diff options
author | Alexander Baldeck <alexander@archlinux.org> | 2004-09-29 06:39:57 +0000 |
---|---|---|
committer | Alexander Baldeck <alexander@archlinux.org> | 2004-09-29 06:39:57 +0000 |
commit | 92f7df43e255dda51f5ece57d2141645bd693afb (patch) | |
tree | d7c8ab8f85408d6aef341aea7cc01babbee5e57e /src/sound/sound.h | |
parent | c9de7c64417f836358298a83e98a11e413892ac2 (diff) | |
download | mana-92f7df43e255dda51f5ece57d2141645bd693afb.tar.gz mana-92f7df43e255dda51f5ece57d2141645bd693afb.tar.bz2 mana-92f7df43e255dda51f5ece57d2141645bd693afb.tar.xz mana-92f7df43e255dda51f5ece57d2141645bd693afb.zip |
added simple soundpool (LoadItem)
Diffstat (limited to 'src/sound/sound.h')
-rw-r--r-- | src/sound/sound.h | 115 |
1 files changed, 73 insertions, 42 deletions
diff --git a/src/sound/sound.h b/src/sound/sound.h index 12300e58..4fbe3e45 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -24,8 +24,12 @@ #ifndef __SOUND_H #define __SOUND_H +#include <list> +#include <string> +#include <fstream> + #ifdef WIN32 - #pragma warning(disable:4312) + #pragma warning(disable:4312) #endif #include <allegro.h> #include <jgmod.h> @@ -33,51 +37,78 @@ using namespace std; /** - rewrite of non-existend sdl-soundengine using allegro - - Author: kth5 aka Alexander Baldeck - pipe your question, suggestions and flames to: kth5@gawab.com + rewrite of non-existend sdl-soundengine using allegro + + Bestviewd w/ Bitstream Vera Sans Mono @ 9pt and a tab-width of 2 spaces - NOTE: - i documented all functions in their implementation. ;-) + Author: kth5 aka Alexander Baldeck + pipe your question, suggestions and flames to: kth5@gawab.com + + NOTE: + i documented all functions in their implementation. ;-) */ +#define TMWSOUND_MOD 1 +#define TMWSOUND_MID 2 +#define TMWSOUND_SFX 3 + +typedef unsigned short TMWSOUND_SID ; + class TmwSound { - public: - void Init(int, int); - int Close(); - - void StartMIDI(char *, int); - void StartMOD(char *, int); - void StopBGM(); - - void StartWAV(char *, int); - void SetVol(int, int, int); - void SetAdjVol(int adigi, int amid, int amod); - - TmwSound() {isOk=-1;} - ~TmwSound() {StopBGM(); Close();}; // if allegros shuts down or object is deleted - // any BGM is stopped and SFX runout - private: - int isOk; // initial value is -1 which means error. - // you can only play sounds and bgm if this is 0. - // should be the case after calling Init() - // successfully - - MIDI * mid; - JGMOD * mod; - SAMPLE * sfx; - - int pan; - int pitch; - - int ret; - int vol_digi; - int vol_midi; - int vol_mod; - - bool isMaxVol(int); -}; + public: + void Init(int, int); + int Close(); + + void StartMIDI(char *, int); + void StartMOD(char *, int); + void StopBGM(); + + void StartWAV(char *, int); + void SetVol(int, int, int); + void SetAdjVol(int, int, int); + TMWSOUND_SID LoadItem(char *, char); + + TmwSound() {isOk=-1;} + + /* if allegro is shut down or object is deleted any BGM is + stopped and SFX run out */ + ~TmwSound() {StopBGM(); Close();}; + private: + /* initial value is -1 which means error or noninitialzed. + you can only play sounds and bgm if this is 0. + that should be the case after calling Init() successfully */ + int isOk; + + MIDI * mid; + JGMOD * mod; + SAMPLE * sfx; + + int pan; + int pitch; + + int ret; + int vol_digi; + int vol_midi; + int vol_mod; + + typedef struct POOL_ITEM { + /* incremental id of pool item */ + TMWSOUND_SID id; + /* type of item */ + char type; + /* (file-)name of sfx only kept for human reasons ^_^ */ + string fname; + /* generic data casted before used */ + void * data; + }; + + /* list of preloaded sound data / items */ + list<POOL_ITEM> soundpool; + list<POOL_ITEM>::iterator sounditem; + TMWSOUND_SID items; + + bool isMaxVol(int); +}; #endif |