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