22 #ifndef SCI_SOUND_AUDIO32_H 23 #define SCI_SOUND_AUDIO32_H 25 #include "audio/audiostream.h" 26 #include "audio/mixer.h" 27 #include "audio/rate.h" 28 #include "common/array.h" 29 #include "common/mutex.h" 30 #include "common/scummsys.h" 31 #include "sci/resource/resource.h" 32 #include "sci/engine/state.h" 33 #include "sci/engine/vm_types.h" 34 #include "sci/video/robot_decoder.h" 42 #pragma mark AudioChannel 165 kNoExistingChannel = -2,
187 kMonitorAudioFlagSci3 = 0x80
197 #pragma mark AudioStream implementation 199 int readBuffer(Audio::st_sample_t *buffer,
const int numSamples)
override;
202 bool endOfData()
const override {
return _numActiveChannels == 0; }
210 int16 getNumChannelsToMix()
const;
216 bool channelShouldMix(
const AudioChannel &channel)
const;
225 #pragma mark Channel management 232 return _numActiveChannels;
246 uint8 getNumUnlockedChannels()
const;
259 int16 findChannelById(
const ResourceId resourceId,
const reg_t soundNode = NULL_REG)
const;
264 void lockResource(
const ResourceId resourceId,
const bool lock);
279 uint8 _numActiveChannels;
295 UnlockList _resourcesToUnlock;
300 LockList _lockedResourceIds;
305 inline AudioChannel &getChannel(
const int16 channelIndex) {
307 assert(channelIndex >= 0 && channelIndex < _numActiveChannels);
308 return _channels[channelIndex];
314 inline const AudioChannel &getChannel(
const int16 channelIndex)
const {
316 assert(channelIndex >= 0 && channelIndex < _numActiveChannels);
317 return _channels[channelIndex];
323 void freeUnusedChannels();
328 void freeChannel(
const int16 channelIndex);
333 void unlockResources();
336 #pragma mark Script compatibility 343 return _globalSampleRate;
350 void setSampleRate(uint16 rate);
357 return _globalBitDepth;
364 void setBitDepth(uint8 depth);
371 return _globalNumOutputChannels;
378 void setNumOutputChannels(int16 numChannels);
400 uint16 _globalSampleRate;
406 uint16 _maxAllowedSampleRate;
411 uint8 _globalBitDepth;
417 uint8 _maxAllowedBitDepth;
423 uint8 _globalNumOutputChannels;
429 uint8 _maxAllowedOutputChannels;
443 bool finishRobotAudio();
444 bool stopRobotAudio();
450 int16 findRobotChannel()
const;
455 bool _robotAudioPaused;
458 #pragma mark Playback 463 uint16 play(int16 channelIndex,
const ResourceId resourceId,
const bool autoPlay,
const bool loop,
const int16
volume,
const reg_t soundNode,
const bool monitor);
469 bool resume(
const int16 channelIndex);
470 bool resume(
const ResourceId resourceId,
const reg_t soundNode = NULL_REG) {
472 return resume(findChannelById(resourceId, soundNode));
478 bool pause(
const int16 channelIndex);
479 bool pause(
const ResourceId resourceId,
const reg_t soundNode = NULL_REG) {
481 return pause(findChannelById(resourceId, soundNode));
487 int16 stop(
const int16 channelIndex);
488 int16 stop(
const ResourceId resourceId,
const reg_t soundNode = NULL_REG) {
490 return stop(findChannelById(resourceId, soundNode));
496 uint16 restart(
const ResourceId resourceId,
const bool autoPlay,
const bool loop,
const int16 volume,
const reg_t soundNode,
const bool monitor);
501 int16 getPosition(
const int16 channelIndex)
const;
502 int16 getPosition(
const ResourceId resourceId,
const reg_t soundNode = NULL_REG) {
504 return getPosition(findChannelById(resourceId, soundNode));
510 void setLoop(
const int16 channelIndex,
const bool loop);
511 void setLoop(
const ResourceId resourceId,
const reg_t soundNode,
const bool loop) {
513 setLoop(findChannelById(resourceId, soundNode), loop);
519 void setPan(
const int16 channelIndex,
const int16
pan) {
521 getChannel(channelIndex).pan =
pan;
528 uint32 _pausedAtTick;
533 uint32 _startedAtTick;
542 int16 getVolume(
const int16 channelIndex)
const;
543 int16 getVolume(
const ResourceId resourceId,
const reg_t soundNode)
const {
545 return getVolume(findChannelById(resourceId, soundNode));
552 void setVolume(
const int16 channelIndex, int16 volume);
553 void setVolume(
const ResourceId resourceId,
const reg_t soundNode,
const int16 volume) {
555 setVolume(findChannelById(resourceId, soundNode), volume);
568 bool fadeChannel(
const int16 channelIndex,
const int16 targetVolume,
const int16 speed,
const int16 steps,
const bool stopAfterFade);
569 bool fadeChannel(
const ResourceId resourceId,
const reg_t soundNode,
const int16 targetVolume,
const int16 speed,
const int16 steps,
const bool stopAfterFade) {
571 return fadeChannel(findChannelById(resourceId, soundNode), targetVolume, speed, steps, stopAfterFade);
578 return _attenuatedMixing;
586 _attenuatedMixing = attenuated;
594 bool _attenuatedMixing;
600 bool _useModifiedAttenuation;
607 bool processFade(
const int16 channelIndex);
610 #pragma mark Signal monitoring 616 bool hasSignal()
const;
624 int16 _monitoredChannelIndex;
635 int _numMonitoredSamples;
646 reg_t kernelMixing(
const int argc,
const reg_t *
const argv);
653 #pragma mark Debugging 655 void printAudioList(
Console *con)
const;
660 #endif // SCI_SOUND_AUDIO32_H Definition: robot_decoder.h:280
ResourceId id
Definition: audio32.h:51
uint32 fadeStartTick
Definition: audio32.h:91
virtual uint getOutputRate() const =0
int fadeStartVolume
Definition: audio32.h:96
uint32 duration
Definition: audio32.h:75
uint8 getNumOutputChannels() const
Definition: audio32.h:370
bool robot
Definition: audio32.h:117
uint8 getBitDepth() const
Definition: audio32.h:356
uint16 getSampleRate() const
Definition: audio32.h:342
int volume
Definition: audio32.h:128
uint32 startedAtTick
Definition: audio32.h:80
bool endOfData() const override
Definition: audio32.h:202
bool stopChannelOnFade
Definition: audio32.h:112
Definition: serializer.h:79
void setPan(const int16 channelIndex, const int16 pan)
Definition: audio32.h:519
PointerType release()
Definition: ptr.h:644
uint8 getNumActiveChannels() const
Definition: audio32.h:230
Definition: resource.h:327
uint32 fadeDuration
Definition: audio32.h:101
Definition: audio32.h:174
void setAttenuatedMixing(bool attenuated)
Definition: audio32.h:584
void setMasterVolume(const int16 volume)
Definition: audio32.h:561
Definition: resource.h:256
Definition: audiostream.h:50
void reset(PointerType o=nullptr)
Definition: ptr.h:607
Definition: serializer.h:308
bool getAttenuatedMixing() const
Definition: audio32.h:577
uint8 getPreload() const
Definition: audio32.h:384
virtual void setVolumeForSoundType(SoundType type, int volume)=0
int fadeTargetVolume
Definition: audio32.h:106
Common::ScopedPtr< Audio::RateConverter > converter
Definition: audio32.h:70
Definition: resource.h:161
Resource * resource
Definition: audio32.h:57
uint32 pausedAtTick
Definition: audio32.h:85
AudioChannelIndex
Definition: audio32.h:163
int getRate() const override
Definition: audio32.h:201
Definition: robot_decoder.h:300
void setPreload(uint8 preload)
Definition: audio32.h:392
reg_t soundNode
Definition: audio32.h:123
int pan
Definition: audio32.h:134
bool endOfStream() const override
Definition: audio32.h:203
Definition: vm_types.h:39
Common::ScopedPtr< Audio::AudioStream > stream
Definition: audio32.h:64
bool isStereo() const override
Definition: audio32.h:200