aboutsummaryrefslogtreecommitdiff
path: root/sound/mixer.h
diff options
context:
space:
mode:
authorMax Horn2003-07-25 01:19:14 +0000
committerMax Horn2003-07-25 01:19:14 +0000
commit791efd853aacee15bb2f5b2e575c59fd9bb7480d (patch)
treeb950b381c024de5d9b0306017f897d0a1915802d /sound/mixer.h
parent95bb74e2b886c22adce2fd0bdd40083b8d8efb53 (diff)
downloadscummvm-rg350-791efd853aacee15bb2f5b2e575c59fd9bb7480d.tar.gz
scummvm-rg350-791efd853aacee15bb2f5b2e575c59fd9bb7480d.tar.bz2
scummvm-rg350-791efd853aacee15bb2f5b2e575c59fd9bb7480d.zip
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
Diffstat (limited to 'sound/mixer.h')
-rw-r--r--sound/mixer.h45
1 files changed, 29 insertions, 16 deletions
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