summaryrefslogtreecommitdiff
path: root/src/sound/sound.cpp
diff options
context:
space:
mode:
authorAlexander Baldeck <alexander@archlinux.org>2004-09-29 06:39:57 +0000
committerAlexander Baldeck <alexander@archlinux.org>2004-09-29 06:39:57 +0000
commit92f7df43e255dda51f5ece57d2141645bd693afb (patch)
treed7c8ab8f85408d6aef341aea7cc01babbee5e57e /src/sound/sound.cpp
parentc9de7c64417f836358298a83e98a11e413892ac2 (diff)
downloadmana-client-92f7df43e255dda51f5ece57d2141645bd693afb.tar.gz
mana-client-92f7df43e255dda51f5ece57d2141645bd693afb.tar.bz2
mana-client-92f7df43e255dda51f5ece57d2141645bd693afb.tar.xz
mana-client-92f7df43e255dda51f5ece57d2141645bd693afb.zip
added simple soundpool (LoadItem)
Diffstat (limited to 'src/sound/sound.cpp')
-rw-r--r--src/sound/sound.cpp68
1 files changed, 48 insertions, 20 deletions
diff --git a/src/sound/sound.cpp b/src/sound/sound.cpp
index f85f4927..900262d8 100644
--- a/src/sound/sound.cpp
+++ b/src/sound/sound.cpp
@@ -53,33 +53,35 @@
32/20 sounds realistic here.
*/
void TmwSound::Init(int voices, int mod_voices) {
- isOk = -1;
+ isOk = -1;
- if(mod_voices >= voices)
- throw("No voices left for SFX! Sound will be disabled!");
+ if(mod_voices >= voices)
+ throw("No voices left for SFX! Sound will be disabled!");
- install_timer();
- reserve_voices (voices, -1);
+ install_timer();
+ reserve_voices (voices, -1);
- #ifdef WIN32
- if (install_sound (DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) < 0)
- #else
- if (install_sound (DIGI_AUTODETECT, MIDI_NONE, NULL) < 0)
- #endif
- throw("Could not initialize sound... :-(");
+ #ifdef WIN32
+ if (install_sound (DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) < 0)
+ #else
+ if (install_sound (DIGI_AUTODETECT, MIDI_NONE, NULL) < 0)
+ #endif
+ throw("Could not initialize sound... :-(");
- if (install_mod (mod_voices) < 0)
- throw("Could not install MOD player... :-(");
+ if (install_mod (mod_voices) < 0)
+ throw("Could not install MOD player... :-(");
- mod = NULL;
- mid = NULL;
- sfx = NULL;
+ mod = NULL;
+ mid = NULL;
+ sfx = NULL;
- pan = 128;
- pitch=1000;
+ pan = 128;
+ pitch=1000;
- isOk = 0;
+ items = 0;
+
+ isOk = 0;
}
/**
@@ -126,6 +128,32 @@ void TmwSound::SetAdjVol(int adigi, int amid, int amod) {
}
/**
+ preloads a sound-item into buffer
+ char *fpath -> full path to file
+ char type -> type of item (TMWSOUND_MOD, TMWSOUND_MID, TMWSOUND_SFX)
+
+ NOTE:
+ only TMWSOUND_SFX items get preloaded. everything
+ else will only store the full path to the file
+*/
+TMWSOUND_SID TmwSound::LoadItem(char *fpath, char type) {
+ POOL_ITEM item;
+ if(type == TMWSOUND_SFX) {
+ item.data = (void*)load_sample(fpath);
+ if(item.data == NULL)
+ throw(sprintf("Unable to load sample: %s\n", fpath));
+ }
+
+ items++;
+ item.id = items;
+ item.type = type;
+ item.fname = fpath;
+
+ soundpool.push_front(item);
+ return item.id;
+}
+
+/**
start BGM using a midi file
char *in -> full path of midi file
int loop -> how many times should the midi be looped? (-1 = infinite)
@@ -230,7 +258,7 @@ void TmwSound::StopBGM() {
*/
void TmwSound::StartWAV(char * in, int pan) {
if(isOk==-1)
- return;
+ return;
sfx = load_sample(in);
if (!sfx)