source: abuse/branches/lol/src/sdlport/sound.h @ 730

Last change on this file since 730 was 722, checked in by Sam Hocevar, 9 years ago

audio: only activate the "song" class if SDL_mixer is present.

  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
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 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
25#endif
26
27/* options are passed via command line */
28
29#define SFX_INITIALIZED    1
30#define MUSIC_INITIALIZED  2
31
32int sound_init(int argc, char **argv);
33void sound_uninit();
34void print_sound_options(); // print the options avaible for sound
35
36class sound_effect
37{
38public:
39    sound_effect(char const *filename);
40    ~sound_effect();
41
42    void play(int volume = 127, int pitch = 128, int panpot = 128);
43
44private:
45#if defined USE_SDL_MIXER
46    Mix_Chunk* m_chunk;
47#endif
48};
49
50class song
51{
52public:
53    String const &name() { return m_name; }
54    song(String const &filename);
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
61private:
62    String m_name;
63#if defined USE_SDL_MIXER
64    uint8_t *data;
65    unsigned long song_id;
66    Mix_Music* music;
67    SDL_RWops* rw;
68#endif
69};
70
71#endif
72
Note: See TracBrowser for help on using the repository browser.