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(int16 *buffer,
const int numSamples)
override;
202 bool endOfData()
const override {
return _numActiveChannels == 0; }
210 int16 getNumChannelsToMix()
const;
216 bool channelShouldMix(
const AudioChannel &channel)
const;
222 int writeAudioInternal(
Audio::AudioStream &sourceStream,
Audio::RateConverter &converter, int16 *targetBuffer,
const int numSamples,
const Audio::st_volume_t leftVolume,
const Audio::st_volume_t rightVolume);
225#pragma mark Channel management
232 return _numActiveChannels;
279 uint8 _numActiveChannels;
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;
357 return _globalBitDepth;
371 return _globalNumOutputChannels;
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;
463 uint16
play(int16 channelIndex,
const ResourceId resourceId,
const bool autoPlay,
const bool loop,
const int16 volume,
const reg_t soundNode,
const bool monitor);
478 bool pause(
const int16 channelIndex);
487 int16
stop(
const int16 channelIndex);
496 uint16
restart(
const ResourceId resourceId,
const bool autoPlay,
const bool loop,
const int16 volume,
const reg_t soundNode,
const bool monitor);
510 void setLoop(
const int16 channelIndex,
const bool loop);
519 void setPan(
const int16 channelIndex,
const int16 pan) {
521 getChannel(channelIndex).
pan = pan;
528 uint32 _pausedAtTick;
533 uint32 _startedAtTick;
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) {
578 return _attenuatedMixing;
586 _attenuatedMixing = attenuated;
594 bool _attenuatedMixing;
600 bool _useModifiedAttenuation;
607 bool processFade(
const int16 channelIndex);
610#pragma mark Signal monitoring
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;
Definition: audiostream.h:50
virtual uint getOutputRate() const =0
@ kMaxChannelVolume
Definition: mixer.h:82
@ kSFXSoundType
Definition: mixer.h:77
virtual void setVolumeForSoundType(SoundType type, int volume)=0
void reset(PointerType o=nullptr)
Definition: ptr.h:607
PointerType release()
Definition: ptr.h:645
Definition: serializer.h:352
Definition: serializer.h:80
Definition: audio32.h:174
int getRate() const override
Definition: audio32.h:201
int16 getVolume(const int16 channelIndex) const
void setMasterVolume(const int16 volume)
Definition: audio32.h:561
uint8 getNumActiveChannels() const
Definition: audio32.h:230
int16 getPosition(const int16 channelIndex) const
bool endOfStream() const override
Definition: audio32.h:203
void setVolume(const int16 channelIndex, int16 volume)
uint8 getNumOutputChannels() const
Definition: audio32.h:370
int16 findChannelByArgs(EngineState *s, int argc, const reg_t *argv, const int startIndex, const reg_t soundNode) const
void setSampleRate(uint16 rate)
uint8 getNumUnlockedChannels() const
int readBuffer(int16 *buffer, const int numSamples) override
uint8 getBitDepth() const
Definition: audio32.h:356
void setNumOutputChannels(int16 numChannels)
void setPreload(uint8 preload)
Definition: audio32.h:392
bool fadeChannel(const int16 channelIndex, const int16 targetVolume, const int16 speed, const int16 steps, const bool stopAfterFade)
int16 stop(const int16 channelIndex)
void setLoop(const int16 channelIndex, const bool loop)
bool isStereo() const override
Definition: audio32.h:200
void lockResource(const ResourceId resourceId, const bool lock)
uint16 play(int16 channelIndex, const ResourceId resourceId, const bool autoPlay, const bool loop, const int16 volume, const reg_t soundNode, const bool monitor)
uint16 getSampleRate() const
Definition: audio32.h:342
bool getAttenuatedMixing() const
Definition: audio32.h:577
bool resume(const int16 channelIndex)
bool endOfData() const override
Definition: audio32.h:202
uint8 getPreload() const
Definition: audio32.h:384
@ kMaxVolume
Definition: audio32.h:185
void setBitDepth(uint8 depth)
uint16 restart(const ResourceId resourceId, const bool autoPlay, const bool loop, const int16 volume, const reg_t soundNode, const bool monitor)
bool pause(const int16 channelIndex)
int16 findChannelById(const ResourceId resourceId, const reg_t soundNode=NULL_REG) const
void setAttenuatedMixing(bool attenuated)
Definition: audio32.h:584
void setPan(const int16 channelIndex, const int16 pan)
Definition: audio32.h:519
Definition: resource.h:256
Definition: resource.h:161
Definition: resource.h:327
AudioChannelIndex
Definition: audio32.h:163
ResourceId id
Definition: audio32.h:51
uint32 startedAtTick
Definition: audio32.h:80
int pan
Definition: audio32.h:134
Resource * resource
Definition: audio32.h:57
uint32 fadeDuration
Definition: audio32.h:101
uint32 pausedAtTick
Definition: audio32.h:85
uint32 fadeStartTick
Definition: audio32.h:91
uint32 duration
Definition: audio32.h:75
Common::ScopedPtr< Audio::AudioStream > stream
Definition: audio32.h:64
bool robot
Definition: audio32.h:117
bool stopChannelOnFade
Definition: audio32.h:112
int fadeStartVolume
Definition: audio32.h:96
int volume
Definition: audio32.h:128
int fadeTargetVolume
Definition: audio32.h:106
Common::ScopedPtr< Audio::RateConverter > converter
Definition: audio32.h:70
reg_t soundNode
Definition: audio32.h:123
Definition: robot_decoder.h:300
Definition: robot_decoder.h:280
Definition: vm_types.h:39