1 | /* |
---|
2 | * Abuse - dark 2D side-scrolling platform game |
---|
3 | * Copyright (c) 1995 Crack dot Com |
---|
4 | * Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net> |
---|
5 | * |
---|
6 | * This software was released into the Public Domain. As with most public |
---|
7 | * domain software, no warranty is made or implied by Crack dot Com, by |
---|
8 | * Jonathan Clark, or by Sam Hocevar. |
---|
9 | */ |
---|
10 | |
---|
11 | #ifndef __SOUND_H__ |
---|
12 | #define __SOUND_H__ |
---|
13 | |
---|
14 | #if defined HAVE_SDL_SDL_H |
---|
15 | # include <SDL/SDL.h> |
---|
16 | #else |
---|
17 | # include <SDL.h> |
---|
18 | #endif |
---|
19 | |
---|
20 | #if defined USE_SDL_MIXER |
---|
21 | # if defined HAVE_SDL_SDL_MIXER_H |
---|
22 | # include <SDL/SDL_mixer.h> |
---|
23 | # else |
---|
24 | # include <SDL_mixer.h> |
---|
25 | # endif |
---|
26 | #endif |
---|
27 | |
---|
28 | /* options are passed via command line */ |
---|
29 | |
---|
30 | #define SFX_INITIALIZED 1 |
---|
31 | #define MUSIC_INITIALIZED 2 |
---|
32 | |
---|
33 | int sound_init(int argc, char **argv); |
---|
34 | void sound_uninit(); |
---|
35 | void print_sound_options(); // print the options avaible for sound |
---|
36 | |
---|
37 | class sound_effect |
---|
38 | { |
---|
39 | public: |
---|
40 | sound_effect(char const *filename); |
---|
41 | ~sound_effect(); |
---|
42 | |
---|
43 | void play(int volume = 127, int pitch = 128, int panpot = 128); |
---|
44 | |
---|
45 | private: |
---|
46 | #if defined USE_SDL_MIXER |
---|
47 | Mix_Chunk* m_chunk; |
---|
48 | #endif |
---|
49 | }; |
---|
50 | |
---|
51 | class song |
---|
52 | { |
---|
53 | public: |
---|
54 | String const &name() { return m_name; } |
---|
55 | song(String const &filename); |
---|
56 | void play(unsigned char volume=127); |
---|
57 | void stop(long fadeout_time=0); // time in ms |
---|
58 | int playing(); |
---|
59 | void set_volume(int volume); |
---|
60 | ~song(); |
---|
61 | |
---|
62 | private: |
---|
63 | String m_name; |
---|
64 | #if defined USE_SDL_MIXER |
---|
65 | uint8_t *data; |
---|
66 | unsigned long song_id; |
---|
67 | Mix_Music* music; |
---|
68 | SDL_RWops* rw; |
---|
69 | #endif |
---|
70 | }; |
---|
71 | |
---|
72 | #endif |
---|
73 | |
---|