-
Notifications
You must be signed in to change notification settings - Fork 2
/
audio.h
132 lines (104 loc) · 3.14 KB
/
audio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* --------------------------------------------------------------------
EXTREME TUXRACER
Copyright (C) 2010 Extreme Tuxracer Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
---------------------------------------------------------------------*/
#ifndef AUDIO_H
#define AUDIO_H
#include "bh.h"
// --------------------------------------------------------------------
// class CAudio
// --------------------------------------------------------------------
class CAudio {
private:
public:
CAudio ();
~CAudio () {}
void Open ();
void Close ();
bool CheckOpen ();
bool IsOpen;
};
// --------------------------------------------------------------------
// class CSound
// --------------------------------------------------------------------
#define MAX_SOUNDS 32
typedef struct {
Mix_Chunk *chunk;
int channel;
double vol_fact;
int loop_count;
} TSound;
class CSound {
private:
TSound sounds[MAX_SOUNDS];
int numSounds;
string SoundIndex;
bool active_arr[MAX_SOUNDS];
public:
CSound ();
~CSound () {}
int LoadChunk (const char *name, const char *filename);
void LoadSoundList ();
int GetSoundIdx (string name);
void SetVolume (int soundid, int volume);
void SetVolume (string name, int volume);
void Play (int soundid, int loop);
void Play (string name, int loop); // -1 infinite, 0 once, 1 twice ...
void Play (int soundid, int loop, int volume);
void Play (string name, int loop, int volume);
void Halt (int soundid);
void Halt (string name);
void HaltAll ();
void FreeSounds ();
};
// --------------------------------------------------------------------
// class CMusic
// --------------------------------------------------------------------
#define MUS_RACING 0
#define MUS_WONRACE 1
#define MUS_LOSTRACE 2
#define MAX_MUSICS 32
#define MAX_THEMES 16
class CMusic {
private:
Mix_Music *musics[MAX_MUSICS];
int numMusics;
string MusicIndex;
int themes[MAX_THEMES][3];
int numThemes;
string ThemesIndex;
int loop_count; // we need only 1 variable for all pieces
int curr_musid; // ID of current music piece
int curr_volume;
public:
CMusic ();
~CMusic () {}
bool is_playing;
int LoadPiece (const char *name, const char *filename);
void LoadMusicList ();
int GetMusicIdx (string name);
int GetThemeIdx (string theme);
void SetVolume (int volume);
void Update ();
bool Play (int musid, int loop);
bool Play (string name, int loop);
bool Play (int musid, int loop, int volume);
bool Play (string name, int loop, int volume);
bool PlayTheme (int theme, int situation);
void Refresh (string name);
void Halt ();
void FreeMusics ();
};
// --------------------------------------------------------------------
extern CAudio Audio;
extern CMusic Music;
extern CSound Sound;
#endif