ScummVM API documentation
player_mod.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef SCUMM_PLAYERS_PLAYER_MOD_H
23#define SCUMM_PLAYERS_PLAYER_MOD_H
24
25#include "scumm/scumm.h"
26#include "audio/audiostream.h"
27#include "audio/mixer.h"
28#include "common/mutex.h"
29
30namespace Audio {
31class RateConverter;
32}
33
34namespace Scumm {
35
40public:
42 ~Player_MOD() override;
43 virtual void setMusicVolume(int vol);
44
45 virtual void startChannel(int id, void *data, int size, int rate, uint8 vol, int loopStart = 0, int loopEnd = 0, int8 pan = 0);
46 virtual void stopChannel(int id);
47 virtual void setChannelVol(int id, uint8 vol);
48 virtual void setChannelPan(int id, int8 pan);
49 virtual void setChannelFreq(int id, int freq);
50
51 typedef void ModUpdateProc(void *param);
52
53 virtual void setUpdateProc(ModUpdateProc *proc, void *param, int freq);
54 virtual void clearUpdateProc();
55
56 // AudioStream API
57 int readBuffer(int16 *buffer, const int numSamples) override {
58 Common::StackLock lock(_mutex);
59 do_mix(buffer, numSamples / 2);
60 return numSamples;
61 }
62 bool isStereo() const override { return true; }
63 bool endOfData() const override { return false; }
64 int getRate() const override { return _sampleRate; }
65
66private:
67 enum {
68 MOD_MAXCHANS = 24
69 };
70
71 struct soundChan {
72 int id;
73 uint8 vol;
74 int8 pan;
75 uint16 freq;
76
77 uint32 ctr;
78 int16 pos;
79 Audio::AudioStream *input;
80 };
81
82 Audio::Mixer *_mixer;
83 Audio::SoundHandle _soundHandle;
84 Common::Mutex _mutex;
85
86 uint32 _mixamt;
87 uint32 _mixpos;
88 const int _sampleRate;
89
90 soundChan _channels[MOD_MAXCHANS];
91
92 uint8 _maxvol;
93
94 virtual void do_mix(int16 *buf, uint len);
95
96 ModUpdateProc *_playproc;
97 void *_playparam;
98};
99
100} // End of namespace Scumm
101
102#endif
Definition: audiostream.h:50
Definition: mixer.h:70
Definition: mixer.h:49
Definition: mutex.h:67
Definition: mutex.h:51
Definition: player_mod.h:39
int readBuffer(int16 *buffer, const int numSamples) override
Definition: player_mod.h:57
int getRate() const override
Definition: player_mod.h:64
bool isStereo() const override
Definition: player_mod.h:62
bool endOfData() const override
Definition: player_mod.h:63
Definition: system.h:39
Definition: actor.h:30