22 #ifndef DIRECTOR_SOUND_H 23 #define DIRECTOR_SOUND_H 25 #include "audio/mixer.h" 31 class RewindableAudioStream;
32 class LoopableAudioStream;
52 FadeParams(
int sv,
int tv,
int tt,
int st,
bool f,
bool as) :
53 startVol(sv), targetVol(tv), totalTicks(tt), startTicks(st), lapsedTicks(0), fadeIn(f), autoStop(as) {}
56 const uint16 kMinSampledMenu = 10;
57 const uint16 kMaxSampledMenu = 15;
58 const uint16 kNumSampledMenus = kMaxSampledMenu - kMinSampledMenu + 1;
66 : menu(menuID), submenu(submenuID) {}
69 return menu == b.menu && submenu == b.submenu;
99 SoundID(SoundIDType type_,
int a,
int b) {
108 u.external.submenu = b;
113 u.cast.member = memberID.member;
114 u.cast.castLib = memberID.castLib;
117 bool operator==(
const SoundID &b) {
123 return u.cast.member == b.u.cast.member && u.cast.castLib == b.u.cast.castLib;
125 return u.external.menu == b.u.external.menu && u.external.submenu == b.u.external.submenu;
130 bool operator!=(
const SoundID &b) {
131 return !(*
this == b);
134 if (type == kSoundCast)
135 return u.cast.member == 0;
146 int pitchShiftPercent;
149 int lastCuePointIndex;
163 SoundChannel(): handle(), lastPlayedSound(
SoundID()), stopOnZero(
true), fromLastMovie(
false), volume(255), originalRate(-1),
164 pitchShiftPercent(100), fade(
nullptr), puppet(
SoundID()), newPuppet(
false), movieChanged(
false), loopPtr(
nullptr),
165 lastCuePointIndex(-1) {}
194 void playSound(
SoundID soundId,
int soundChannel,
bool forPuppet =
false);
195 void playCastMember(
CastMemberID memberID,
int soundChannel,
bool forPuppet =
false);
196 void playExternalSound(uint16 menu, uint16 submenu,
int soundChannel);
198 void playFPlaySound();
199 void setSoundEnabled(
bool enabled);
201 void changingMovie();
203 void loadSampleSounds(uint type);
204 void unloadSampleSounds();
206 bool isChannelPuppet(
int soundChannel);
207 void setPuppetSound(
SoundID soundId,
int soundChannel);
208 void disablePuppetSound(
int soundChannel);
209 void playPuppetSound(
int soundChannel);
211 bool getSoundEnabled() {
return _enable; }
215 void registerFade(
int soundChannel,
int startVol,
int targetVol,
int ticks,
bool autoStop =
false);
216 void registerFade(
int soundChannel,
bool fadeIn,
int ticks,
bool autoStop =
false);
219 bool isChannelActive(
int soundChannel);
220 uint8 getChannelVolume(
int soundChannel);
221 void setChannelVolume(
int channel, uint8 volume);
222 int8 getChannelBalance(
int soundChannel);
223 void setChannelBalance(
int soundChannel, int8 balance);
224 uint8 getChannelFaderL(
int soundChannel);
225 void setChannelFaderL(
int soundChannel, uint8 faderL);
226 uint8 getChannelFaderR(
int soundChannel);
227 void setChannelFaderR(
int soundChannel, uint8 faderR);
228 void stopSound(
int soundChannel);
230 void setChannelDefaultVolume(
int soundChannel);
231 void setChannelPitchShift(
int soundChannel,
int pitchShiftPercent);
233 void processCuePoints();
236 void setLastPlayedSound(
int soundChannel,
SoundID soundId,
bool stopOnZero =
true);
237 bool isLastPlayedSound(
int soundChannel,
const SoundID &soundId);
238 bool shouldStopOnZero(
int soundChannel);
240 void setChannelVolumeInternal(
int soundChannel, uint8 volume);
241 bool assertChannel(
int soundChannel);
242 void cancelFade(
int soundChannel);
250 virtual Audio::AudioStream *getAudioStream(
bool looping =
false,
bool forPuppet =
false, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES) {
return nullptr; }
251 virtual int getChannelCount() {
return 0; }
252 virtual int getSampleRate() {
return 0; }
253 virtual int getSampleSize() {
return 0; }
265 Audio::AudioStream *getAudioStream(
bool looping =
false,
bool forPuppet =
false, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES)
override;
266 bool hasLoopBounds();
267 void resetLoopBounds();
268 bool hasValidLoopBounds();
269 int getChannelCount()
override {
return _channels; }
270 int getSampleRate()
override {
return _rate; }
271 int getSampleSize()
override {
return _bits; }
291 Audio::AudioStream *getAudioStream(
bool looping =
false,
bool forPuppet =
false, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES)
override;
303 Audio::AudioStream *getAudioStream(
bool looping =
false,
bool forPuppet =
false, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES)
override;
315 int32 playbackStartFrame;
317 int32 loopStartFrame;
321 int32 playbackEndFrame;
325 byte compressionType[16];
327 int32 bytesPerSample;
330 byte soundHeaderType[16];
331 uint32 platformData[63];
344 byte *_data =
nullptr;
347 Audio::AudioStream *getAudioStream(
bool looping =
false,
bool forPuppet =
false, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES)
override;
Definition: audiostream.h:123
Definition: macresman.h:126
Definition: algorithm.h:29
Definition: audiostream.h:50