1 /* Tower Toppler - Nebulus
2  * Copyright (C) 2000-2012  Andreas R�ver
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18 
19 #include <string.h>
20 #include "sound.h"
21 
22 #include "decl.h"
23 #include "archi.h"
24 #include "configuration.h"
25 
26 static bool samplesloaded = false;
27 
snd_init(void)28 void snd_init(void) {
29   if (!config.nosound()) {
30     ttsounds::instance()->opensound();
31 
32     if (!samplesloaded) {
33 
34       ttsounds::instance()->addsound("water.wav",    SND_WATER,     128, -1);
35       ttsounds::instance()->addsound("tap.wav",      SND_TAP,       MIX_MAX_VOLUME, 0);
36       ttsounds::instance()->addsound("boing.wav",    SND_BOINK,     0,    0);
37       ttsounds::instance()->addsound("hit.wav",      SND_HIT,       MIX_MAX_VOLUME, 0);
38       ttsounds::instance()->addsound("honk.wav",     SND_CROSS,     MIX_MAX_VOLUME, 0);
39       ttsounds::instance()->addsound("tick.wav",     SND_TICK,      MIX_MAX_VOLUME, 0);
40       ttsounds::instance()->addsound("bubbles.wav",  SND_DROWN,     MIX_MAX_VOLUME, 2);
41       ttsounds::instance()->addsound("splash.wav",   SND_SPLASH,    0,    0);
42       ttsounds::instance()->addsound("swoosh.wav",   SND_SHOOT,     MIX_MAX_VOLUME, 0);
43       ttsounds::instance()->addsound("alarm.wav",    SND_ALARM,     MIX_MAX_VOLUME, 0);
44       ttsounds::instance()->addsound("score.wav",    SND_SCORE,     MIX_MAX_VOLUME, 0);
45       ttsounds::instance()->addsound("rumble.wav",   SND_CRUMBLE,   MIX_MAX_VOLUME, 0);
46       ttsounds::instance()->addsound("fanfare.wav",  SND_FANFARE,   MIX_MAX_VOLUME, 0);
47       ttsounds::instance()->addsound("sonar.wav",    SND_SONAR,     MIX_MAX_VOLUME/6, 0);
48       ttsounds::instance()->addsound("torpedo.wav",  SND_TORPEDO,   MIX_MAX_VOLUME, 0);
49 
50       samplesloaded = true;
51     }
52   }
53 }
54 
snd_done(void)55 void snd_done(void) {
56   ttsounds::instance()->closesound();
57 }
58 
59 
snd_playTitle(void)60 void snd_playTitle(void) {
61   ttsounds::instance()->playmusic("toppler.ogg");
62 }
63 
64 
snd_stopTitle(void)65 void snd_stopTitle(void) {
66   ttsounds::instance()->stopmusic();
67 }
68 
snd_musicVolume(int vol)69 void snd_musicVolume(int vol) {
70   ttsounds::instance()->fadeToVol(vol);
71 }
72