X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsound.h;h=d38b1ff5ae202cbd5bcb2d0e97540b02456fdde5;hb=cf4a9fe888b3faa0fcfd45870af756a5955d9030;hp=825fdd7091e3b100d7eaeefe8872b6ab9ff1fb62;hpb=7fc94a99a287a0d7104d75eac2aeffcff4bf4703;p=supertux.git diff --git a/src/sound.h b/src/sound.h index 825fdd709..d38b1ff5a 100644 --- a/src/sound.h +++ b/src/sound.h @@ -1,63 +1,87 @@ -/* - sound.h - - Super Tux - Audio Functions - - by Bill Kendrick - bill@newbreedsoftware.com - http://www.newbreedsoftware.com/supertux/ - - April 22, 2000 - July 15, 2002 -*/ +// $Id$ +// +// SuperTux - A Jump'n Run +// Copyright (C) 2000 Bill Kendrick +// Copyright (C) 2004 Duong-Khang NGUYEN +// +// 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. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_SOUND_H #define SUPERTUX_SOUND_H - /*all the sounds we have*/ -#define NUM_SOUNDS 16 +#include "defines.h" /* get YES/NO defines */ -#ifndef NOSOUND +/*global variable*/ +extern bool use_sound; /* handle sound on/off menu and command-line option */ +extern bool use_music; /* handle music on/off menu and command-line */ +extern bool audio_device; /* != 0: available and initialized */ +/* enum of different internal music types */ +enum Music_Type { + NO_MUSIC, + LEVEL_MUSIC, + HURRYUP_MUSIC, + HERRING_MUSIC +}; + +/* panning effects: terrible :-) ! */ +enum Sound_Speaker { + SOUND_LEFT_SPEAKER = 0, + SOUND_RIGHT_SPEAKER = 1, + SOUND_RESERVED_CHANNELS = 2, // 2 channels reserved for left/right speaker + SOUND_CENTER_SPEAKER = -1 +}; + +/* Sound files: */ +enum { + SND_JUMP, + SND_BIGJUMP, + SND_SKID, + SND_DISTRO, + SND_HERRING, + SND_BRICK, + SND_HURT, + SND_SQUISH, + SND_FALL, + SND_RICOCHET, + SND_BUMP_UPGRADE, + SND_UPGRADE, + SND_EXCELLENT, + SND_COFFEE, + SND_SHOOT, + SND_LIFEUP, + SND_STOMP, + SND_KICK, + SND_EXPLODE, + NUM_SOUNDS +}; + +extern char* soundfilenames[NUM_SOUNDS]; + +#include #include -// variables for stocking the sound and music -Mix_Chunk* sounds[NUM_SOUNDS]; -Mix_Music* song; +/* variables for stocking the sound and music */ +extern Mix_Chunk* sounds[NUM_SOUNDS]; -// functions handling the sound and music -Mix_Chunk * load_sound(char * file); -void playsound(Mix_Chunk * snd); -Mix_Music * load_song(char * file); +/* functions handling the sound and music */ +int open_audio(int frequency, Uint16 format, int channels, int chunksize); +void close_audio( void ); -int playing_music(void); -int halt_music(void); -int play_music(Mix_Music*music, int loops); -void free_music(Mix_Music*music); +Mix_Chunk * load_sound(const std::string& file); void free_chunk(Mix_Chunk*chunk); - -#else - -//fake variables -void* sounds[NUM_SOUNDS]; -void* song; - -// fake sound handlers -void* load_sound(void* file); -void playsound(void * snd); -void* load_song(void* file); -int Mix_PlayingMusic(); -void Mix_HaltMusic(); -int Mix_PlayMusic(); -void Mix_FreeMusic(); -void Mix_FreeChunk(); -int Mix_OpenAudio(int a, int b, int c, int d); - -int playing_music(); -void halt_music(); -int play_music(int *music, int loops); -void free_music(int *music);; -void free_chunk(int *chunk); - -#endif +void play_sound(Mix_Chunk * snd, enum Sound_Speaker whichSpeaker); #endif /*SUPERTUX_SOUND_H*/