diff options
Diffstat (limited to 'engines/agi/sound.h')
-rw-r--r-- | engines/agi/sound.h | 141 |
1 files changed, 22 insertions, 119 deletions
diff --git a/engines/agi/sound.h b/engines/agi/sound.h index 001b3e35c2..63b36e017c 100644 --- a/engines/agi/sound.h +++ b/engines/agi/sound.h @@ -26,15 +26,10 @@ #ifndef AGI_SOUND_H #define AGI_SOUND_H -#include "sound/audiostream.h" #include "sound/mixer.h" -class MidiDriver; - namespace Agi { -#define BUFFER_SIZE 410 - #define SOUND_EMU_NONE 0 #define SOUND_EMU_PC 1 #define SOUND_EMU_PCJR 2 @@ -44,13 +39,6 @@ namespace Agi { #define SOUND_EMU_COCO3 6 #define SOUND_EMU_MIDI 7 -#define WAVEFORM_SIZE 64 -#define ENV_ATTACK 10000 /**< envelope attack rate */ -#define ENV_DECAY 1000 /**< envelope decay rate */ -#define ENV_SUSTAIN 100 /**< envelope sustain level */ -#define ENV_RELEASE 7500 /**< envelope release rate */ -#define NUM_CHANNELS 7 /**< number of sound channels */ - /** * AGI sound note structure. */ @@ -70,19 +58,6 @@ struct AgiNote { } }; -struct CoCoNote { - uint8 freq; - uint8 volume; - uint16 duration; ///< Note duration - - /** Reads a CoCoNote through the given pointer. */ - void read(const uint8 *ptr) { - freq = *ptr; - volume = *(ptr + 1); - duration = READ_LE_UINT16(ptr + 2); - } -}; - /** * AGI sound resource types. * It's probably coincidence that all the values here are powers of two @@ -94,47 +69,26 @@ enum AgiSoundEmuType { AGI_SOUND_MIDI = 0x0002, AGI_SOUND_4CHN = 0x0008 }; -enum AgiSoundFlags { - AGI_SOUND_LOOP = 0x0001, - AGI_SOUND_ENVELOPE = 0x0002 -}; -enum AgiSoundEnv { - AGI_SOUND_ENV_ATTACK = 3, - AGI_SOUND_ENV_DECAY = 2, - AGI_SOUND_ENV_SUSTAIN = 1, - AGI_SOUND_ENV_RELEASE = 0 -}; - - -/** - * AGI engine sound channel structure. - */ -struct ChannelInfo { - AgiSoundEmuType type; - const uint8 *ptr; // Pointer to the AgiNote data - const int16 *ins; - int32 size; - uint32 phase; - uint32 flags; // ORs values from AgiSoundFlags - AgiSoundEnv adsr; - int32 timer; - uint32 end; - uint32 freq; - uint32 vol; - uint32 env; -}; class SoundMgr; class SoundGen { public: - SoundGen() {} + SoundGen(AgiEngine *vm, Audio::Mixer *pMixer) : _vm(vm), _mixer(pMixer) { + _sampleRate = pMixer->getOutputRate(); + } + virtual ~SoundGen() {} - virtual void play(int resnum, int flag) = 0; + virtual void play(int resnum) = 0; virtual void stop(void) = 0; - virtual void premixerCall(int16 *stream, int len) = 0; + AgiEngine *_vm; + + Audio::Mixer *_mixer; + Audio::SoundHandle _soundHandle; + + uint32 _sampleRate; }; /** @@ -177,81 +131,30 @@ protected: uint16 _type; ///< Sound resource type }; -class AgiEngine; -class IIgsSoundMgr; -class MusicPlayer; - -struct IIgsExeInfo; - -class SoundMgr : public Audio::AudioStream { +class SoundMgr { public: SoundMgr(AgiEngine *agi, Audio::Mixer *pMixer); ~SoundMgr(); - virtual void setVolume(uint8 volume); - // AudioStream API - int readBuffer(int16 *buffer, const int numSamples); + void setVolume(uint8 volume); - bool isStereo() const { - return false; - } - - bool endOfData() const { - return false; - } + void unloadSound(int); + void playSound(); + int initSound(); + void deinitSound(); + void startSound(int, int); + void stopSound(); - int getRate() const { - // FIXME: Ideally, we should use _sampleRate. - return 22050; - } + void soundIsFinished(); +private: int _endflag; AgiEngine *_vm; -private: - Audio::Mixer *_mixer; - Audio::SoundHandle _soundHandle; - - MusicPlayer *_musicPlayer; - MidiDriver *_midiDriver; - - uint32 _sampleRate; - - bool _playing; - ChannelInfo _chn[NUM_CHANNELS]; - IIgsSoundMgr *_gsSound; - int _playingSound; - uint8 _env; - bool _disabledMidi; - - int16 *_sndBuffer; - const int16 *_waveform; - - bool _useChorus; - - void premixerCall(int16 *buf, uint len); - void fillAudio(void *udata, int16 *stream, uint len); - SoundGen *_soundGen; -public: - void unloadSound(int); - void playSound(); - int initSound(); - void deinitSound(); - void startSound(int, int); - void stopSound(); - void stopNote(int i); - void playNote(int i, int freq, int vol); - void playAgiSound(); - void playCoCoSound(); - uint32 mixSound(); - bool loadInstruments(); - void playMidiSound(); - void playSampleSound(); - const IIgsExeInfo *getIIgsExeInfo(enum AgiGameID gameid) const; - static bool convertWave(Common::SeekableReadStream &source, int8 *dest, uint length); + int _playingSound; }; } // End of namespace Agi |