From 791efd853aacee15bb2f5b2e575c59fd9bb7480d Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 25 Jul 2003 01:19:14 +0000 Subject: lots of mixer changes: replaced _volumeTable by _globalVolume (applying volume after resampling is more accurate); made more member vars of SoundMixer protected (and thus added some new getter methods); added (untested) support for a second (stereo) channel when playing MP3 svn-id: r9184 --- sound/mixer.h | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'sound/mixer.h') diff --git a/sound/mixer.h b/sound/mixer.h index c98f9d4af7..6c7e8edf97 100644 --- a/sound/mixer.h +++ b/sound/mixer.h @@ -43,6 +43,7 @@ class Channel; class File; class SoundMixer { + friend class Channel; public: typedef void PremixProc (void *param, int16 *data, uint len); @@ -50,6 +51,16 @@ public: NUM_CHANNELS = 16 }; + enum { + // Do *NOT* change any of these flags without looking at the code in mixer.cpp + FLAG_UNSIGNED = 1 << 0, // unsigned samples (default: signed) + FLAG_STEREO = 1 << 1, // sound is in stereo (default: mono) + FLAG_16BITS = 1 << 2, // sound is 16 bits wide (default: 8bit) + FLAG_AUTOFREE = 1 << 3, // sound buffer is freed automagically at the end of playing + FLAG_REVERSE_STEREO = 1 << 4, // reverse the left and right stereo channel + FLAG_LOOP = 1 << 5 // loop the audio + }; + private: OSystem *_syst; OSystem::MutexRef _mutex; @@ -57,10 +68,9 @@ private: void *_premixParam; PremixProc *_premixProc; -public: uint _outputRate; - int16 *_volumeTable; + int _globalVolume; int _musicVolume; bool _paused; @@ -72,15 +82,6 @@ public: ~SoundMixer(); // start playing a raw sound - enum { - // Do *NOT* change any of these flags without looking at the code in mixer.cpp - FLAG_UNSIGNED = 1 << 0, // unsigned samples - FLAG_STEREO = 1 << 1, // sound is in stereo - FLAG_16BITS = 1 << 2, // sound is 16 bits wide - FLAG_AUTOFREE = 1 << 3, // sound buffer is freed automagically at the end of playing - FLAG_REVERSE_STEREO = 1 << 4, // sound should be reverse stereo - FLAG_LOOP = 1 << 5 // loop the audio - }; int playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, int id = -1); #ifdef USE_MAD int playMP3(PlayingSoundHandle *handle, void *sound, uint32 size, byte flags); @@ -118,21 +119,33 @@ public: bool hasActiveSFXChannel(); /** Check whether the specified channel is active. */ - bool isActiveChannel(int index); + bool isChannelActive(int index); + + /** Check whether the specified channel is in use. */ + bool isChannelUsed(int index); /** bind to the OSystem object => mixer will be * invoked automatically when samples need * to be generated */ bool bindToSystem(OSystem *syst); + /** pause - unpause */ + void pause(bool paused); + /** set the global volume, 0-256 */ void setVolume(int volume); + + /** query the global volume, 0-256 */ + int getVolume() const { return _globalVolume; } /** set the music volume, 0-256 */ void setMusicVolume(int volume); - - /** pause - unpause */ - void pause(bool paused); + + /** query the music volume, 0-256 */ + int getMusicVolume() const { return _musicVolume; } + + /** query the output rate in kHz */ + uint getOutputRate() const { return _outputRate; } private: int insertChannel(PlayingSoundHandle *handle, Channel *chan); @@ -140,7 +153,7 @@ private: /** mix */ void mix(int16 * buf, uint len); - static void onGenerateSamples(void *s, byte *samples, int len); + static void mixCallback(void *s, byte *samples, int len); }; #endif -- cgit v1.2.3