22 #ifndef SCUMM_PLAYERS_MAC_SOUND_LOWLEVEL_H 23 #define SCUMM_PLAYERS_MAC_SOUND_LOWLEVEL_H 25 #include "audio/audiostream.h" 26 #include "audio/mixer.h" 27 #include "common/array.h" 28 #include "common/func.h" 34 MacSoundDriver(
Common::Mutex &mutex, uint32 deviceRate,
int activeChannels,
bool canInterpolate,
bool internal16Bit) : _mutex(mutex),
35 _smpSize(internal16Bit ? 2 : 1), _smpMin(internal16Bit ? -32768 : -128), _smpMax(internal16Bit ? 32767 : 127) {
36 for (
int i = 0; i < 4; ++i) {
37 _status[i].deviceRate = deviceRate;
38 _status[i].numExternalMixChannels = activeChannels;
39 _status[i].allowInterPolation = canInterpolate;
47 Status() : deviceRate(0), numExternalMixChannels(0), allowInterPolation(
false), flags(0) {}
49 int numExternalMixChannels;
50 bool allowInterPolation;
55 enum StatusFlag : uint8 {
56 kStatusPlaying = 1 << 0,
57 kStatusOverflow = 1 << 1,
58 kStatusStartup = 1 << 2,
60 kStatusDisabled = 1 << 7
78 PCMSound() : len(0), rate(0), loopst(0), loopend(0), baseFreq(0), stereo(
false), enc(0) {}
79 PCMSound(
Common::SharedPtr<const byte> a, uint32 b, uint32 c, uint32 d, uint32 e, byte f, byte g,
bool h) : data(a), len(b), rate(c), loopst(d), loopend(e), baseFreq(f), enc(g), stereo(h) {}
90 enum SynthType : byte {
97 enum ChanAttrib : byte {
100 kWaveInitChannel0 = 4,
101 kWaveInitChannel1 = 5,
102 kWaveInitChannel2 = 6,
103 kWaveInitChannel3 = 7,
110 enum ExecMode : byte {
115 typedef int ChanHandle;
118 enum Flags : uint32 {
122 DoubleBuffer(ChanHandle hdl, uint32 numframes) : numFrames(numframes), flags(0), data(0), chanHandle(hdl) {}
125 const ChanHandle chanHandle;
133 virtual void sndChannelCallback(uint16 arg1,
const void *arg2) {}
134 virtual void dblBuffCallback(
DoubleBuffer *dblBuffer) {}
145 ChanHandle createChannel(
Audio::Mixer::SoundType sndType, SynthType synthType, byte attributes, ChanCallback *callback);
146 void disposeChannel(ChanHandle handle);
148 void playSamples(ChanHandle handle, ExecMode mode,
const PCMSound *snd);
149 void playNote(ChanHandle handle, ExecMode mode, uint8 note, uint16 duration);
150 void quiet(ChanHandle handle, ExecMode mode);
151 void flush(ChanHandle handle, ExecMode mode);
152 void wait(ChanHandle handle, ExecMode mode, uint16 duration);
153 void loadWaveTable(ChanHandle handle, ExecMode mode,
const byte *data, uint16 dataSize);
154 void loadInstrument(ChanHandle handle, ExecMode mode,
const PCMSound *snd);
155 void setTimbre(ChanHandle handle, ExecMode mode, uint16 timbre);
156 void callback(ChanHandle handle, ExecMode mode, uint16 arg1,
const void *arg2);
158 bool playDoubleBuffer(ChanHandle handle, byte numChan, byte bitsPerSample, uint32 rate, DBCallback *callback, byte numMixChan = 1);
160 uint8 getChannelStatus(ChanHandle handle)
const;
161 void clearChannelFlags(ChanHandle handle, uint8 flags);
163 static uint32 calcRate(uint32 outRate, uint32 factor, uint32 dataRate);
167 MacSndChannel *findAndCheckChannel(ChanHandle h,
const char *caller, byte reqSynthType)
const;
168 MacSndChannel *findChannel(ChanHandle h)
const;
170 int _numInternalMixChannels[4];
171 int32 *_mixBuffer = 0;
172 uint32 _mixBufferSize;
178 virtual void vblCallback() = 0;
188 void initBuffers(uint32 feedBufferSize);
191 void scaleVolume(uint upscale, uint downscale) { _upscale = upscale; _downscale = downscale; }
193 void setVblCallback(
const CallbackProc *proc);
199 int readBuffer(int16 *buffer,
const int numSamples)
override;
200 bool isStereo()
const override {
return _isStereo; }
201 int getRate()
const override {
return _outputRate; }
214 uint32 _vblSmpQtyRem;
215 uint32 _vblCountDown;
216 uint32 _vblCountDownRem;
217 const CallbackProc *_vblCbProc;
220 SmpBuffer() : start(0), pos(0), end(0), volume(0), lastL(0), lastR(0), size(0), rateConvInt(0), rateConvFrac(0), rateConvAcc(-1), group(
Audio::Mixer::kPlainSoundType) {}
234 const uint32 _outputRate;
235 const uint8 _frameSize;
237 const int _smpInternalSize;
239 const bool _isStereo;
250 uint32 id()
const {
return _id; }
251 const char* name() {
return _name.c_str(); }
259 extern const uint8 _fourToneSynthWaveForm[256];
260 extern const uint32 _fourToneSynthWaveFormSize;
Definition: mac_sound_lowlevel.h:77
Definition: mac_sound_lowlevel.h:32
int getRate() const override
Definition: mac_sound_lowlevel.h:201
bool isStereo() const override
Definition: mac_sound_lowlevel.h:200
Definition: mac_sound_lowlevel.h:130
Definition: mac_sound_lowlevel.h:46
Definition: mac_sound_lowlevel.h:175
SoundType
Definition: mixer.h:62
bool endOfData() const override
Definition: mac_sound_lowlevel.h:202
Definition: mac_sound_lowlevel.h:117
Definition: audiostream.h:50
Definition: mac_sound_lowlevel.h:183
Definition: mac_sound_lowlevel.h:75
Definition: mac_sound_lowlevel.h:242