1
2 #include "tuxkart.h"
3
4 struct Sound
5 {
6 char *fname ;
7 slSample *s ;
8 } ;
9
10
11 static Sound sfx [] =
12 {
13 { "wavs/ugh.wav" , NULL },
14 { "wavs/boing.wav" , NULL },
15 { "wavs/bonk.wav" , NULL },
16 { "wavs/burp.wav" , NULL },
17 { "wavs/laser.wav" , NULL },
18 { "wavs/ow.wav" , NULL },
19 { "wavs/wee.wav" , NULL },
20 { "wavs/explosion.wav", NULL },
21 { "wavs/bzzt.wav" , NULL },
22 { "wavs/horn.wav" , NULL },
23 { "wavs/shoomf.wav" , NULL },
24 { NULL, NULL }
25 } ;
26
27 static int music_off = FALSE ;
28 static int sfx_off = FALSE ;
29
disable_music()30 void SoundSystem::disable_music ()
31 {
32 sched -> stopMusic () ;
33 sched -> update () ; /* Ugh! Nasty Kludge! */
34 sched -> update () ; /* Ugh! Nasty Kludge! */
35
36 music_off = TRUE ;
37 }
38
39
change_track(char * fname)40 void SoundSystem::change_track ( char *fname )
41 {
42 if ( fname == NULL )
43 fname = "" ;
44
45 if ( strcmp ( fname, current_track ) != 0 )
46 {
47 strcpy ( current_track, fname ) ;
48
49 if ( ! music_off )
50 enable_music () ;
51 }
52 }
53
enable_music()54 void SoundSystem::enable_music ()
55 {
56 sched -> stopMusic () ;
57
58 if ( current_track [ 0 ] != '\0' )
59 sched -> loopMusic ( current_track ) ;
60
61 music_off = FALSE ;
62 }
63
64
disable_sfx()65 void SoundSystem::disable_sfx () { sfx_off = TRUE ; }
enable_sfx()66 void SoundSystem:: enable_sfx () { sfx_off = FALSE ; }
67
68
69
playSfx(int sfx_num)70 void SoundSystem::playSfx ( int sfx_num )
71 {
72 if ( ! sfx_off )
73 sched -> playSample ( sfx[sfx_num].s, 1, SL_SAMPLE_MUTE, 2, NULL ) ;
74 }
75
76
SoundSystem()77 SoundSystem::SoundSystem ()
78 {
79 sched = new slScheduler ;
80
81 setSafetyMargin () ;
82
83 for ( Sound *currsfx = &(sfx[0]) ; currsfx -> fname != NULL ; currsfx++ )
84 currsfx -> s = new slSample ( currsfx -> fname, sched ) ;
85
86 enable_sfx () ;
87 change_track ( "" ) ;
88 enable_music () ;
89 }
90
91
update()92 void SoundSystem::update ()
93 {
94 /*
95 Comment this next line out if the
96 sound causes big glitches on your
97 IRIX machine!
98 */
99
100 sched -> update () ;
101 }
102
103
104