From 2a026e12779b77b2aeabb78bdca3ea00e10d478a Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 16 May 2007 14:28:22 +0000 Subject: Add FEATURE_SOUND. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 877 --- src/Makefile.am | 18 ++++-- src/deh_sound.c | 14 +++-- src/doomfeatures.h | 4 ++ src/i_sound.c | 41 ++---------- src/i_system.c | 8 +-- src/s_dummy.c | 180 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/s_sound.c | 21 ++++--- src/s_sound.h | 23 ++++++- 8 files changed, 247 insertions(+), 62 deletions(-) create mode 100644 src/s_dummy.c diff --git a/src/Makefile.am b/src/Makefile.am index 29cd71fe..60370280 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -49,8 +49,6 @@ hu_stuff.c hu_stuff.h \ i_main.c \ info.c info.h \ i_scale.c i_scale.h \ -i_pcsound.c i_pcsound.h \ -i_sound.c i_sound.h \ i_swap.h \ i_system.c i_system.h \ i_timer.c i_timer.h \ @@ -63,7 +61,6 @@ m_menu.c m_menu.h \ m_misc.c m_misc.h \ md5.c md5.h \ memio.c memio.h \ -mus2mid.c mus2mid.h \ m_random.c m_random.h \ p_ceilng.c \ p_doors.c \ @@ -97,7 +94,6 @@ r_sky.c r_sky.h \ r_state.h \ r_things.c r_things.h \ sounds.c sounds.h \ -s_sound.c s_sound.h \ st_lib.c st_lib.h \ st_stuff.c st_stuff.h \ tables.c tables.h \ @@ -145,10 +141,19 @@ net_structrw.c net_structrw.h FEATURE_WAD_MERGE_SOURCE_FILES = \ w_merge.c w_merge.h +# source files needed for FEATURE_SOUND + +FEATURE_SOUND_SOURCE_FILES = \ +i_pcsound.c i_pcsound.h \ +i_sound.c i_sound.h \ +mus2mid.c mus2mid.h \ +s_sound.c s_sound.h + SOURCE_FILES = $(MAIN_SOURCE_FILES) \ $(FEATURE_DEHACKED_SOURCE_FILES) \ $(FEATURE_MULTIPLAYER_SOURCE_FILES) \ - $(FEATURE_WAD_MERGE_SOURCE_FILES) + $(FEATURE_WAD_MERGE_SOURCE_FILES) \ + $(FEATURE_SOUND_SOURCE_FILES) if HAVE_WINDRES chocolate_doom_SOURCES=$(SOURCE_FILES) chocolate-doom-res.rc @@ -160,7 +165,8 @@ chocolate_doom_LDADD = ../textscreen/libtextscreen.a ../pcsound/libpcsound.a @LD EXTRA_DIST = \ chocolate_doom_icon.c \ - chocolate-doom-screensaver.desktop + chocolate-doom-screensaver.desktop \ + s_dummy.c .rc.o: $(WINDRES) $^ -o $@ diff --git a/src/deh_sound.c b/src/deh_sound.c index 9f99384b..7068d94a 100644 --- a/src/deh_sound.c +++ b/src/deh_sound.c @@ -27,6 +27,7 @@ #include #include "doomdef.h" +#include "doomfeatures.h" #include "doomtype.h" #include "deh_defs.h" #include "deh_main.h" @@ -48,7 +49,6 @@ DEH_END_MAPPING static void *DEH_SoundStart(deh_context_t *context, char *line) { int sound_number = 0; - sfxinfo_t *sfx; if (sscanf(line, "Sound %i", &sound_number) != 1) { @@ -67,10 +67,16 @@ static void *DEH_SoundStart(deh_context_t *context, char *line) DEH_Warning(context, "Attempt to modify SFX %i. This will problems " "in Vanilla dehacked.", sound_number); } + +#ifdef FEATURE_SOUND - sfx = &S_sfx[sound_number]; - - return sfx; + return &S_sfx[sound_number]; + +#else + + return NULL; + +#endif } static void DEH_SoundParseLine(deh_context_t *context, char *line, void *tag) diff --git a/src/doomfeatures.h b/src/doomfeatures.h index 14b773ee..46e26e52 100644 --- a/src/doomfeatures.h +++ b/src/doomfeatures.h @@ -39,6 +39,10 @@ #define FEATURE_MULTIPLAYER 1 +// Enables sound output + +#define FEATURE_SOUND 1 + #endif /* #ifndef DOOM_FEATURES_H */ diff --git a/src/i_sound.c b/src/i_sound.c index 67a92130..06fdd727 100644 --- a/src/i_sound.c +++ b/src/i_sound.c @@ -43,6 +43,7 @@ #include "i_sound.h" #include "i_swap.h" #include "deh_main.h" +#include "s_sound.h" #include "m_argv.h" #include "m_misc.h" #include "w_wad.h" @@ -53,23 +54,6 @@ #define MAXMIDLENGTH (96 * 1024) -enum -{ - SNDDEVICE_NONE = 0, - SNDDEVICE_PCSPEAKER = 1, - SNDDEVICE_ADLIB = 2, - SNDDEVICE_SB = 3, - SNDDEVICE_PAS = 4, - SNDDEVICE_GUS = 5, - SNDDEVICE_WAVEBLASTER = 6, - SNDDEVICE_SOUNDCANVAS = 7, - SNDDEVICE_GENMIDI = 8, - SNDDEVICE_AWE32 = 9, -}; - -extern int snd_sfxdevice; -extern int snd_musicdevice; - static boolean nosfxparm; static boolean nomusicparm; @@ -83,17 +67,6 @@ static int mixer_freq; static Uint16 mixer_format; static int mixer_channels; -// Disable music on OSX by default; there are problems with SDL_mixer. - -#ifndef __MACOSX__ -#define DEFAULT_MUSIC_DEVICE SNDDEVICE_SB -#else -#define DEFAULT_MUSIC_DEVICE SNDDEVICE_NONE -#endif - -int snd_musicdevice = DEFAULT_MUSIC_DEVICE; -int snd_sfxdevice = SNDDEVICE_SB; - // When a sound stops, check if it is still playing. If it is not, // we can mark the sound data as CACHE to be freed back for other // means. @@ -506,6 +479,9 @@ void I_ShutdownSound(void) Mix_CloseAudio(); SDL_QuitSubSystem(SDL_INIT_AUDIO); + + sound_initialised = false; + music_initialised = false; } @@ -625,15 +601,6 @@ I_InitSound() // MUSIC API. // -void I_InitMusic(void) -{ -} - -void I_ShutdownMusic(void) -{ - music_initialised = false; -} - static boolean musicpaused = false; static int currentMusicVolume; diff --git a/src/i_system.c b/src/i_system.c index 55c3b8fe..7a8c469c 100644 --- a/src/i_system.c +++ b/src/i_system.c @@ -34,11 +34,12 @@ #include "deh_main.h" #include "doomdef.h" +#include "doomstat.h" #include "m_argv.h" #include "m_misc.h" -#include "i_sound.h" #include "i_timer.h" #include "i_video.h" +#include "s_sound.h" #include "d_net.h" #include "g_game.h" @@ -113,8 +114,6 @@ byte *I_ZoneBase (int *size) void I_Init (void) { I_CheckIsScreensaver(); - I_InitSound(); - I_InitMusic(); I_InitTimer(); } @@ -169,8 +168,7 @@ void I_Quit (void) { D_QuitNetGame (); G_CheckDemoStatus(); - I_ShutdownSound(); - I_ShutdownMusic(); + S_Shutdown(); if (!screensaver_mode) { diff --git a/src/s_dummy.c b/src/s_dummy.c new file mode 100644 index 00000000..a3c9f797 --- /dev/null +++ b/src/s_dummy.c @@ -0,0 +1,180 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// 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. +// +// DESCRIPTION: Dummy sound interface for running with FEATURE_SOUND +// disabled. +// +//----------------------------------------------------------------------------- + +#include "doomtype.h" +#include "s_sound.h" +#include "p_mobj.h" +#include "sounds.h" + +int snd_musicdevice = SNDDEVICE_NONE; +int snd_sfxdevice = SNDDEVICE_NONE; + +// Maximum volume of a sound effect. +// Internal default is max out of 0-15. +int sfxVolume = 8; + +// Maximum volume of music. +int musicVolume = 8; + +// number of channels available + +int numChannels = 8; + +// +// Initializes sound stuff, including volume +// Sets channels, SFX and music volume, +// allocates channel buffer, sets S_sfx lookup. +// +void S_Init +( int sfxVolume, + int musicVolume ) +{ +} + +void S_Shutdown(void) +{ +} + +// +// Per level startup code. +// Kills playing sounds at start of level, +// determines music if any, changes music. +// +void S_Start(void) +{ +} + +void +S_StartSoundAtVolume +( void* origin_p, + int sfx_id, + int volume ) +{ +} + +void +S_StartSound +( void* origin, + int sfx_id ) +{ +} + +void S_StopSound(void *origin) +{ +} + +// +// Stop and resume music, during game PAUSE. +// +void S_PauseSound(void) +{ +} + +void S_ResumeSound(void) +{ +} + + +// +// Updates music & sounds +// +void S_UpdateSounds(void* listener_p) +{ +} + +void S_SetMusicVolume(int volume) +{ +} + +void S_SetSfxVolume(int volume) +{ +} + +// +// Starts some music with the music id found in sounds.h. +// +void S_StartMusic(int m_id) +{ +} + +void +S_ChangeMusic +( int musicnum, + int looping ) +{ +} + +boolean S_MusicPlaying(void) +{ + return false; +} + + +void S_StopMusic(void) +{ +} + +void S_StopChannel(int cnum) +{ +} + + + +// +// Changes volume, stereo-separation, and pitch variables +// from the norm of a sound effect to be played. +// If the sound is not audible, returns a 0. +// Otherwise, modifies parameters and returns 1. +// +int +S_AdjustSoundParams +( mobj_t* listener, + mobj_t* source, + int* vol, + int* sep, + int* pitch ) +{ + return 0; +} + + + + +// +// S_getChannel : +// If none available, return -1. Otherwise channel #. +// +int +S_getChannel +( void* origin, + sfxinfo_t* sfxinfo ) +{ + return -1; +} + + + + diff --git a/src/s_sound.c b/src/s_sound.c index 5e22f1e8..56cb18c9 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -82,15 +82,16 @@ const char snd_prefixen[] #define NA 0 #define S_NUMCHANNELS 2 +// Disable music on OSX by default; there are problems with SDL_mixer. -// Current music/sfx card - index useless -// w/o a reference LUT in a sound module. -extern int snd_MusicDevice; -extern int snd_SfxDevice; -// Config file? Same disclaimer as above. -extern int snd_DesiredMusicDevice; -extern int snd_DesiredSfxDevice; +#ifndef __MACOSX__ +#define DEFAULT_MUSIC_DEVICE SNDDEVICE_SB +#else +#define DEFAULT_MUSIC_DEVICE SNDDEVICE_NONE +#endif +int snd_musicdevice = DEFAULT_MUSIC_DEVICE; +int snd_sfxdevice = SNDDEVICE_SB; typedef struct @@ -169,6 +170,8 @@ void S_Init { int i; + I_InitSound(); + // Whatever these did with DMX, these are rather dummies now. I_SetChannels(); @@ -195,6 +198,10 @@ void S_Init } +void S_Shutdown(void) +{ + I_ShutdownSound(); +} // diff --git a/src/s_sound.h b/src/s_sound.h index ea718814..015a18fa 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -29,8 +29,22 @@ #define __S_SOUND__ - - +typedef enum +{ + SNDDEVICE_NONE = 0, + SNDDEVICE_PCSPEAKER = 1, + SNDDEVICE_ADLIB = 2, + SNDDEVICE_SB = 3, + SNDDEVICE_PAS = 4, + SNDDEVICE_GUS = 5, + SNDDEVICE_WAVEBLASTER = 6, + SNDDEVICE_SOUNDCANVAS = 7, + SNDDEVICE_GENMIDI = 8, + SNDDEVICE_AWE32 = 9, +} snddevice_t; + +extern int snd_sfxdevice; +extern int snd_musicdevice; // // Initializes sound stuff, including volume @@ -43,6 +57,10 @@ S_Init int musicVolume ); +// Shut down sound + +void S_Shutdown(void); + // @@ -52,7 +70,6 @@ S_Init // void S_Start(void); - // // Start sound for thing at // using from sounds.h -- cgit v1.2.3