Merge branch 'music-cleanup' into musicplus-core

Pending rewrite of fade music changing

# Conflicts:
#	src/android/i_sound.c
#	src/djgppdos/i_sound.c
#	src/i_sound.h
#	src/s_sound.c
#	src/s_sound.h
#	src/sdl/mixer_sound.c
#	src/sdl/sdl_sound.c
#	src/win32/win_snd.c
This commit is contained in:
mazmazz 2018-08-23 21:07:39 -04:00
commit a2d626384a
26 changed files with 2939 additions and 2531 deletions

View File

@ -57,49 +57,6 @@ matrix:
- gcc-4.8
compiler: gcc-4.8
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- p7zip-full
- gcc-4.9
compiler: gcc-4.9
#gcc-4.9 (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- p7zip-full
- gcc-5
compiler: gcc-5
#gcc-5 (Ubuntu 5.3.0-3ubuntu1~14.04) 5.3.0 20151204
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- p7zip-full
- gcc-6
compiler: gcc-6
env: WFLAGS="-Wno-tautological-compare"
#gcc-6 (Ubuntu 6.1.1-3ubuntu11~14.04.1) 6.1.1 20160511
- os: linux
addons:
apt:

View File

@ -8,7 +8,7 @@
UINT8 cdaudio_started = 0;
consvar_t cd_volume = {"cd_volume","31",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cd_volume = {"cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};

View File

@ -55,23 +55,24 @@ void I_SetSfxVolume(INT32 volume)
(void)volume;
}
//
// MUSIC I/O
//
/// ------------------------
// MUSIC SYSTEM
/// ------------------------
UINT8 music_started = 0;
UINT8 digmusic_started = 0;
void I_InitMusic(void){}
void I_ShutdownMusic(void){}
void I_PauseSong(INT32 handle)
{
(void)handle;
}
/// ------------------------
// MUSIC PROPERTIES
/// ------------------------
void I_ResumeSong(INT32 handle)
musictype_t I_SongType(void)
{
(void)handle;
return MU_NONE;
}
boolean I_SongPlaying(void)
@ -84,73 +85,9 @@ boolean I_SongPaused(void)
return false;
}
musictype_t I_GetSongType(void)
{
return MU_NONE;
}
//
// MIDI I/O
//
UINT8 midimusic_started = 0;
void I_InitMIDIMusic(void){}
void I_ShutdownMIDIMusic(void){}
void I_SetMIDIMusicVolume(INT32 volume)
{
(void)volume;
}
INT32 I_RegisterSong(void *data, size_t len)
{
(void)data;
(void)len;
return -1;
}
boolean I_PlaySong(INT32 handle, INT32 looping)
{
(void)handle;
(void)looping;
return false;
}
void I_StopSong(INT32 handle)
{
(void)handle;
}
void I_UnRegisterSong(INT32 handle)
{
(void)handle;
}
//
// DIGMUSIC I/O
//
UINT8 digmusic_started = 0;
void I_InitDigMusic(void){}
void I_ShutdownDigMusic(void){}
boolean I_StartDigSong(const char *musicname, INT32 looping)
{
(void)musicname;
(void)looping;
return false;
}
void I_StopDigSong(void){}
void I_SetDigMusicVolume(INT32 volume)
{
(void)volume;
}
/// ------------------------
// MUSIC EFFECTS
/// ------------------------
boolean I_SetSongSpeed(float speed)
{
@ -158,6 +95,10 @@ boolean I_SetSongSpeed(float speed)
return false;
}
/// ------------------------
// MUSIC SEEKING
/// ------------------------
UINT32 I_GetSongLength(void)
{
return 0;
@ -185,6 +126,55 @@ UINT32 I_GetSongPosition(void)
return 0;
}
/// ------------------------
// MUSIC PLAYBACK
/// ------------------------
UINT8 midimusic_started = 0;
boolean I_LoadSong(char *data, size_t len)
{
(void)data;
(void)len;
return -1;
}
void I_UnloadSong()
{
}
boolean I_PlaySong(boolean looping)
{
(void)handle;
(void)looping;
return false;
}
void I_StopSong(void)
{
(void)handle;
}
void I_PauseSong(void)
{
(void)handle;
}
void I_ResumeSong(void)
{
(void)handle;
}
void I_SetMusicVolume(INT32 volume)
{
(void)volume;
}
/// ------------------------
// MUSIC FADING
/// ------------------------
void I_SetInternalMusicVolume(UINT8 volume)
{
(void)volume;

View File

@ -112,13 +112,10 @@ INT32 postimgparam;
postimg_t postimgtype2 = postimg_none;
INT32 postimgparam2;
boolean nomidimusic = false, nosound = false;
boolean nodigimusic = false; // No fmod-based music
// These variables are only true if
// the respective sound system is initialized
// and active, but no sounds/music should play.
boolean music_disabled = false;
// These variables are in effect
// whether the respective sound system is disabled
// or they're init'ed, but the player just toggled them
boolean midi_disabled = false;
boolean sound_disabled = false;
boolean digital_disabled = false;
@ -1192,27 +1189,27 @@ void D_SRB2Main(void)
// setting up sound
if (dedicated)
{
nosound = true;
nomidimusic = nodigimusic = true;
sound_disabled = true;
midi_disabled = digital_disabled = true;
}
else
{
CONS_Printf("S_Init(): Setting up sound.\n");
CONS_Printf("S_InitSfxChannels(): Setting up sound channels.\n");
}
if (M_CheckParm("-nosound"))
nosound = true;
sound_disabled = true;
if (M_CheckParm("-nomusic")) // combines -nomidimusic and -nodigmusic
nomidimusic = nodigimusic = true;
midi_disabled = digital_disabled = true;
else
{
if (M_CheckParm("-nomidimusic"))
nomidimusic = true; ; // WARNING: DOS version initmusic in I_StartupSound
midi_disabled = true; ; // WARNING: DOS version initmusic in I_StartupSound
if (M_CheckParm("-nodigmusic"))
nodigimusic = true; // WARNING: DOS version initmusic in I_StartupSound
digital_disabled = true; // WARNING: DOS version initmusic in I_StartupSound
}
I_StartupSound();
I_InitMusic();
S_Init(cv_soundvolume.value, cv_digmusicvolume.value, cv_midimusicvolume.value);
S_InitSfxChannels(cv_soundvolume.value);
CONS_Printf("ST_Init(): Init status bar.\n");
ST_Init();

View File

@ -4063,11 +4063,9 @@ static void Command_RestartAudio_f(void)
// These must be called or no sound and music until manually set.
I_SetSfxVolume(cv_soundvolume.value);
I_SetDigMusicVolume(cv_digmusicvolume.value);
I_SetMIDIMusicVolume(cv_midimusicvolume.value);
S_SetMusicVolume(cv_digmusicvolume.value, cv_midimusicvolume.value);
if (Playing()) // Gotta make sure the player is in a level
P_RestoreMusic(&players[consoleplayer]);
}
/** Quits a game and returns to the title screen.

View File

@ -50,7 +50,7 @@ static boolean wasPlaying;
static int cdVolume=0; // current cd volume (0-31)
// 0-31 like Music & Sfx, though CD hardware volume is 0-255.
consvar_t cd_volume = {"cd_volume","31",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cd_volume = {"cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
// allow Update for next/loop track
// some crap cd drivers take up to

View File

@ -134,21 +134,12 @@ FUNCINLINE static ATTRINLINE int Volset(int vol)
void I_SetSfxVolume(INT32 volume)
{
if (nosound)
if (sound_disabled)
return;
set_volume (Volset(volume),-1);
}
void I_SetMIDIMusicVolume(INT32 volume)
{
if (nomidimusic)
return;
// Now set volume on output device.
set_volume (-1, Volset(volume));
}
//
// Starting a sound means adding it
// to the current list of active sounds
@ -169,7 +160,7 @@ INT32 I_StartSound ( sfxenum_t id,
{
int voice;
if (nosound)
if (sound_disabled)
return 0;
// UNUSED
@ -190,7 +181,7 @@ void I_StopSound (INT32 handle)
// an setting the channel to zero.
int voice=handle & (VIRTUAL_VOICES-1);
if (nosound)
if (sound_disabled)
return;
if (voice_check(voice)==S_sfx[handle>>VOICESSHIFT].data)
@ -199,7 +190,7 @@ void I_StopSound (INT32 handle)
INT32 I_SoundIsPlaying(INT32 handle)
{
if (nosound)
if (sound_disabled)
return FALSE;
if (voice_check(handle & (VIRTUAL_VOICES-1))==S_sfx[handle>>VOICESSHIFT].data)
@ -229,7 +220,7 @@ void I_UpdateSoundParams( INT32 handle,
int voice=handle & (VIRTUAL_VOICES-1);
int numsfx=handle>>VOICESSHIFT;
if (nosound)
if (sound_disabled)
return;
if (voice_check(voice)==S_sfx[numsfx].data)
@ -270,17 +261,17 @@ void I_StartupSound(void)
char err[255];
#endif
if (nosound)
if (sound_disabled)
sfxcard=DIGI_NONE;
else
sfxcard=DIGI_AUTODETECT;
if (nomidimusic)
if (midi_disabled)
midicard=MIDI_NONE;
else
midicard=MIDI_AUTODETECT; //DetectMusicCard();
nodigimusic=true; //Alam: No OGG/MP3/IT/MOD support
digital_disabled=true; //Alam: No OGG/MP3/IT/MOD support
// Secure and configure sound device first.
CONS_Printf("I_StartupSound: ");
@ -293,8 +284,8 @@ void I_StartupSound(void)
{
sprintf (err,"Sound init error : %s\n",allegro_error);
CONS_Error (err);
nosound=true;
nomidimusic=true;
sound_disabled=true;
midi_disabled=true;
}
else
{
@ -321,7 +312,11 @@ static MIDI* currsong; //im assuming only 1 song will be played at once
static int islooping=0;
static int musicdies=-1;
UINT8 music_started=0;
boolean songpaused=false;
/// ------------------------
// MUSIC SYSTEM
/// ------------------------
/* load_midi_mem:
* Loads a standard MIDI file from memory, returning a pointer to
@ -389,161 +384,51 @@ static MIDI *load_midi_mem(char *mempointer,int *e)
return midi;
}
void I_InitMIDIMusic(void)
void I_InitMusic(void)
{
if (nomidimusic)
if (midi_disabled)
return;
I_AddExitFunc(I_ShutdownMusic);
music_started = true;
}
void I_ShutdownMIDIMusic(void)
{
if ( !music_started )
return;
I_StopSong(1);
music_started=false;
}
void I_InitDigMusic(void)
{
// CONS_Printf("Digital music not yet supported under DOS.\n");
}
void I_ShutdownDigMusic(void)
{
// CONS_Printf("Digital music not yet supported under DOS.\n");
}
void I_InitMusic(void)
{
if (!nodigimusic)
I_InitDigMusic();
if (!nomidimusic)
I_InitMIDIMusic();
songpaused = false;
}
void I_ShutdownMusic(void)
{
I_ShutdownMIDIMusic();
I_ShutdownDigMusic();
}
boolean I_PlaySong(INT32 handle, INT32 looping)
{
handle = 0;
if (nomidimusic)
return false;
islooping = looping;
musicdies = gametic + NEWTICRATE*30;
if (play_midi(currsong,looping)==0)
return true;
return false;
}
void I_PauseSong (INT32 handle)
{
handle = 0;
if (nomidimusic)
if ( !music_started )
return;
midi_pause();
I_StopSong();
music_started=false;
}
void I_ResumeSong (INT32 handle)
/// ------------------------
// MUSIC PROPERTIES
/// ------------------------
musictype_t I_SongType(void)
{
handle = 0;
if (nomidimusic)
return;
midi_resume();
}
void I_StopSong(INT32 handle)
{
handle = 0;
if (nomidimusic)
return;
islooping = 0;
musicdies = 0;
stop_midi();
}
// Is the song playing?
#if 0
int I_QrySongPlaying(int handle)
{
if (nomidimusic)
return 0;
//return islooping || musicdies > gametic;
return (midi_pos==-1);
}
#endif
void I_UnRegisterSong(INT32 handle)
{
handle = 0;
if (nomidimusic)
return;
//destroy_midi(currsong);
}
INT32 I_RegisterSong(void *data, size_t len)
{
int e = len; //Alam: For error
if (nomidimusic)
return 0;
if (memcmp(data,"MThd",4)==0) // support mid file in WAD !!!
{
currsong=load_midi_mem(data,&e);
}
if (currsong)
return MU_MID;
else
{
CONS_Printf("Music Lump is not a MIDI lump\n");
return 0;
}
if (currsong==NULL)
{
CONS_Printf("Not a valid mid file : %d\n",e);
return 0;
}
return 1;
return MU_NONE;
}
/// \todo Add OGG/MP3 support for dos
boolean I_StartDigSong(const char *musicname, INT32 looping)
boolean I_SongPlaying()
{
musicname = NULL;
looping = 0;
//CONS_Printf("I_StartDigSong: Not yet supported under DOS.\n");
return false;
return (boolean)currsong;
}
void I_StopDigSong(void)
boolean I_SongPaused()
{
// CONS_Printf("I_StopDigSong: Not yet supported under DOS.\n");
return songpaused;
}
void I_SetDigMusicVolume(INT32 volume)
{
volume = 0;
if (nodigimusic)
return;
// Now set volume on output device.
// CONS_Printf("Digital music not yet supported under DOS.\n");
}
/// ------------------------
// MUSIC EFFECTS
/// ------------------------
boolean I_SetSongSpeed(float speed)
{
@ -551,6 +436,10 @@ boolean I_SetSongSpeed(float speed)
return false;
}
/// ------------------------
// MUSIC SEEKING
/// ------------------------
UINT32 I_GetSongLength(void)
{
return 0;
@ -578,21 +467,118 @@ UINT32 I_GetSongPosition(void)
return 0;
}
boolean I_SongPlaying(void)
/// ------------------------
// MUSIC PLAYBACK
/// ------------------------
boolean I_LoadSong(char *data, size_t len)
{
return (boolean)currsong && music_started;
int e = len; //Alam: For error
if (midi_disabled)
return 0;
if (memcmp(data,"MThd",4)==0) // support mid file in WAD !!!
{
currsong=load_midi_mem(data,&e);
}
else
{
CONS_Printf("Music Lump is not a MIDI lump\n");
return 0;
}
if (currsong==NULL)
{
CONS_Printf("Not a valid mid file : %d\n",e);
return 0;
}
return 1;
}
boolean I_SongPaused(void)
void I_UnloadSong(void)
{
handle = 0;
if (midi_disabled)
return;
//destroy_midi(currsong);
}
boolean I_PlaySong(boolean looping)
{
handle = 0;
if (midi_disabled)
return false;
islooping = looping;
musicdies = gametic + NEWTICRATE*30;
if (play_midi(currsong,looping)==0)
return true;
return false;
}
musictype_t I_GetSongType(void)
void I_StopSong(void)
{
return MU_NONE;
handle = 0;
if (midi_disabled)
return;
islooping = 0;
musicdies = 0;
stop_midi();
songpaused = false;
}
void I_PauseSong (INT32 handle)
{
handle = 0;
if (midi_disabled)
return;
midi_pause();
songpaused = true;
}
void I_ResumeSong (INT32 handle)
{
handle = 0;
if (midi_disabled)
return;
midi_resume();
songpaused = false;
}
void I_SetMusicVolume(INT32 volume)
{
if (midi_disabled)
return;
// Now set volume on output device.
set_volume (-1, Volset(volume));
}
boolean I_SetSongTrack(INT32 track)
{
(void)track;
return false;
}
// Is the song playing?
#if 0
int I_QrySongPlaying(int handle)
{
if (midi_disabled)
return 0;
//return islooping || musicdies > gametic;
return (midi_pos==-1);
}
#endif
/// ------------------------
// MUSIC FADING
/// ------------------------
void I_SetInternalMusicVolume(UINT8 volume)
{
(void)volume;

View File

@ -90,10 +90,7 @@ extern boolean fromlevelselect;
// Internal parameters for sound rendering.
// ========================================
extern boolean nomidimusic; // defined in d_main.c
extern boolean nosound;
extern boolean nodigimusic;
extern boolean music_disabled;
extern boolean midi_disabled;
extern boolean sound_disabled;
extern boolean digital_disabled;

View File

@ -57,89 +57,86 @@ void I_SetSfxVolume(UINT8 volume)
(void)volume;
}
//
// MUSIC I/O
//
/// ------------------------
// MUSIC SYSTEM
/// ------------------------
void I_InitMusic(void){}
void I_ShutdownMusic(void){}
void I_PauseSong(INT32 handle)
/// ------------------------
// MUSIC PROPERTIES
/// ------------------------
musictype_t I_SongType(void)
{
(void)handle;
return MU_NONE;
}
void I_ResumeSong(INT32 handle)
boolean I_SongPlaying(void)
{
(void)handle;
return false;
}
//
// MIDI I/O
//
void I_InitMIDIMusic(void){}
void I_ShutdownMIDIMusic(void){}
void I_SetMIDIMusicVolume(UINT8 volume)
boolean I_SongPaused(void)
{
(void)volume;
return false;
}
INT32 I_RegisterSong(void *data, size_t len)
/// ------------------------
// MUSIC EFFECTS
/// ------------------------
boolean I_SetSongSpeed(float speed)
{
(void)speed;
return false;
}
/// ------------------------
// MUSIC PLAYBACK
/// ------------------------
boolean I_LoadSong(char *data, size_t len)
{
(void)data;
(void)len;
return -1;
}
boolean I_PlaySong(INT32 handle, boolean looping)
void I_UnloadSong(void)
{
(void)handle;
}
boolean I_PlaySong(boolean looping)
{
(void)handle;
(void)looping;
return false;
}
void I_StopSong(INT32 handle)
void I_StopSong(void)
{
(void)handle;
}
void I_UnRegisterSong(INT32 handle)
void I_PauseSong(void)
{
(void)handle;
}
//
// DIGMUSIC I/O
//
void I_InitDigMusic(void){}
void I_ShutdownDigMusic(void){}
boolean I_StartDigSong(const char *musicname, boolean looping)
void I_ResumeSong(void)
{
(void)musicname;
(void)looping;
return false;
(void)handle;
}
void I_StopDigSong(void){}
void I_SetDigMusicVolume(UINT8 volume)
void I_SetMusicVolume(UINT8 volume)
{
(void)volume;
}
boolean I_SetSongSpeed(float speed)
{
(void)speed;
return false;
}
boolean I_SetSongTrack(int track)
{
(void)track;
@ -221,7 +218,7 @@ boolean I_SongPaused(void)
return false;
}
musictype_t I_GetSongType(void)
musictype_t I_SongType(void)
{
return MU_NONE;
}

View File

@ -361,7 +361,7 @@ INT32 HW3S_I_StartSound(const void *origin_p, source3D_data_t *source_parm, chan
if (splitscreen) listenmobj2 = players[secondarydisplayplayer].mo;
if (nosound)
if (sound_disabled)
return -1;
sfx = &S_sfx[sfx_id];

View File

@ -20,16 +20,16 @@
// copied from SDL mixer, plus GME
typedef enum {
MU_NONE,
MU_CMD,
MU_WAV,
MU_MOD,
MU_MID,
MU_OGG,
MU_MP3,
MU_MP3_MAD_UNUSED, // use MU_MP3 instead
MU_FLAC,
MU_MODPLUG_UNUSED, // use MU_MOD instead
MU_NONE,
MU_CMD,
MU_WAV,
MU_MOD,
MU_MID,
MU_OGG,
MU_MP3,
MU_MP3_MAD_UNUSED, // use MU_MP3 instead
MU_FLAC,
MU_MODPLUG_UNUSED, // use MU_MOD instead
MU_GME
} musictype_t;
@ -66,9 +66,9 @@ void I_StartupSound(void);
*/
void I_ShutdownSound(void);
//
// SFX I/O
//
/// ------------------------
/// SFX I/O
/// ------------------------
/** \brief Starts a sound in a particular sound channel.
\param id sfxid
@ -120,9 +120,10 @@ void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch);
*/
void I_SetSfxVolume(UINT8 volume);
//
// MUSIC I/O
//
/// ------------------------
// MUSIC SYSTEM
/// ------------------------
/** \brief Init the music systems
*/
void I_InitMusic(void);
@ -131,55 +132,35 @@ void I_InitMusic(void);
*/
void I_ShutdownMusic(void);
/** \brief PAUSE game handling.
/// ------------------------
// MUSIC PROPERTIES
/// ------------------------
\param handle song handle
\return void
*/
void I_PauseSong(INT32 handle);
/** \brief RESUME game handling
\param handle song handle
\return void
*/
void I_ResumeSong(INT32 handle);
/** \brief Get general music status
\return boolean
*/
musictype_t I_SongType(void);
boolean I_SongPlaying(void);
/** \brief Get music pause status
\return boolean
*/
boolean I_SongPaused(void);
musictype_t I_GetSongType(void);
/// ------------------------
// MUSIC EFFECTS
/// ------------------------
//
// MIDI I/O
//
boolean I_SetSongSpeed(float speed);
/** \brief Startup the MIDI music system
*/
void I_InitMIDIMusic(void);
/// ------------------------
// MUSIC SEEKING
/// ------------------------
/** \brief Shutdown the MIDI music system
*/
void I_ShutdownMIDIMusic(void);
UINT32 I_GetSongLength(void);
/** \brief The I_SetMIDIMusicVolume function
boolean I_SetSongLoopPoint(UINT32 looppoint);
UINT32 I_GetSongLoopPoint(void);
\param volume volume to set at
boolean I_SetSongPosition(UINT32 position);
UINT32 I_GetSongPosition(void);
\return void
*/
void I_SetMIDIMusicVolume(UINT8 volume);
/// ------------------------
// MUSIC PLAYBACK
/// ------------------------
/** \brief Registers a song handle to song data.
@ -190,7 +171,16 @@ void I_SetMIDIMusicVolume(UINT8 volume);
\todo Remove this
*/
INT32 I_RegisterSong(void *data, size_t len);
boolean I_LoadSong(char *data, size_t len);
/** \brief See ::I_LoadSong, then think backwards
\param handle song handle
\sa I_LoadSong
\todo remove midi handle
*/
void I_UnloadSong(void);
/** \brief Called by anything that wishes to start music
@ -201,7 +191,7 @@ INT32 I_RegisterSong(void *data, size_t len);
\todo pass music name, not handle
*/
boolean I_PlaySong(INT32 handle, boolean looping);
boolean I_PlaySong(boolean looping);
/** \brief Stops a song over 3 seconds
@ -210,43 +200,38 @@ boolean I_PlaySong(INT32 handle, boolean looping);
/todo drop handle
*/
void I_StopSong(INT32 handle);
void I_StopSong(void);
/** \brief See ::I_RegisterSong, then think backwards
/** \brief PAUSE game handling.
\param handle song handle
\sa I_RegisterSong
\todo remove midi handle
\return void
*/
void I_UnRegisterSong(INT32 handle);
void I_PauseSong(void);
//
// DIGMUSIC I/O
//
/** \brief RESUME game handling
/** \brief Startup the music system
\param handle song handle
\return void
*/
void I_InitDigMusic(void);
void I_ResumeSong(void);
/** \brief Shutdown the music system
/** \brief The I_SetMusicVolume function
\param volume volume to set at
\return void
*/
void I_ShutdownDigMusic(void);
boolean I_SetSongSpeed(float speed);
UINT32 I_GetSongLength(void);
boolean I_SetSongLoopPoint(UINT32 looppoint);
UINT32 I_GetSongLoopPoint(void);
boolean I_SetSongPosition(UINT32 position);
UINT32 I_GetSongPosition(void);
void I_SetMusicVolume(UINT8 volume);
boolean I_SetSongTrack(INT32 track);
/// ------------------------
/// MUSIC FADING
/// ------------------------
void I_SetInternalMusicVolume(UINT8 volume);
void I_StopFadingSong(void);
@ -260,31 +245,9 @@ boolean I_FadeOutStopSong(UINT32 ms);
boolean I_FadeInStartDigSong(const char *musicname, UINT16 track, boolean looping, UINT32 position, UINT32 fadeinms, boolean queuepostfade);
#define I_QueueDigSong(a,b,c,d,e) I_FadeInStartDigSong(a,b,c,d,e,1)
/** \brief The I_StartDigSong function
\param musicname music lump name
\param looping if true, loop the song
\return if true, song playing
*/
boolean I_StartDigSong(const char *musicname, boolean looping);
/** \brief stop non-MIDI song
*/
void I_StopDigSong(void);
/** \brief The I_SetDigMusicVolume function
\param volume volume to set at
\return void
*/
void I_SetDigMusicVolume(UINT8 volume);
//
// CD MUSIC I/O
//
/// ------------------------
// CD MUSIC I/O
/// ------------------------
/** \brief cd music interface
*/

View File

@ -3825,7 +3825,7 @@ msgid "Music lump is not MID music format\n"
msgstr ""
#: win32/win_snd.c:2128
msgid "I_RegisterSong: StreamBufferSetup FAILED"
msgid "I_LoadSong: StreamBufferSetup FAILED"
msgstr ""
#: win32/win_sys.c:892

View File

@ -4021,7 +4021,7 @@ msgid "Music lump is not MID music format\n"
msgstr ""
#: win32/win_snd.c:2126
msgid "I_RegisterSong: StreamBufferSetup FAILED"
msgid "I_LoadSong: StreamBufferSetup FAILED"
msgstr ""
#: win32/win_sys.c:894

View File

@ -421,6 +421,7 @@ static int sector_get(lua_State *L)
{
sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR));
enum sector_e field = luaL_checkoption(L, 2, sector_opt[0], sector_opt);
INT16 i;
if (!sector)
{
@ -443,11 +444,23 @@ static int sector_get(lua_State *L)
lua_pushfixed(L, sector->ceilingheight);
return 1;
case sector_floorpic: // floorpic
lua_pushlstring(L, levelflats[sector->floorpic].name, 8);
{
levelflat_t *levelflat = &levelflats[sector->floorpic];
for (i = 0; i < 8; i++)
if (!levelflat->name[i])
break;
lua_pushlstring(L, levelflat->name, i);
return 1;
}
case sector_ceilingpic: // ceilingpic
lua_pushlstring(L, levelflats[sector->ceilingpic].name, 8);
{
levelflat_t *levelflat = &levelflats[sector->ceilingpic];
for (i = 0; i < 8; i++)
if (!levelflat->name[i])
break;
lua_pushlstring(L, levelflat->name, i);
return 1;
}
case sector_lightlevel:
lua_pushinteger(L, sector->lightlevel);
return 1;

View File

@ -9350,7 +9350,7 @@ static void M_SoundMenu(INT32 choice)
{
(void)choice;
OP_SoundOptionsMenu[6].status = ((nosound || sound_disabled) ? IT_GRAYEDOUT : (IT_STRING | IT_CVAR));
OP_SoundOptionsMenu[6].status = (sound_disabled ? IT_GRAYEDOUT : (IT_STRING | IT_CVAR));
M_SetupNextMenu(&OP_SoundOptionsDef);
}
@ -9363,25 +9363,25 @@ void M_DrawSoundMenu(void)
V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x,
currentMenu->y+currentMenu->menuitems[0].alphaKey,
(nosound ? V_REDMAP : V_YELLOWMAP),
((nosound || sound_disabled) ? offstring : onstring));
(sound_disabled ? V_REDMAP : V_YELLOWMAP),
(sound_disabled ? offstring : onstring));
V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x,
currentMenu->y+currentMenu->menuitems[2].alphaKey,
(nodigimusic ? V_REDMAP : V_YELLOWMAP),
((nodigimusic || digital_disabled) ? offstring : onstring));
(digital_disabled ? V_REDMAP : V_YELLOWMAP),
(digital_disabled ? offstring : onstring));
V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x,
currentMenu->y+currentMenu->menuitems[4].alphaKey,
(nomidimusic ? V_REDMAP : V_YELLOWMAP),
((nomidimusic || music_disabled) ? offstring : onstring));
(midi_disabled ? V_REDMAP : V_YELLOWMAP),
(midi_disabled ? offstring : onstring));
if (itemOn == 0)
lengthstring = ((nosound || sound_disabled) ? 3 : 2);
lengthstring = (sound_disabled ? 3 : 2);
else if (itemOn == 2)
lengthstring = ((nodigimusic || digital_disabled) ? 3 : 2);
lengthstring = (digital_disabled ? 3 : 2);
else if (itemOn == 4)
lengthstring = ((nomidimusic || music_disabled) ? 3 : 2);
lengthstring = (midi_disabled ? 3 : 2);
else
return;
@ -9416,12 +9416,12 @@ static void M_ToggleSFX(INT32 choice)
break;
}
if (nosound)
if (sound_disabled)
{
nosound = false;
sound_disabled = false;
I_StartupSound();
if (nosound) return;
S_Init(cv_soundvolume.value, cv_digmusicvolume.value, cv_midimusicvolume.value);
if (sound_disabled) return;
S_InitSfxChannels(cv_soundvolume.value);
S_StartSound(NULL, sfx_strpst);
OP_SoundOptionsMenu[6].status = IT_STRING | IT_CVAR;
//M_StartMessage(M_GetText("SFX Enabled\n"), NULL, MM_NOTHING);
@ -9469,12 +9469,11 @@ static void M_ToggleDigital(INT32 choice)
break;
}
if (nodigimusic)
if (digital_disabled)
{
nodigimusic = false;
I_InitDigMusic();
if (nodigimusic) return;
S_Init(cv_soundvolume.value, cv_digmusicvolume.value, cv_midimusicvolume.value);
digital_disabled = false;
I_InitMusic();
if (digital_disabled) return;
S_StopMusic();
if (Playing())
P_RestoreMusic(&players[consoleplayer]);
@ -9484,21 +9483,27 @@ static void M_ToggleDigital(INT32 choice)
}
else
{
if (digital_disabled)
digital_disabled = true;
if (S_MusicType() != MU_MID)
{
digital_disabled = false;
if (Playing())
P_RestoreMusic(&players[consoleplayer]);
if (midi_disabled)
S_StopMusic();
else
S_ChangeMusicInternal("_clear", false);
//M_StartMessage(M_GetText("Digital Music Enabled\n"), NULL, MM_NOTHING);
}
else
{
digital_disabled = true;
S_StopMusic();
//M_StartMessage(M_GetText("Digital Music Disabled\n"), NULL, MM_NOTHING);
{
char mmusic[7];
UINT16 mflags;
boolean looping;
if (S_MusicInfo(mmusic, &mflags, &looping) && S_MIDIExists(mmusic))
{
S_StopMusic();
S_ChangeMusic(mmusic, mflags, looping);
}
else
S_StopMusic();
}
}
//M_StartMessage(M_GetText("Digital Music Disabled\n"), NULL, MM_NOTHING);
}
}
@ -9516,6 +9521,12 @@ static void M_ToggleMIDI(INT32 choice)
itemOn--;
return;
case KEY_LEFTARROW:
case KEY_RIGHTARROW:
if (S_MusicType() != MU_MID && S_MusicType() != MU_NONE)
S_StartSound(NULL, sfx_menu1);
break;
case KEY_ESCAPE:
if (currentMenu->prevMenu)
M_SetupNextMenu(currentMenu->prevMenu);
@ -9526,12 +9537,11 @@ static void M_ToggleMIDI(INT32 choice)
break;
}
if (nomidimusic)
if (midi_disabled)
{
nomidimusic = false;
I_InitMIDIMusic();
if (nomidimusic) return;
S_Init(cv_soundvolume.value, cv_digmusicvolume.value, cv_midimusicvolume.value);
midi_disabled = false;
I_InitMusic();
if (midi_disabled) return;
if (Playing())
P_RestoreMusic(&players[consoleplayer]);
else
@ -9540,21 +9550,27 @@ static void M_ToggleMIDI(INT32 choice)
}
else
{
if (music_disabled)
midi_disabled = true;
if (S_MusicType() == MU_MID)
{
music_disabled = false;
if (Playing())
P_RestoreMusic(&players[consoleplayer]);
if (digital_disabled)
S_StopMusic();
else
S_ChangeMusicInternal("_clear", false);
//M_StartMessage(M_GetText("MIDI Music Enabled\n"), NULL, MM_NOTHING);
}
else
{
music_disabled = true;
S_StopMusic();
//M_StartMessage(M_GetText("MIDI Music Disabled\n"), NULL, MM_NOTHING);
{
char mmusic[7];
UINT16 mflags;
boolean looping;
if (S_MusicInfo(mmusic, &mflags, &looping) && S_DigExists(mmusic))
{
S_StopMusic();
S_ChangeMusic(mmusic, mflags, looping);
}
else
S_StopMusic();
}
}
//M_StartMessage(M_GetText("MIDI Music Disabled\n"), NULL, MM_NOTHING);
}
}

View File

@ -9172,7 +9172,7 @@ void P_PrecipitationEffects(void)
if (!playeringame[displayplayer] || !players[displayplayer].mo)
return;
if (nosound || sound_disabled)
if (sound_disabled)
return; // Sound off? D'aw, no fun.
if (players[displayplayer].mo->subsector->sector->ceilingpic == skyflatnum)

View File

@ -79,7 +79,7 @@ consvar_t stereoreverse = {"stereoreverse", "Off", CV_SAVE, CV_OnOff, NULL, 0, N
static consvar_t precachesound = {"precachesound", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
// actual general (maximum) sound & music volume, saved into the config
consvar_t cv_soundvolume = {"soundvolume", "31", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_soundvolume = {"soundvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_digmusicvolume = {"digmusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_midimusicvolume = {"midimusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@ -234,7 +234,7 @@ void S_RegisterSoundStuff(void)
{
if (dedicated)
{
nosound = true;
sound_disabled = true;
return;
}
@ -498,7 +498,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
mobj_t *listenmobj = players[displayplayer].mo;
mobj_t *listenmobj2 = NULL;
if (sound_disabled || !sound_started || nosound)
if (sound_disabled || !sound_started)
return;
// Don't want a sound? Okay then...
@ -828,7 +828,7 @@ void S_UpdateSounds(void)
goto notinlevel;
}
if (dedicated || nosound)
if (dedicated || sound_disabled)
return;
if (players[displayplayer].awayviewtics)
@ -1287,6 +1287,43 @@ void S_StartSoundName(void *mo, const char *soundname)
S_StartSound(mo, soundnum);
}
//
// Initializes sound stuff, including volume
// Sets channels, SFX volume,
// allocates channel buffer, sets S_sfx lookup.
//
void S_InitSfxChannels(INT32 sfxVolume)
{
INT32 i;
if (dedicated)
return;
S_SetSfxVolume(sfxVolume);
SetChannelsNum();
// Note that sounds have not been cached (yet).
for (i = 1; i < NUMSFX; i++)
{
S_sfx[i].usefulness = -1; // for I_GetSfx()
S_sfx[i].lumpnum = LUMPERROR;
}
// precache sounds if requested by cmdline, or precachesound var true
if (!sound_disabled && (M_CheckParm("-precachesound") || precachesound.value))
{
// Initialize external data (all sounds) at start, keep static.
CONS_Printf(M_GetText("Loading sounds... "));
for (i = 1; i < NUMSFX; i++)
if (S_sfx[i].name)
S_sfx[i].data = I_GetSfx(&S_sfx[i]);
CONS_Printf(M_GetText(" pre-cached all sound data\n"));
}
}
/// ------------------------
/// Music
/// ------------------------
@ -1313,75 +1350,174 @@ const char *compat_special_music_slots[16] =
};
#endif
#define music_playing (music_name[0]) // String is empty if no music is playing
static char music_name[7]; // up to 6-character name
static lumpnum_t music_lumpnum; // lump number of music (used??)
static void *music_data; // music raw data
static INT32 music_handle; // once registered, the handle for the music
static UINT16 music_flags;
static boolean music_looping;
static boolean mus_paused = 0; // whether songs are mus_paused
/// ------------------------
/// Music Status
/// ------------------------
static boolean S_MIDIMusic(const char *mname, boolean looping)
boolean S_DigMusicDisabled(void)
{
return digital_disabled;
}
boolean S_MIDIMusicDisabled(void)
{
return midi_disabled;
}
boolean S_MusicDisabled(void)
{
return (midi_disabled && digital_disabled);
}
boolean S_MusicPlaying(void)
{
return I_SongPlaying();
}
boolean S_MusicPaused(void)
{
return I_SongPaused();
}
musictype_t S_MusicType(void)
{
return I_SongType();
}
boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping)
{
if (!I_SongPlaying())
return false;
strncpy(mname, music_name, 7);
mname[6] = 0;
*mflags = music_flags;
*looping = music_looping;
return (boolean)mname[0];
}
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi)
{
return (
(checkDigi ? W_CheckNumForName(va("O_%s", mname)) != LUMPERROR : false)
|| (checkMIDI ? W_CheckNumForName(va("D_%s", mname)) != LUMPERROR : false)
);
}
/// ------------------------
/// Music Effects
/// ------------------------
boolean S_SpeedMusic(float speed)
{
return I_SetSongSpeed(speed);
}
/// ------------------------
/// Music Seeking
/// ------------------------
UINT32 S_GetMusicLength(void)
{
return I_GetSongLength();
}
boolean S_SetMusicLoopPoint(UINT32 looppoint)
{
return I_SetSongLoopPoint(looppoint);
}
UINT32 S_GetMusicLoopPoint(void)
{
return I_GetSongLoopPoint();
}
boolean S_SetMusicPosition(UINT32 position)
{
return I_SetSongPosition(position);
}
UINT32 S_GetMusicPosition(void)
{
return I_GetSongPosition();
}
/// ------------------------
/// Music Playback
/// ------------------------
static boolean S_LoadMusic(const char *mname)
{
lumpnum_t mlumpnum;
void *mdata;
INT32 mhandle;
if (nomidimusic || music_disabled)
return false; // didn't search.
if (W_CheckNumForName(va("d_%s", mname)) == LUMPERROR)
if (S_MusicDisabled())
return false;
mlumpnum = W_GetNumForName(va("d_%s", mname));
if (!S_DigMusicDisabled() && S_DigExists(mname))
mlumpnum = W_GetNumForName(va("o_%s", mname));
else if (!S_MIDIMusicDisabled() && S_MIDIExists(mname))
mlumpnum = W_GetNumForName(va("d_%s", mname));
else if (S_DigMusicDisabled() && S_DigExists(mname))
{
CONS_Alert(CONS_NOTICE, "Digital music is disabled!\n");
return false;
}
else if (S_MIDIMusicDisabled() && S_MIDIExists(mname))
{
CONS_Alert(CONS_NOTICE, "MIDI music is disabled!\n");
return false;
}
else
{
CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), mname);
return false;
}
// load & register it
mdata = W_CacheLumpNum(mlumpnum, PU_MUSIC);
mhandle = I_RegisterSong(mdata, W_LumpLength(mlumpnum));
#ifdef MUSSERV
if (msg_id != -1)
if (I_LoadSong(mdata, W_LumpLength(mlumpnum)))
{
struct musmsg msg_buffer;
msg_buffer.msg_type = 6;
memset(msg_buffer.msg_text, 0, sizeof (msg_buffer.msg_text));
sprintf(msg_buffer.msg_text, "d_%s", mname);
msgsnd(msg_id, (struct msgbuf*)&msg_buffer, sizeof (msg_buffer.msg_text), IPC_NOWAIT);
strncpy(music_name, mname, 7);
music_name[6] = 0;
return true;
}
#endif
// play it
if (!I_PlaySong(mhandle, looping))
else
return false;
strncpy(music_name, mname, 7);
music_name[6] = 0;
music_lumpnum = mlumpnum;
music_data = mdata;
music_handle = mhandle;
return true;
}
static boolean S_DigMusic(const char *mname, boolean looping)
static void S_UnloadMusic(void)
{
if (nodigimusic || digital_disabled)
return false; // try midi
I_UnloadSong();
music_name[0] = 0;
music_flags = 0;
music_looping = false;
}
if (!I_StartDigSong(mname, looping))
static boolean S_PlayMusic(boolean looping)
{
if (S_MusicDisabled())
return false;
strncpy(music_name, mname, 7);
music_name[6] = 0;
music_lumpnum = LUMPERROR;
music_data = NULL;
music_handle = 0;
if (!I_PlaySong(looping))
{
S_UnloadMusic();
return false;
}
S_InitMusicVolume(); // switch between digi and sequence volume
return true;
}
void S_ChangeMusicAdvanced(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms)
{
if ((nomidimusic || music_disabled) && (nodigimusic || digital_disabled))
if (S_MusicDisabled())
return;
char newmusic[7];
@ -1405,9 +1541,9 @@ void S_ChangeMusicAdvanced(const char *mmusic, UINT16 mflags, boolean looping, U
CONS_Debug(DBG_DETAILED, "Now playing song %s\n", newmusic);
if (digiexists && !nodigimusic && !digital_disabled) // digmusic?
if (digiexists && !digital_disabled) // digmusic?
{
if (prefadems && I_GetSongType() != MU_MID) //have to queue post-fade // allow even if the music is the same
if (prefadems && I_SongType() != MU_MID) //have to queue post-fade // allow even if the music is the same
{
I_FadeOutStopSong(prefadems);
I_QueueDigSong(newmusic, mflags & MUSIC_TRACKMASK, looping, position, fadeinms);
@ -1449,17 +1585,23 @@ void S_ChangeMusicAdvanced(const char *mmusic, UINT16 mflags, boolean looping, U
I_SetSongTrack(mflags & MUSIC_TRACKMASK);
}
}
else if (strncmp(music_name, newmusic, 6) && midiexists && !nomidimusic && !music_disabled) // midimusic?
else if (strncmp(music_name, newmusic, 6) && midiexists && !midi_disabled) // midimusic?
{
// HACK: We don't support fade for MIDI right now, so
// just fall to old behavior verbatim. This technically should be implemented in
// the interfaces, even as a stub.
S_StopMusic();
S_StopMusic(); // shutdown old music
if (!S_MIDIMusic(newmusic, looping))
if (!S_LoadMusic(mmusic))
return;
music_flags = mflags;
music_looping = looping;
if (!S_PlayMusic(looping))
{
CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), newmusic);
CONS_Alert(CONS_ERROR, "Music cannot be played!\n");
return;
}
}
@ -1469,59 +1611,25 @@ void S_ChangeMusicAdvanced(const char *mmusic, UINT16 mflags, boolean looping, U
musictype_t S_MusicType()
{
return I_GetSongType();
}
boolean S_SpeedMusic(float speed)
{
return I_SetSongSpeed(speed);
}
UINT32 S_GetMusicLength(void)
{
return I_GetSongLength();
}
boolean S_SetMusicLoopPoint(UINT32 looppoint)
{
return I_SetSongLoopPoint(looppoint);
}
UINT32 S_GetMusicLoopPoint(void)
{
return I_GetSongLoopPoint();
}
boolean S_SetMusicPosition(UINT32 position)
{
return I_SetSongPosition(position);
}
UINT32 S_GetMusicPosition(void)
{
return I_GetSongPosition();
return I_SongType();
}
void S_StopMusic(void)
{
if (!music_playing)
if (!I_SongPlaying())
return;
if (mus_paused)
I_ResumeSong(music_handle);
if (!nodigimusic)
I_StopDigSong();
if (I_SongPaused())
I_ResumeSong();
S_SpeedMusic(1.0f);
I_StopSong(music_handle);
I_UnRegisterSong(music_handle);
I_StopSong();
I_UnloadSong();
#ifndef HAVE_SDL //SDL uses RWOPS
Z_ChangeTag(music_data, PU_CACHE);
#endif
music_data = NULL;
music_name[0] = 0;
if (cv_closedcaptioning.value)
@ -1531,6 +1639,67 @@ void S_StopMusic(void)
}
}
//
// Stop and resume music, during game PAUSE.
//
void S_PauseAudio(void)
{
if (I_SongPlaying() && !I_SongPaused())
I_PauseSong();
// pause cd music
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
I_PauseCD();
#else
I_StopCD();
#endif
}
void S_ResumeAudio(void)
{
if (I_SongPlaying() && I_SongPaused())
I_ResumeSong();
// resume cd music
I_ResumeCD();
}
void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume)
{
if (digvolume < 0)
digvolume = cv_digmusicvolume.value;
if (seqvolume < 0)
seqvolume = cv_midimusicvolume.value;
if (digvolume < 0 || digvolume > 31)
CONS_Alert(CONS_WARNING, "digmusicvolume should be between 0-31\n");
CV_SetValue(&cv_digmusicvolume, digvolume&31);
actualdigmusicvolume = cv_digmusicvolume.value; //check for change of var
if (seqvolume < 0 || seqvolume > 31)
CONS_Alert(CONS_WARNING, "midimusicvolume should be between 0-31\n");
CV_SetValue(&cv_midimusicvolume, seqvolume&31);
actualmidimusicvolume = cv_midimusicvolume.value; //check for change of var
#ifdef DJGPPDOS
digvolume = seqvolume = 31;
#endif
switch(I_SongType())
{
case MU_MID:
case MU_MOD:
case MU_GME:
I_SetMusicVolume(seqvolume&31);
default:
I_SetMusicVolume(digvolume&31);
}
}
/// ------------------------
/// Music Fading
/// ------------------------
void S_SetInternalMusicVolume(INT32 volume)
{
I_SetInternalMusicVolume(min(max(volume, 0), 100));
@ -1554,81 +1723,10 @@ boolean S_FadeOutStopMusic(UINT32 ms)
return I_FadeOutStopSong(ms);
}
void S_SetDigMusicVolume(INT32 volume)
{
if (volume < 0 || volume > 31)
CONS_Alert(CONS_WARNING, "musicvolume should be between 0-31\n");
CV_SetValue(&cv_digmusicvolume, volume&31);
actualdigmusicvolume = cv_digmusicvolume.value; //check for change of var
#ifdef DJGPPDOS
I_SetDigMusicVolume(31); // Trick for buggy dos drivers. Win32 doesn't need this.
#endif
I_SetDigMusicVolume(volume&31);
}
void S_SetMIDIMusicVolume(INT32 volume)
{
if (volume < 0 || volume > 31)
CONS_Alert(CONS_WARNING, "musicvolume should be between 0-31\n");
CV_SetValue(&cv_midimusicvolume, volume&0x1f);
actualmidimusicvolume = cv_midimusicvolume.value; //check for change of var
#ifdef DJGPPDOS
I_SetMIDIMusicVolume(31); // Trick for buggy dos drivers. Win32 doesn't need this.
#endif
I_SetMIDIMusicVolume(volume&0x1f);
}
/// ------------------------
/// Init & Others
/// ------------------------
//
// Initializes sound stuff, including volume
// Sets channels, SFX and music volume,
// allocates channel buffer, sets S_sfx lookup.
//
void S_Init(INT32 sfxVolume, INT32 digMusicVolume, INT32 midiMusicVolume)
{
INT32 i;
if (dedicated)
return;
S_SetSfxVolume(sfxVolume);
S_SetDigMusicVolume(digMusicVolume);
S_SetMIDIMusicVolume(midiMusicVolume);
SetChannelsNum();
// no sounds are playing, and they are not mus_paused
mus_paused = 0;
// Note that sounds have not been cached (yet).
for (i = 1; i < NUMSFX; i++)
{
S_sfx[i].usefulness = -1; // for I_GetSfx()
S_sfx[i].lumpnum = LUMPERROR;
}
// precache sounds if requested by cmdline, or precachesound var true
if (!nosound && (M_CheckParm("-precachesound") || precachesound.value))
{
// Initialize external data (all sounds) at start, keep static.
CONS_Printf(M_GetText("Loading sounds... "));
for (i = 1; i < NUMSFX; i++)
if (S_sfx[i].name)
S_sfx[i].data = I_GetSfx(&S_sfx[i]);
CONS_Printf(M_GetText(" pre-cached all sound data\n"));
}
}
//
// Per level startup code.
// Kills playing sounds at start of level,
@ -1643,69 +1741,7 @@ void S_Start(void)
mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK);
}
mus_paused = 0;
if (cv_resetmusic.value)
S_StopMusic();
S_ChangeMusic(mapmusname, mapmusflags, true);
}
//
// Stop and resume music, during game PAUSE.
//
void S_PauseAudio(void)
{
if (!nodigimusic)
I_PauseSong(0);
if (music_playing && !mus_paused)
{
I_PauseSong(music_handle);
mus_paused = true;
}
// pause cd music
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
I_PauseCD();
#else
I_StopCD();
#endif
}
void S_ResumeAudio(void)
{
if (!nodigimusic)
I_ResumeSong(0);
else
if (music_playing && mus_paused)
{
I_ResumeSong(music_handle);
mus_paused = false;
}
// resume cd music
I_ResumeCD();
}
boolean S_MusicPlaying(void)
{
return I_SongPlaying();
}
boolean S_MusicPaused(void)
{
return I_SongPaused();
}
const char *S_GetMusicName(void)
{
return S_MusicPlaying() ? music_name : "\0";
}
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi)
{
return (
(checkDigi ? W_CheckNumForName(va("O_%s", mname)) != LUMPERROR : false)
|| (checkMIDI ? W_CheckNumForName(va("D_%s", mname)) != LUMPERROR : false)
);
}

View File

@ -14,7 +14,7 @@
#ifndef __S_SOUND__
#define __S_SOUND__
#include "i_sound.h"
#include "i_sound.h" // musictype_t
#include "sounds.h"
#include "m_fixed.h"
#include "command.h"
@ -98,9 +98,9 @@ void S_RegisterSoundStuff(void);
//
// Initializes sound stuff, including volume
// Sets channels, SFX and music volume, allocates channel buffer, sets S_sfx lookup.
// Sets channels, SFX, allocates channel buffer, sets S_sfx lookup.
//
void S_Init(INT32 sfxVolume, INT32 digMusicVolume, INT32 midiMusicVolume);
void S_InitSfxChannels(INT32 sfxVolume);
//
// Per level startup code.
@ -126,20 +126,32 @@ void S_StartSoundAtVolume(const void *origin, sfxenum_t sound_id, INT32 volume);
// Stop sound for thing at <origin>
void S_StopSound(void *origin);
// Start music track, arbitrary, given its name, and set whether looping
// note: music flags 12 bits for tracknum (gme, other formats with more than one track)
// 13-15 aren't used yet
// and the last bit we ignore (internal game flag for resetting music on reload)
void S_ChangeMusicAdvanced(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms);
#define S_ChangeMusicInternal(a,b) S_ChangeMusicAdvanced(a,0,b,0,0,0)
#define S_ChangeMusic(a,b,c) S_ChangeMusicAdvanced(a,b,c,0,0,0)
//
// Music Status
//
// Get music type
musictype_t S_MusicType();
boolean S_DigMusicDisabled(void);
boolean S_MIDIMusicDisabled(void);
boolean S_MusicDisabled(void);
boolean S_MusicPlaying(void);
boolean S_MusicPaused(void);
musictype_t S_MusicType(void);
boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping);
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi);
#define S_DigExists(a) S_MusicExists(a, false, true)
#define S_MIDIExists(a) S_MusicExists(a, true, false)
//
// Music Effects
//
// Set Speed of Music
boolean S_SpeedMusic(float speed);
//
// Music Seeking
//
// Get Length of Music
UINT32 S_GetMusicLength(void);
@ -155,6 +167,18 @@ boolean S_SetMusicPosition(UINT32 position);
// Get Position of Music
UINT32 S_GetMusicPosition(void);
//
// Music Playback
//
// Start music track, arbitrary, given its name, and set whether looping
// note: music flags 12 bits for tracknum (gme, other formats with more than one track)
// 13-15 aren't used yet
// and the last bit we ignore (internal game flag for resetting music on reload)
void S_ChangeMusicAdvanced(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms);
#define S_ChangeMusicInternal(a,b) S_ChangeMusicAdvanced(a,0,b,0,0,0)
#define S_ChangeMusic(a,b,c) S_ChangeMusicAdvanced(a,b,c,0,0,0)
// Stops the music.
void S_StopMusic(void);
@ -162,20 +186,11 @@ void S_StopMusic(void);
void S_PauseAudio(void);
void S_ResumeAudio(void);
// Gets general music status
boolean S_MusicPlaying(void);
// Gets music pause status
boolean S_MusicPaused(void);
// Gets currently playing music name
const char *S_GetMusicName(void);
// Checks if music name exists
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi);
#define S_DigExists(a) S_MusicExists(a, false, true)
#define S_MIDIExists(a) S_MusicExists(a, true, false)
//
// Music Fading
//
void S_SetInternalMusicVolume(INT32 volume);
void S_StopFadingMusic(void);
boolean S_FadeMusicFromVolume(UINT8 target_volume, INT16 source_volume, UINT32 ms);
#define S_FadeMusic(a, b) S_FadeMusicFromVolume(a, -1, b)
@ -189,10 +204,11 @@ void S_UpdateSounds(void);
FUNCMATH fixed_t S_CalculateSoundDistance(fixed_t px1, fixed_t py1, fixed_t pz1, fixed_t px2, fixed_t py2, fixed_t pz2);
void S_SetInternalMusicVolume(INT32 volume);
void S_SetDigMusicVolume(INT32 volume);
void S_SetMIDIMusicVolume(INT32 volume);
void S_SetSfxVolume(INT32 volume);
void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume);
#define S_SetDigMusicVolume(a) S_SetMusicVolume(a,-1)
#define S_SetMIDIMusicVolume(a) S_SetMusicVolume(-1,a)
#define S_InitMusicVolume() S_SetMusicVolume(-1,-1)
INT32 S_OriginPlaying(void *origin);
INT32 S_IdPlaying(sfxenum_t id);

File diff suppressed because it is too large Load Diff

View File

@ -1,425 +1,213 @@
/* XPM */
static char * C:\Repo\srb2\src\sdl\SDL_icon_xpm[] = {
"32 32 390 2",
" c None",
". c #4F4F70",
"+ c #4D4D87",
"@ c #4D4D84",
"# c #4E4E6C",
"$ c #6C6C95",
"% c #5E5EB2",
"& c #6B6BE7",
"* c #7373F9",
"= c #7C7CFF",
"- c #6F70E7",
"; c #494BB2",
"> c #4F4FA3",
", c #6464D4",
"' c #7979F5",
") c #5F5FCA",
"! c #5D5D93",
"~ c #3A3A9F",
"{ c #6060AC",
"] c #777793",
"^ c #5C5CB3",
"/ c #7373EA",
"( c #7A7AFF",
"_ c #7575FF",
": c #7979FF",
"< c #6264DD",
"[ c #47478C",
"} c #564567",
"| c #4647D0",
"1 c #5C5CAE",
"2 c #5E5EFF",
"3 c #2929FF",
"4 c #1D1DFF",
"5 c #1919D1",
"6 c #4F4F90",
"7 c #1E1ECE",
"8 c #5858FF",
"9 c #6767A8",
"0 c #4949A0",
"a c #7070FB",
"b c #7D7DFF",
"c c #7777FF",
"d c #7373FF",
"e c #7272FF",
"f c #7878FF",
"g c #6465D8",
"h c #363886",
"i c #9F7655",
"j c #C89B5C",
"k c #1D1CB7",
"l c #3031B1",
"m c #1919F4",
"n c #1111FF",
"o c #1818FF",
"p c #1B1BFF",
"q c #1C1CFF",
"r c #2626B3",
"s c #1E1EC8",
"t c #1A1AE8",
"u c #24249F",
"v c #2F2FD2",
"w c #7676FF",
"x c #6869E2",
"y c #414290",
"z c #8C6751",
"A c #FCBA68",
"B c #E9BD7D",
"C c #201EB8",
"D c #090AB8",
"E c #1616EB",
"F c #1818FD",
"G c #1414EE",
"H c #1010E1",
"I c #0E0EE2",
"J c #0E0EF4",
"K c #0606B2",
"L c #7A7A89",
"M c #0C0C9A",
"N c #0A0AA7",
"O c #2424E4",
"P c #6669E6",
"Q c #4F4A8F",
"R c #BF853B",
"S c #FFD98D",
"T c #CDAB76",
"U c #1717C4",
"V c #0F10BA",
"W c #0909B6",
"X c #0505C3",
"Y c #0000B6",
"Z c #0000BE",
"` c #0000AD",
" . c #1D1D83",
".. c #63638E",
"+. c #090975",
"@. c #1414F3",
"#. c #5B5BFF",
"$. c #7B7BFF",
"%. c #7070FF",
"&. c #6E6EFF",
"*. c #7172F6",
"=. c #625DAF",
"-. c #BA9E6C",
";. c #887167",
">. c #090DF2",
",. c #1313BE",
"'. c #000085",
"). c #0000AC",
"!. c #0202AA",
"~. c #242488",
"{. c #1414C7",
"]. c #1717FF",
"^. c #5959FF",
"/. c #7F7FFF",
"(. c #7474FF",
"_. c #7171FF",
":. c #8686FF",
"<. c #7574FF",
"[. c #797CFF",
"}. c #5756B8",
"|. c #1C19A4",
"1. c #1617FF",
"2. c #1212BD",
"3. c #040485",
"4. c #0707A4",
"5. c #1B1B71",
"6. c #373797",
"7. c #1616FF",
"8. c #5050FF",
"9. c #8080FF",
"0. c #AAAAFF",
"a. c #AEAEF6",
"b. c #8A8AEF",
"c. c #6969FB",
"d. c #2728FF",
"e. c #1314FF",
"f. c #1919FF",
"g. c #1313E8",
"h. c #1F1FF4",
"i. c #5454FF",
"j. c #6D6DF0",
"k. c #6868B5",
"l. c #0B0BB8",
"m. c #1212C5",
"n. c #1616FC",
"o. c #1515FF",
"p. c #1212FF",
"q. c #2323FF",
"r. c #3636FF",
"s. c #4040FF",
"t. c #4343F9",
"u. c #5D5DB8",
"v. c #7F7F92",
"w. c #878793",
"x. c #4B4B94",
"y. c #0B0CE2",
"z. c #1313FF",
"A. c #4C4CFF",
"B. c #8282FF",
"C. c #7171ED",
"D. c #636394",
"E. c #575785",
"F. c #A9A99C",
"G. c #1414BC",
"H. c #1414FF",
"I. c #0707FD",
"J. c #2525AA",
"K. c #A8A8A4",
"L. c #EBEBE2",
"M. c #F9F9F2",
"N. c #E1E1CC",
"O. c #4D4D9F",
"P. c #0B0BF7",
"Q. c #2121FF",
"R. c #3232FF",
"S. c #5555FF",
"T. c #6161B4",
"U. c #B5B5B2",
"V. c #FFFFF8",
"W. c #4F4F9A",
"X. c #0B0BF5",
"Y. c #1616C5",
"Z. c #A8A8A1",
"`. c #FFFFFC",
" + c #FFFFFF",
".+ c #C0C0C4",
"++ c #1212D4",
"@+ c #4444FF",
"#+ c #6464FF",
"$+ c #8383FF",
"%+ c #6767C3",
"&+ c #E4E4E4",
"*+ c #9494AE",
"=+ c #0808DF",
"-+ c #0D0DF2",
";+ c #61619A",
">+ c #F1F1E0",
",+ c #E8E8DD",
"'+ c #2424BB",
")+ c #1010FF",
"!+ c #3434FF",
"~+ c #6161FF",
"{+ c #6969D2",
"]+ c #EFEFF0",
"^+ c #C2C2BA",
"/+ c #1010B6",
"(+ c #0909AC",
"_+ c #A4A49A",
":+ c #EAEADE",
"<+ c #2525B8",
"[+ c #2F2FFF",
"}+ c #3C3CB5",
"|+ c #EEEEEE",
"1+ c #BBBBAD",
"2+ c #0B0B56",
"3+ c #0B0BFC",
"4+ c #1212EF",
"5+ c #0C0C3E",
"6+ c #919187",
"7+ c #DEDED6",
"8+ c #1F1FC0",
"9+ c #1A1AFF",
"0+ c #1717FA",
"a+ c #1515F8",
"b+ c #1111FC",
"c+ c #494992",
"d+ c #999998",
"e+ c #3E3E3B",
"f+ c #3C3C99",
"g+ c #535397",
"h+ c #5A5A4D",
"i+ c #6F6F70",
"j+ c #BFBFC9",
"k+ c #1111D6",
"l+ c #1515F1",
"m+ c #0F0FE2",
"n+ c #0D0DD9",
"o+ c #0909CD",
"p+ c #0808C7",
"q+ c #0505C7",
"r+ c #0303CB",
"s+ c #0101C0",
"t+ c #0202AF",
"u+ c #0606AC",
"v+ c #121283",
"w+ c #BBBBBB",
"x+ c #BEBEBE",
"y+ c #2F2F2E",
"z+ c #C7C8BB",
"A+ c #D8DAD1",
"B+ c #272828",
"C+ c #929292",
"D+ c #8688C7",
"E+ c #0506F6",
"F+ c #1616F5",
"G+ c #0B0BD3",
"H+ c #0202B6",
"I+ c #0000AF",
"J+ c #0000B4",
"K+ c #0000BD",
"L+ c #0000BB",
"M+ c #00009E",
"N+ c #2C2C7E",
"O+ c #6A6A8B",
"P+ c #959595",
"Q+ c #F0F0F1",
"R+ c #E1E1E1",
"S+ c #8C8E90",
"T+ c #BEBEBF",
"U+ c #C9C7C5",
"V+ c #939699",
"W+ c #E7EAED",
"X+ c #CBCBC7",
"Y+ c #413B9B",
"Z+ c #0607DD",
"`+ c #0C0CE2",
" @ c #0303B9",
".@ c #0000A8",
"+@ c #181888",
"@@ c #6A6A6A",
"#@ c #626263",
"$@ c #4B4B4C",
"%@ c #3E3B36",
"&@ c #9B805C",
"*@ c #D9B07D",
"=@ c #C9AE89",
"-@ c #B9AF9E",
";@ c #C7C5C4",
">@ c #CBCCCF",
",@ c #C7C6C6",
"'@ c #AEA59A",
")@ c #B69974",
"!@ c #D8B87F",
"~@ c #9B8272",
"{@ c #0E0B9B",
"]@ c #0000B7",
"^@ c #0000B8",
"/@ c #000082",
"(@ c #00007A",
"_@ c #636379",
":@ c #62533E",
"<@ c #B59B6C",
"[@ c #DEB07B",
"}@ c #FECC90",
"|@ c #FFCE92",
"1@ c #FEC98C",
"2@ c #F1BD82",
"3@ c #D1A979",
"4@ c #BC9E73",
"5@ c #CCA777",
"6@ c #EAB980",
"7@ c #FFCD90",
"8@ c #FFD595",
"9@ c #FDD782",
"0@ c #413678",
"a@ c #0000AE",
"b@ c #000077",
"c@ c #010193",
"d@ c #0C0CE4",
"e@ c #38389E",
"f@ c #EEC585",
"g@ c #FFDA9D",
"h@ c #FFC992",
"i@ c #FFC88F",
"j@ c #FFC990",
"k@ c #FFCE93",
"l@ c #FFD094",
"m@ c #FFCC92",
"n@ c #C9A174",
"o@ c #EDBD88",
"p@ c #FAD287",
"q@ c #3A2F7F",
"r@ c #0000BA",
"s@ c #0000B0",
"t@ c #0101B2",
"u@ c #1111ED",
"v@ c #1919C1",
"w@ c #95887C",
"x@ c #DCAC6E",
"y@ c #FFD393",
"z@ c #FFCD94",
"A@ c #FFCA93",
"B@ c #FFC991",
"C@ c #FFC78E",
"D@ c #FFCB91",
"E@ c #E0B581",
"F@ c #BB9A6F",
"G@ c #FFDC97",
"H@ c #C1A173",
"I@ c #0E0B9A",
"J@ c #0000B5",
"K@ c #0101B6",
"L@ c #1010E0",
"M@ c #1616EC",
"N@ c #A68156",
"O@ c #E7AC6B",
"P@ c #FFC582",
"Q@ c #FFCF8F",
"R@ c #FFD195",
"S@ c #FFD296",
"T@ c #FFD396",
"U@ c #FFD193",
"V@ c #FFD28F",
"W@ c #D2A96B",
"X@ c #2F2482",
"Y@ c #0000C1",
"Z@ c #0000C0",
"`@ c #0000BF",
" # c #0101BF",
".# c #1212F0",
"+# c #767698",
"@# c #9C866E",
"## c #A9865D",
"$# c #C0915D",
"%# c #C89760",
"&# c #C29360",
"*# c #AD8A61",
"=# c #9D8971",
"-# c #7F7A7A",
";# c #70708F",
"># c #6F6F91",
",# c #575788",
"'# c #464687",
")# c #2F2F87",
"!# c #15158F",
"~# c #0101A8",
"{# c #1313FB",
"]# c #57579F",
"^# c #343487",
"/# c #434388",
static const char *SDL_icon_xpm[] = {
/* columns rows colors chars-per-pixel */
"32 32 175 2 ",
" c None",
". c #2E2E2E",
"X c #3C3C3C",
"o c #493939",
"O c #4E473F",
"+ c #161658",
"@ c #131369",
"# c #06067B",
"$ c #111173",
"% c #16167F",
"& c #252567",
"* c #372B7C",
"= c #3D3679",
"- c #41414A",
"; c #575655",
": c #6A5841",
"> c #5B4B72",
", c #616160",
"< c #7B7B7B",
"1 c #906E49",
"2 c #89685D",
"3 c #A67B4A",
"4 c #AA7F50",
"5 c #9B7560",
"6 c #856C78",
"7 c #997B7D",
"8 c #B48552",
"9 c #BA8A55",
"0 c #A48665",
"q c #B98F67",
"w c #B9946A",
"e c #B7937A",
"r c #C8955C",
"t c #CA9966",
"y c #DAA469",
"u c #C9A37B",
"i c #D7AB7B",
"p c #DFB07D",
"a c #EBAE6A",
"s c #E5B27A",
"d c #F1B779",
"f c #0A0A83",
"g c #05058B",
"h c #060687",
"j c #101089",
"k c #131382",
"l c #040494",
"z c #02029D",
"x c #0C0B9C",
"c c #120F9E",
"v c #19199B",
"b c #382D84",
"n c #39398D",
"m c #222296",
"M c #0101A6",
"N c #0A0AA2",
"B c #0202AC",
"V c #1919A2",
"C c #1616AD",
"Z c #0000B5",
"A c #0202BC",
"S c #0C0CB6",
"D c #1313B3",
"F c #1011BD",
"G c #1B1BBE",
"H c #2B2BAC",
"J c #3737A1",
"K c #2A26BE",
"L c #2A29B4",
"P c #3B3BB8",
"I c #48478B",
"U c #57578A",
"Y c #4A499A",
"T c #524F95",
"R c #565399",
"E c #4C4CA8",
"W c #524DA7",
"Q c #5353A4",
"! c #5555A9",
"~ c #5555B4",
"^ c #5656B7",
"/ c #6464A6",
"( c #6F67B5",
") c #0404C3",
"_ c #0707CA",
"` c #1414CB",
"' c #1A1AC6",
"] c #0A0AD3",
"[ c #0D0DDC",
"{ c #1A1AD4",
"} c #1010DF",
"| c #1E1EDE",
" . c #1817DE",
".. c #221FCA",
"X. c #2B2BCC",
"o. c #2727C9",
"O. c #3434C3",
"+. c #3434D4",
"@. c #0F0FE2",
"#. c #1313E5",
"$. c #1515ED",
"%. c #1B1BEA",
"&. c #1C1CE4",
"*. c #1515F4",
"=. c #1818F3",
"-. c #1717FD",
";. c #1818FF",
":. c #2B2BE9",
">. c #2424FF",
",. c #2A2AFF",
"<. c #2222F1",
"1. c #3737FF",
"2. c #5D5DC3",
"3. c #5F5FC9",
"4. c #5655C2",
"5. c #4747D1",
"6. c #5B5BD4",
"7. c #6565C8",
"8. c #6363DA",
"9. c #4545FF",
"0. c #4D4DFC",
"q. c #5454FF",
"w. c #5959FF",
"e. c #6969E5",
"r. c #6B6CEA",
"t. c #6666E7",
"y. c #6B6BFE",
"u. c #6767F8",
"i. c #7070F6",
"p. c #7373FF",
"a. c #7C7CFF",
"s. c #91918F",
"d. c #8F9090",
"f. c #979797",
"g. c #9C9C9C",
"h. c #8585A1",
"j. c #9C9CA7",
"k. c #9292B6",
"l. c #A4A4A4",
"z. c #BDB2A4",
"x. c #A4A4B1",
"c. c #BFBFBD",
"v. c #BABAB7",
"b. c #C8AA87",
"n. c #DAAE82",
"m. c #DBB081",
"M. c #EBBA85",
"N. c #F3BF84",
"B. c #F2BE88",
"V. c #C2B3A3",
"C. c #FBC386",
"Z. c #FCC68C",
"A. c #FFC88F",
"S. c #F4C387",
"D. c #FFC990",
"F. c #C3C1BF",
"G. c #8F8FCB",
"H. c #BDBDC2",
"J. c #BDBDD1",
"K. c #8888F9",
"L. c #A4A4FB",
"P. c #CDCDCC",
"I. c #CECAC6",
"U. c #D3CFCA",
"Y. c #D3D0CC",
"T. c #C0C0D5",
"R. c #D6D5D4",
"E. c #D7D7DD",
"W. c #E1E1DF",
"Q. c #DEDEE1",
"!. c #E4E4E4",
"~. c #E8E8E8",
"^. c #F0F0EE",
"/. c #F5F5F2",
"(. c #FFFFFF",
/* pixels */
" ",
" ",
" ",
" . + @ # ",
" $ % & * = - ; > , ' ) ! ",
" ~ { ] ^ / = ( _ : < [ } | 1 2 3 4 5 6 ",
" 7 8 9 0 a b c d e f g h i j k l m n o p q r ",
" s t u v _ f d d d w x y z A B C D E F G H I J K L ",
" M N O _ c e d d d _ P Q R S T U V W X Y Z ` ... ",
" +.@.#.$.d d d d %.&._ *.=.-.;.>.,.'.).!.~. ",
" {.].^./.(.d d _.$.:._ <.[.}.|.1.2.3.4.5. ",
" 6.7.7.4 8.e : w 9.0.a.b.c.2 d.e.f.g.h.i.j.k. ",
" l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.o o z.A.B./.b C.D. ",
" E.F.G.].o H.z.I.J.K.L.M.N.O.P.o o o Q.R.S._.b B.T. ",
" U.V.W.X.f.f.7.Y.Z.`. + + +.+++].o o o.n z.q.@+#+$+%+ ",
" &+ +*+=+].o -+;+>+ + + + +,+'+H.o o o o o H.)+o !+~+{+ ",
" ]+ +^+/+H.o.(+_+ + + + + +:+<+z.o o o o o o o 7.n H.[+}+ ",
" |+ +1+2+3+4+5+6+ + + + + +7+8+H.o o f.9+f.9+f.F 0+a+b+o.c+ ",
" &+ +d+e+f+g+h+i+ + + + + +j+k+].f.9+l+m+n+o+p+q+r+s+t+u+v+ ",
" w+ +x+y+z+A+B+C+ + + + + +D+E+9+F+G+H+I+J+K+L+M+N+O+ ",
" P+Q+R+S+T+U+V+W+ + + + +X+Y+Z+`+ @I+J+Z .@+@E. ",
" @@#@$@%@&@*@=@-@;@>@,@'@)@!@~@{@]@^@I+/@(@_@ ",
" :@<@[@}@|@1@2@3@4@5@6@7@8@9@0@L+a@b@c@d@e@ ",
" f@g@h@i@i@j@k@l@|@m@n@o@p@q@r@s@t@u@p v@ ",
" w@x@y@z@A@B@i@C@D@E@F@G@H@I@L+J@K@L@p M@ ",
" N@O@P@Q@R@S@T@U@V@W@X@Y@Z@Y@`@ #.#p +# ",
" @###$#%#&#*#=#-#;#>#,#'#)#!#~#{#]# ",
" ^#/# ",
" I Q T = ",
" Q 7.e.r.i.8.E E 3.r.6.J ",
" H ~ n 4.r.p.p.p.p.8.R > 5.^ w.,.-.{ v ",
" { 9.^ & P t.p.p.p.p.p.8.I 5 q K L <.;.;.;.-.' ",
" { %.H +.y.p.p.p.p.p.e.Y 2 a n.K F $.*.$.@.} ] N ",
" x D :.y.p.p.p.p.p.p.r.R 8 C.u ..F A ) A Z M h $ ",
" f =.q.p.p.p.p.p.p.p.p.i.( e 6 $.` l B M g ",
" ` ;.q.p.p.p.p.p.a.K.a.p.p.4.L -.` l N % ",
" V =.-.>.q.y.p.p.p.L.L.K.i.w.,.-.;.$.<.q.u.2. ",
" D { =.-.;.>.1.1.9.( h.h.Q &.-.-.-.;.9.p.p.p.r.! ",
" U j.o.-.;.-.;.-.P x.Q.^.R.~ *.-.;.;.>.1.q.y.p.i.2. ",
" H./.! *.;.;.;.o.x./.(.(.(.J.| -.-.;.-.-.;.,.9.u.p.7. ",
" !.(.k.#.;.-.=./ !.(.(.(.(.Q.X.-.;.;.;.;.-.-.;.;.1.w.6. ",
" ~.(.H.G ;.-.D j.(.(.(.(.(.!.O.-.-.;.;.;.-.;.-.;.-.;.,.O. ",
" ~.(.v.@ *.$.+ d.(.(.(.(.(.E.o.-.-.;.;.-.;.;.;.*.=.=.*.$.v ",
" ~.(.l.- Y T ; < (.(.(.(.(.J.&.-.;.;.$.@.[ ] _ ) ) Z B B f ",
" P.(.F.X c.I.X f.(.(.(.(.(.G.=.-.=.] A Z Z Z Z z f $ ",
" l.!.R.s.F.I.g.W.(.(.(.(.R.E .[ A Z Z Z B g $ ",
" . , ; - 0 M.b.V.U.R.Y.z.u n.7 c Z Z B g # + ",
" : w p Z.D.A.S.p u i M.A.A.S.* Z B h z ] C ",
" s D.D.A.A.A.A.A.A.A.i B.B.b A Z Z @.-.` ",
" 1 y C.D.A.A.A.A.A.M.u Z.e c A Z Z [ ;.&. ",
" 8 y d C.A.A.A.C.B.t * B Z Z Z A #.=.m ",
" 3 9 r t r 9 8 o @ $ # f j l B #.V ",
" j k ",
" ",
" ",
" ",
" "};
" "
};

View File

@ -39,6 +39,10 @@
#ifdef HAVE_IMAGE
#include "SDL_image.h"
#elif 1
#define LOAD_XPM //I want XPM!
#include "IMG_xpm.c" //Alam: I don't want to add SDL_Image.dll/so
#define HAVE_IMAGE //I have SDL_Image, sortof
#endif
#ifdef HAVE_IMAGE
@ -562,7 +566,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
// Tell game we got focus back, resume music if necessary
window_notinfocus = false;
if (!paused)
I_ResumeSong(0); //resume it
I_ResumeSong(); //resume it
if (!firsttimeonmouse)
{
@ -574,7 +578,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
{
// Tell game we lost focus, pause music
window_notinfocus = true;
I_PauseSong(0);
I_PauseSong();
if (!disable_mouse)
{

File diff suppressed because it is too large Load Diff

View File

@ -194,8 +194,8 @@ static srb2audio_t localdata;
static void Snd_LockAudio(void) //Alam: Lock audio data and uninstall audio callback
{
if (Snd_Mutex) SDL_LockMutex(Snd_Mutex);
else if (nosound) return;
else if (nomidimusic && nodigimusic
else if (sound_disabled) return;
else if (midi_disabled && digital_disabled
#ifdef HW3SOUND
&& hws_mode == HWS_DEFAULT_MODE
#endif
@ -208,8 +208,8 @@ static void Snd_LockAudio(void) //Alam: Lock audio data and uninstall audio call
static void Snd_UnlockAudio(void) //Alam: Unlock audio data and reinstall audio callback
{
if (Snd_Mutex) SDL_UnlockMutex(Snd_Mutex);
else if (nosound) return;
else if (nomidimusic && nodigimusic
else if (sound_disabled) return;
else if (midi_disabled && digital_disabled
#ifdef HW3SOUND
&& hws_mode == HWS_DEFAULT_MODE
#endif
@ -493,7 +493,7 @@ static inline void I_SetChannels(void)
INT32 *steptablemid = steptable + 128;
if (nosound)
if (sound_disabled)
return;
// This table provides step widths for pitch parameters.
@ -609,7 +609,7 @@ INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priori
(void)priority;
(void)pitch;
if (nosound)
if (sound_disabled)
return 0;
if (S_sfx[id].data == NULL) return -1;
@ -1136,7 +1136,7 @@ static INT32 Init3DSDriver(const char *soName)
void I_ShutdownSound(void)
{
if (nosound || !sound_started)
if (sound_disabled || !sound_started)
return;
CONS_Printf("I_ShutdownSound: ");
@ -1150,7 +1150,7 @@ void I_ShutdownSound(void)
}
#endif
if (nomidimusic && nodigimusic)
if (midi_disabled && digital_disabled)
SDL_CloseAudio();
CONS_Printf("%s", M_GetText("shut down\n"));
sound_started = false;
@ -1170,7 +1170,7 @@ void I_StartupSound(void)
const char *sdrv_name = NULL;
#endif
#ifndef HAVE_MIXER
nomidimusic = nodigimusic = true;
midi_disabled = digital_disabled = true;
#endif
memset(channels, 0, sizeof (channels)); //Alam: Clean it
@ -1213,7 +1213,7 @@ void I_StartupSound(void)
audio.samples /= 2;
}
if (nosound)
if (sound_disabled)
return;
#ifdef HW3SOUND
@ -1261,7 +1261,7 @@ void I_StartupSound(void)
{
snddev_t snddev;
//nosound = true;
//sound_disabled = true;
//I_AddExitFunc(I_ShutdownSound);
snddev.bps = 16;
snddev.sample_rate = audio.freq;
@ -1288,7 +1288,7 @@ void I_StartupSound(void)
if (!musicStarted && SDL_OpenAudio(&audio, &audio) < 0)
{
CONS_Printf("%s", M_GetText(" couldn't open audio with desired format\n"));
nosound = true;
sound_disabled = true;
return;
}
else
@ -1313,10 +1313,37 @@ void I_StartupSound(void)
// MUSIC API.
//
void I_ShutdownMIDIMusic(void)
musictype_t I_SongType(void)
{
nomidimusic = false;
if (nodigimusic) I_ShutdownMusic();
#ifdef HAVE_MIXER
#ifdef HAVE_LIBGME
if (gme)
return MU_GME;
else
#endif
if (!music)
return MU_NONE;
else if (Mix_GetMusicType(music) == MUS_MID)
return MU_MID;
else if (Mix_GetMusicType(music) == MUS_MOD || Mix_GetMusicType(music) == MUS_MODPLUG_UNUSED)
return MU_MOD;
else if (Mix_GetMusicType(music) == MUS_MP3 || Mix_GetMusicType(music) == MUS_MP3_MAD_UNUSED)
return MU_MP3;
else
return (musictype_t)Mix_GetMusicType(music);
#else
return MU_NONE
#endif
}
boolean I_SongPlaying(void)
{
return music_started;
}
boolean I_SongPaused(void)
{
return Mix_PausedMusic();
}
#ifdef HAVE_LIBGME
@ -1330,12 +1357,6 @@ static void I_ShutdownGMEMusic(void)
}
#endif
void I_ShutdownDigMusic(void)
{
nodigimusic = false;
if (nomidimusic) I_ShutdownMusic();
}
#ifdef HAVE_MIXER
static boolean LoadSong(void *data, size_t lumplength, size_t selectpos)
{
@ -1427,38 +1448,9 @@ static boolean LoadSong(void *data, size_t lumplength, size_t selectpos)
}
#endif
void I_ShutdownMusic(void)
{
#ifdef HAVE_MIXER
if ((nomidimusic && nodigimusic) || !musicStarted)
return;
CONS_Printf("%s", M_GetText("I_ShutdownMusic: "));
I_UnRegisterSong(0);
I_StopDigSong();
Mix_CloseAudio();
#ifdef MIX_INIT
Mix_Quit();
#endif
CONS_Printf("%s", M_GetText("shut down\n"));
musicStarted = SDL_FALSE;
if (Msc_Mutex)
SDL_DestroyMutex(Msc_Mutex);
Msc_Mutex = NULL;
#endif
}
void I_InitMIDIMusic(void)
{
if (nodigimusic) I_InitMusic();
}
void I_InitDigMusic(void)
{
if (nomidimusic) I_InitMusic();
}
/// ------------------------
// MUSIC SYSTEM
/// ------------------------
void I_InitMusic(void)
{
@ -1532,7 +1524,7 @@ void I_InitMusic(void)
if (Mix_OpenAudio(audio.freq, audio.format, audio.channels, audio.samples) < 0) //open_music(&audio)
{
CONS_Printf(M_GetText(" Unable to open music: %s\n"), Mix_GetError());
nomidimusic = nodigimusic = true;
midi_disabled = digital_disabled = true;
if (sound_started
#ifdef HW3SOUND
&& hws_mode == HWS_DEFAULT_MODE
@ -1542,7 +1534,7 @@ void I_InitMusic(void)
if (SDL_OpenAudio(&audio, NULL) < 0) //retry
{
CONS_Printf("%s", M_GetText(" couldn't open audio with desired format\n"));
nosound = true;
sound_disabled = true;
sound_started = false;
}
else
@ -1573,11 +1565,137 @@ void I_InitMusic(void)
#endif
}
boolean I_PlaySong(INT32 handle, boolean looping)
void I_ShutdownMusic(void)
{
(void)handle;
#ifdef HAVE_MIXER
if (nomidimusic || !musicStarted || !music[handle])
if ((midi_disabled && digital_disabled) || !musicStarted)
return;
CONS_Printf("%s", M_GetText("I_ShutdownMusic: "));
I_UnloadSong();
I_StopSong();
Mix_CloseAudio();
#ifdef MIX_INIT
Mix_Quit();
#endif
CONS_Printf("%s", M_GetText("shut down\n"));
musicStarted = SDL_FALSE;
if (Msc_Mutex)
SDL_DestroyMutex(Msc_Mutex);
Msc_Mutex = NULL;
#endif
}
/// ------------------------
// MUSIC PROPERTIES
/// ------------------------
musictype_t I_SongType(void)
{
return MU_NONE;
}
boolean I_SongPlaying(void)
{
return musicStarted;
}
boolean I_SongPaused(void)
{
return Mix_PausedMusic();
}
/// ------------------------
// MUSIC EFFECTS
/// ------------------------
boolean I_SetSongSpeed(float speed)
{
(void)speed;
return false;
}
/// ------------------------
// MUSIC SEEKING
/// ------------------------
UINT32 I_GetSongLength(void)
{
return 0;
}
boolean I_SetSongLoopPoint(UINT32 looppoint)
{
(void)looppoint;
return false;
}
UINT32 I_GetSongLoopPoint(void)
{
return 0;
}
boolean I_SetSongPosition(UINT32 position)
{
(void)position;
return false;
}
UINT32 I_GetSongPosition(void)
{
return 0;
}
/// ------------------------
// MUSIC PLAYBACK
// \todo Merge Digital and MIDI
/// ------------------------
boolean I_LoadSong(char *data, size_t len)
{
#ifdef HAVE_MIXER
if (midi_disabled || !musicStarted)
return false;
if (!LoadSong(data, len, 0))
return false;
if (music[0])
return true;
CONS_Printf(M_GetText("Couldn't load MIDI: %s\n"), Mix_GetError());
#else
(void)len;
(void)data;
#endif
return false;
}
void I_UnloadSong(void)
{
#ifdef HAVE_MIXER
if (midi_disabled || !musicStarted)
return;
Mix_HaltMusic();
while (Mix_PlayingMusic())
;
if (music[handle])
Mix_FreeMusic(music[handle]);
music[handle] = NULL;
LoadSong(NULL, 0, handle);
#else
(void)handle;
#endif
}
boolean I_PlaySong(boolean looping)
{
#ifdef HAVE_MIXER
if (!musicStarted || !music[handle])
return false;
#ifdef MIXER_POS
@ -1598,6 +1716,28 @@ boolean I_PlaySong(INT32 handle, boolean looping)
return false;
}
void I_StopSong(void)
{
I_StopGME();
#ifdef HAVE_MIXER
if (digital_disabled)
return;
#ifdef MIXER_POS
if (canlooping)
Mix_HookMusicFinished(NULL);
#endif
Mix_HaltMusic();
while (Mix_PlayingMusic())
;
if (music[1])
Mix_FreeMusic(music[1]);
music[1] = NULL;
LoadSong(NULL, 0, 1);
}
static void I_PauseGME(void)
{
#ifdef HAVE_LIBGME
@ -1605,12 +1745,12 @@ static void I_PauseGME(void)
#endif
}
void I_PauseSong(INT32 handle)
void I_PauseSong(void)
{
(void)handle;
I_PauseGME();
#ifdef HAVE_MIXER
if ((nomidimusic && nodigimusic) || !musicStarted)
if ((midi_disabled && digital_disabled) || !musicStarted)
return;
Mix_PauseMusic();
@ -1625,12 +1765,12 @@ static void I_ResumeGME(void)
#endif
}
void I_ResumeSong(INT32 handle)
void I_ResumeSong(void)
{
(void)handle;
I_ResumeGME();
#ifdef HAVE_MIXER
if ((nomidimusic && nodigimusic) || !musicStarted)
if ((midi_disabled && digital_disabled) || !musicStarted)
return;
Mix_VolumeMusic(musicvol);
@ -1639,76 +1779,10 @@ void I_ResumeSong(INT32 handle)
#endif
}
void I_StopSong(INT32 handle)
{
(void)handle;
#ifdef HAVE_MIXER
if (nomidimusic || !musicStarted)
return;
Mix_FadeOutMusic(MIDIfade);
#endif
}
boolean I_SongPlaying(void)
{
return musicStarted;
}
boolean I_SongPaused(void)
{
return Mix_PausedMusic();
}
musictype_t I_GetSongType(void)
{
return MU_NONE;
}
void I_UnRegisterSong(INT32 handle)
void I_SetMusicVolume(UINT8 volume)
{
#ifdef HAVE_MIXER
if (nomidimusic || !musicStarted)
return;
Mix_HaltMusic();
while (Mix_PlayingMusic())
;
if (music[handle])
Mix_FreeMusic(music[handle]);
music[handle] = NULL;
LoadSong(NULL, 0, handle);
#else
(void)handle;
#endif
}
INT32 I_RegisterSong(void *data, size_t len)
{
#ifdef HAVE_MIXER
if (nomidimusic || !musicStarted)
return false;
if (!LoadSong(data, len, 0))
return false;
if (music[0])
return true;
CONS_Printf(M_GetText("Couldn't load MIDI: %s\n"), Mix_GetError());
#else
(void)len;
(void)data;
#endif
return false;
}
void I_SetMIDIMusicVolume(UINT8 volume)
{
#ifdef HAVE_MIXER
if ((nomidimusic && nodigimusic) || !musicStarted)
if ((midi_disabled && digital_disabled) || !musicStarted)
return;
if (Msc_Mutex) SDL_LockMutex(Msc_Mutex);
@ -1720,6 +1794,60 @@ void I_SetMIDIMusicVolume(UINT8 volume)
#endif
}
boolean I_SetSongTrack(int track)
{
(void)track;
return false;
}
/// ------------------------
/// MUSIC FADING
/// ------------------------
void I_SetInternalMusicVolume(UINT8 volume)
{
(void)volume;
}
void I_StopFadingSong(void)
{
}
boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, boolean stopafterfade)
{
(void)target_volume;
(void)source_volume;
(void)ms;
return false;
}
boolean I_FadeSong(UINT8 target_volume, UINT32 ms)
{
(void)target_volume;
(void)ms;
return false;
}
boolean I_FadeOutStopSong(UINT32 ms)
{
(void)ms;
return false;
}
boolean I_FadeInStartDigSong(const char *musicname, UINT16 track, boolean looping, UINT32 position, UINT32 fadeinms, boolean queuepostfade)
{
(void)musicname;
(void)looping;
(void)fadeinms;
return false;
}
/// ------------------------
// MUSIC LOADING AND CLEANUP
// \todo Split logic between loading and playing,
// then move to Playback section
/// ------------------------
#ifdef HAVE_LIBGME
static void I_CleanupGME(void *userdata)
{
@ -1795,14 +1923,14 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
return true;
#ifdef HAVE_MIXER
if (nodigimusic)
if (digital_disabled)
return false;
snprintf(filename, sizeof filename, "o_%s", musicname);
lumpnum = W_CheckNumForName(filename);
I_StopDigSong();
I_StopSong();
if (lumpnum == LUMPERROR)
{
@ -1954,112 +2082,6 @@ static void I_StopGME(void)
#endif
}
void I_StopDigSong(void)
{
I_StopGME();
#ifdef HAVE_MIXER
if (nodigimusic)
return;
#ifdef MIXER_POS
if (canlooping)
Mix_HookMusicFinished(NULL);
#endif
Mix_HaltMusic();
while (Mix_PlayingMusic())
;
if (music[1])
Mix_FreeMusic(music[1]);
music[1] = NULL;
LoadSong(NULL, 0, 1);
#endif
}
void I_SetDigMusicVolume(UINT8 volume)
{
I_SetMIDIMusicVolume(volume);
}
boolean I_SetSongSpeed(float speed)
{
(void)speed;
return false;
}
UINT32 I_GetSongLength(void)
{
return 0;
}
boolean I_SetSongLoopPoint(UINT32 looppoint)
{
(void)looppoint;
return false;
}
UINT32 I_GetSongLoopPoint(void)
{
return 0;
}
boolean I_SetSongPosition(UINT32 position)
{
(void)position;
return false;
}
UINT32 I_GetSongPosition(void)
{
return 0;
}
boolean I_SetSongTrack(int track)
{
(void)track;
return false;
}
void I_SetInternalMusicVolume(UINT8 volume)
{
(void)volume;
}
void I_StopFadingSong(void)
{
}
boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, boolean stopafterfade)
{
(void)target_volume;
(void)source_volume;
(void)ms;
return false;
}
boolean I_FadeSong(UINT8 target_volume, UINT32 ms)
{
(void)target_volume;
(void)ms;
return false;
}
boolean I_FadeOutStopSong(UINT32 ms)
{
(void)ms;
return false;
}
boolean I_FadeInStartDigSong(const char *musicname, UINT16 track, boolean looping, UINT32 position, UINT32 fadeinms, boolean queuepostfade)
{
(void)musicname;
(void)looping;
(void)fadeinms;
return false;
}
#ifdef MIXER_POS
static void SDLCALL I_FinishMusic(void)
{

View File

@ -161,7 +161,7 @@ static BOOL wasPlaying;
//static INT cdVolume = 0; // current cd volume (0-31)
// 0-31 like Music & Sfx, though CD hardware volume is 0-255.
consvar_t cd_volume = {"cd_volume","31",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cd_volume = {"cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
// allow Update for next/loop track
// some crap cd drivers take up to

View File

@ -110,9 +110,9 @@ static LRESULT CALLBACK MainWndproc(HWND hWnd, UINT message, WPARAM wParam, LPAR
// pause music when alt-tab
if (appActive && !paused)
I_ResumeSong(0);
I_ResumeSong();
else if (!paused)
I_PauseSong(0);
I_PauseSong();
{
HANDLE ci = GetStdHandle(STD_INPUT_HANDLE);
DWORD mode;

View File

@ -42,7 +42,6 @@
static FMOD_SYSTEM *fsys;
static FMOD_SOUND *music_stream;
static FMOD_CHANNEL *music_channel;
static boolean midimode;
static UINT8 music_volume, midi_volume, sfx_volume;
static INT32 current_track;
@ -440,9 +439,9 @@ void I_SetSfxVolume(UINT8 volume)
sfx_volume = volume;
}
//
// MUSIC
//
/// ------------------------
// MUSIC SYSTEM
/// ------------------------
void I_InitMusic(void)
{
@ -450,22 +449,46 @@ void I_InitMusic(void)
void I_ShutdownMusic(void)
{
I_ShutdownDigMusic();
I_ShutdownMIDIMusic();
I_StopSong();
}
void I_PauseSong(INT32 handle)
{
UNREFERENCED_PARAMETER(handle);
if (music_stream)
FMR_MUSIC(FMOD_Channel_SetPaused(music_channel, true));
}
/// ------------------------
// MUSIC PROPERTIES
/// ------------------------
void I_ResumeSong(INT32 handle)
musictype_t I_SongType(void)
{
UNREFERENCED_PARAMETER(handle);
if (music_stream)
FMR_MUSIC(FMOD_Channel_SetPaused(music_channel, false));
#ifdef HAVE_LIBGME
if (gme)
return MU_GME;
#endif
if (!music_stream)
return MU_NONE;
FMOD_SOUND_TYPE type;
if (FMOD_Sound_GetFormat(music_stream, &type, NULL, NULL, NULL) == FMOD_OK)
{
switch(type)
{
case FMOD_SOUND_TYPE_WAV:
return MU_WAV;
case FMOD_SOUND_TYPE_MOD:
return MU_MOD;
case FMOD_SOUND_TYPE_MID:
return MU_MID;
case FMOD_SOUND_TYPE_OGGVORBIS:
return MU_OGG;
case FMOD_SOUND_TYPE_MP3:
return MU_MP3;
case FMOD_SOUND_TYPE_FLAC:
return MU_FLAC;
default:
return MU_NONE;
}
}
else
return MU_NONE;
}
boolean I_SongPlaying(void)
@ -481,22 +504,48 @@ boolean I_SongPaused(void)
return fmpaused;
}
musictype_t I_GetSongType(void)
/// ------------------------
// MUSIC EFFECTS
/// ------------------------
boolean I_SetSongSpeed(float speed)
{
return MU_NONE;
FMOD_RESULT e;
float frequency;
if (!music_stream)
return false;
if (speed > 250.0f)
speed = 250.0f; //limit speed up to 250x
#ifdef HAVE_LIBGME
// Try to set GME speed
if (gme)
{
gme_set_tempo(gme, speed);
return true;
}
#endif
// Try to set Mod/Midi speed
e = FMOD_Sound_SetMusicSpeed(music_stream, speed);
if (e == FMOD_ERR_FORMAT)
{
// Just change pitch instead for Ogg/etc.
FMR(FMOD_Sound_GetDefaults(music_stream, &frequency, NULL, NULL, NULL));
FMR_MUSIC(FMOD_Channel_SetFrequency(music_channel, speed*frequency));
}
else
FMR_MUSIC(e);
return true;
}
void I_InitDigMusic(void)
{
}
/// ------------------------
// MUSIC PLAYBACK
/// ------------------------
void I_ShutdownDigMusic(void)
{
if (!midimode)
I_StopDigSong();
}
boolean I_StartDigSong(const char *musicname, boolean looping)
boolean I_LoadSong(char *data, size_t len)
{
char *data;
size_t len;
@ -508,10 +557,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
lumpnum = W_CheckNumForName(va("D_%s",musicname));
if (lumpnum == LUMPERROR)
return false;
midimode = true;
}
else
midimode = false;
data = (char *)W_CacheLumpNum(lumpnum, PU_MUSIC);
len = W_LumpLength(lumpnum);
@ -621,8 +667,6 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
{
gme_equalizer_t gmeq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0};
Z_Free(data); // We don't need this anymore.
gme_start_track(gme, 0);
current_track = 0;
gme_set_equalizer(gme,&gmeq);
fmt.format = FMOD_SOUND_FORMAT_PCM16;
fmt.defaultfrequency = 44100;
@ -632,6 +676,102 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
fmt.pcmreadcallback = GMEReadCallback;
fmt.userdata = gme;
FMR(FMOD_System_CreateStream(fsys, NULL, FMOD_OPENUSER | (looping ? FMOD_LOOP_NORMAL : 0), &fmt, &music_stream));
return true;
}
#endif
fmt.length = len;
FMOD_RESULT e = FMOD_System_CreateStream(fsys, data, FMOD_OPENMEMORY_POINT|(looping ? FMOD_LOOP_NORMAL : 0), &fmt, &music_stream);
if (e != FMOD_OK)
{
if (e == FMOD_ERR_FORMAT)
CONS_Alert(CONS_WARNING, "Failed to play music lump %s due to invalid format.\n", W_CheckNameForNum(lumpnum));
else
FMR(e);
return false;
}
// Try to find a loop point in streaming music formats (ogg, mp3)
FMOD_RESULT e;
FMOD_TAG tag;
unsigned int loopstart, loopend;
// A proper LOOPPOINT is its own tag, stupid.
e = FMOD_Sound_GetTag(music_stream, "LOOPPOINT", 0, &tag);
if (e != FMOD_ERR_TAGNOTFOUND)
{
FMR(e);
loopstart = atoi((char *)tag.data); // assumed to be a string data tag.
FMR(FMOD_Sound_GetLoopPoints(music_stream, NULL, FMOD_TIMEUNIT_PCM, &loopend, FMOD_TIMEUNIT_PCM));
if (loopstart > 0)
FMR(FMOD_Sound_SetLoopPoints(music_stream, loopstart, FMOD_TIMEUNIT_PCM, loopend, FMOD_TIMEUNIT_PCM));
return true;
}
// todo
// if(music type == MIDI)
// {
// FMR(FMOD_Sound_SetMode(music_stream, FMOD_LOOP_NORMAL));
// return true;
// }
// Use LOOPMS for time in miliseconds.
e = FMOD_Sound_GetTag(music_stream, "LOOPMS", 0, &tag);
if (e != FMOD_ERR_TAGNOTFOUND)
{
FMR(e);
loopstart = atoi((char *)tag.data); // assumed to be a string data tag.
FMR(FMOD_Sound_GetLoopPoints(music_stream, NULL, FMOD_TIMEUNIT_MS, &loopend, FMOD_TIMEUNIT_PCM));
if (loopstart > 0)
FMR(FMOD_Sound_SetLoopPoints(music_stream, loopstart, FMOD_TIMEUNIT_MS, loopend, FMOD_TIMEUNIT_PCM));
return true;
}
// Try to fetch it from the COMMENT tag, like A.J. Freda
e = FMOD_Sound_GetTag(music_stream, "COMMENT", 0, &tag);
if (e != FMOD_ERR_TAGNOTFOUND)
{
char *loopText;
// Handle any errors that arose, first
FMR(e);
// Figure out where the number starts
loopText = strstr((char *)tag.data,"LOOPPOINT=");
if (loopText != NULL)
{
// Skip the "LOOPPOINT=" part.
loopText += 10;
// Convert it to our looppoint
// FMOD seems to ensure the tag is properly NULL-terminated.
// atoi will stop when it reaches anything that's not a number.
loopstart = atoi(loopText);
// Now do the rest like above
FMR(FMOD_Sound_GetLoopPoints(music_stream, NULL, FMOD_TIMEUNIT_PCM, &loopend, FMOD_TIMEUNIT_PCM));
if (loopstart > 0)
FMR(FMOD_Sound_SetLoopPoints(music_stream, loopstart, FMOD_TIMEUNIT_PCM, loopend, FMOD_TIMEUNIT_PCM));
}
return true;
}
// No special loop point
return true;
}
void I_UnloadSong(void)
{
UNREFERENCED_PARAMETER(handle);
if (music_stream)
FMR(FMOD_Sound_Release(music_stream));
music_stream = NULL;
}
boolean I_PlaySong(boolean looping)
{
#ifdef HAVE_LIBGME
if (gme)
{
gme_start_track(gme, 0);
current_track = 0;
FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel));
FMR(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0));
FMR(FMOD_Channel_SetPriority(music_channel, 0));
@ -639,139 +779,55 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
}
#endif
fmt.length = len;
{
FMOD_RESULT e = FMOD_System_CreateStream(fsys, data, FMOD_OPENMEMORY_POINT|(looping ? FMOD_LOOP_NORMAL : 0), &fmt, &music_stream);
if (e != FMOD_OK)
{
if (e == FMOD_ERR_FORMAT)
CONS_Alert(CONS_WARNING, "Failed to play music lump %s due to invalid format.\n", W_CheckNameForNum(lumpnum));
else
FMR(e);
return false;
}
}
FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel));
if (midimode)
if (I_SongType() != MU_MID)
FMR(FMOD_Channel_SetVolume(music_channel, midi_volume / 31.0));
else
FMR(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0));
FMR(FMOD_Channel_SetPriority(music_channel, 0));
current_track = 0;
// Try to find a loop point in streaming music formats (ogg, mp3)
if (looping)
{
FMOD_RESULT e;
FMOD_TAG tag;
unsigned int loopstart, loopend;
// A proper LOOPPOINT is its own tag, stupid.
e = FMOD_Sound_GetTag(music_stream, "LOOPPOINT", 0, &tag);
if (e != FMOD_ERR_TAGNOTFOUND)
{
FMR(e);
loopstart = atoi((char *)tag.data); // assumed to be a string data tag.
FMR(FMOD_Sound_GetLoopPoints(music_stream, NULL, FMOD_TIMEUNIT_PCM, &loopend, FMOD_TIMEUNIT_PCM));
if (loopstart > 0)
FMR(FMOD_Sound_SetLoopPoints(music_stream, loopstart, FMOD_TIMEUNIT_PCM, loopend, FMOD_TIMEUNIT_PCM));
return true;
}
// Use LOOPMS for time in miliseconds.
e = FMOD_Sound_GetTag(music_stream, "LOOPMS", 0, &tag);
if (e != FMOD_ERR_TAGNOTFOUND)
{
FMR(e);
loopstart = atoi((char *)tag.data); // assumed to be a string data tag.
FMR(FMOD_Sound_GetLoopPoints(music_stream, NULL, FMOD_TIMEUNIT_MS, &loopend, FMOD_TIMEUNIT_PCM));
if (loopstart > 0)
FMR(FMOD_Sound_SetLoopPoints(music_stream, loopstart, FMOD_TIMEUNIT_MS, loopend, FMOD_TIMEUNIT_PCM));
return true;
}
// Try to fetch it from the COMMENT tag, like A.J. Freda
e = FMOD_Sound_GetTag(music_stream, "COMMENT", 0, &tag);
if (e != FMOD_ERR_TAGNOTFOUND)
{
char *loopText;
// Handle any errors that arose, first
FMR(e);
// Figure out where the number starts
loopText = strstr((char *)tag.data,"LOOPPOINT=");
if (loopText != NULL)
{
// Skip the "LOOPPOINT=" part.
loopText += 10;
// Convert it to our looppoint
// FMOD seems to ensure the tag is properly NULL-terminated.
// atoi will stop when it reaches anything that's not a number.
loopstart = atoi(loopText);
// Now do the rest like above
FMR(FMOD_Sound_GetLoopPoints(music_stream, NULL, FMOD_TIMEUNIT_PCM, &loopend, FMOD_TIMEUNIT_PCM));
if (loopstart > 0)
FMR(FMOD_Sound_SetLoopPoints(music_stream, loopstart, FMOD_TIMEUNIT_PCM, loopend, FMOD_TIMEUNIT_PCM));
}
return true;
}
}
// No special loop point, but we're playing so it's all good.
return true;
}
void I_StopDigSong(void)
void I_StopSong(void)
{
if (music_stream)
FMR(FMOD_Sound_Release(music_stream));
music_stream = NULL;
#ifdef HAVE_LIBGME
if (gme)
gme_delete(gme);
gme = NULL;
#endif
current_track = -1;
I_UnloadSong();
}
void I_SetDigMusicVolume(UINT8 volume)
void I_PauseSong(void)
{
// volume is 0 to 31.
music_volume = volume;
if (!midimode && music_stream)
FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, volume / 31.0));
UNREFERENCED_PARAMETER(handle);
if (music_stream)
FMR_MUSIC(FMOD_Channel_SetPaused(music_channel, true));
}
boolean I_SetSongSpeed(float speed)
void I_ResumeSong(void)
{
UNREFERENCED_PARAMETER(handle);
if (music_stream)
FMR_MUSIC(FMOD_Channel_SetPaused(music_channel, false));
}
void I_SetMusicVolume(UINT8 volume)
{
FMOD_RESULT e;
float frequency;
if (!music_stream)
return false;
if (speed > 250.0f)
speed = 250.0f; //limit speed up to 250x
return;
#ifdef HAVE_LIBGME
// Try to set GME speed
if (gme)
{
gme_set_tempo(gme, speed);
return true;
}
#endif
// Try to set Mod/Midi speed
e = FMOD_Sound_SetMusicSpeed(music_stream, speed);
if (e == FMOD_ERR_FORMAT)
{
// Just change pitch instead for Ogg/etc.
FMR(FMOD_Sound_GetDefaults(music_stream, &frequency, NULL, NULL, NULL));
FMR_MUSIC(FMOD_Channel_SetFrequency(music_channel, speed*frequency));
}
// volume is 0 to 31.
if (I_SongType() == MU_MID)
music_volume = 31; // windows bug hack
else
FMR_MUSIC(e);
music_volume = volume;
return true;
FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0));
}
UINT32 I_GetSongLength()
@ -873,6 +929,10 @@ boolean I_SetSongTrack(INT32 track)
return false;
}
/// ------------------------
/// MUSIC FADING
/// ------------------------
void I_SetInternalMusicVolume(UINT8 volume)
{
(void)volume;
@ -911,61 +971,3 @@ boolean I_FadeInStartDigSong(const char *musicname, UINT16 track, boolean loopin
return false;
}
//
// Fuck MIDI. ... Okay fine, you can have your silly D_-only mode.
//
void I_InitMIDIMusic(void)
{
}
void I_ShutdownMIDIMusic(void)
{
if (midimode)
I_StopSong(0);
}
void I_SetMIDIMusicVolume(UINT8 volume)
{
// volume is 0 to 31.
midi_volume = volume;
if (midimode && music_stream)
FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, volume / 31.0));
}
INT32 I_RegisterSong(void *data, size_t len)
{
FMOD_CREATESOUNDEXINFO fmt;
memset(&fmt, 0, sizeof(FMOD_CREATESOUNDEXINFO));
fmt.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
fmt.length = len;
FMR(FMOD_System_CreateStream(fsys, (char *)data, FMOD_OPENMEMORY_POINT, &fmt, &music_stream));
return 1337;
}
boolean I_PlaySong(INT32 handle, boolean looping)
{
if (1337 == handle)
{
midimode = true;
if (looping)
FMR(FMOD_Sound_SetMode(music_stream, FMOD_LOOP_NORMAL));
FMR(FMOD_System_PlaySound(fsys, FMOD_CHANNEL_FREE, music_stream, false, &music_channel));
FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, midi_volume / 31.0));
FMR_MUSIC(FMOD_Channel_SetPriority(music_channel, 0));
}
return true;
}
void I_StopSong(INT32 handle)
{
I_UnRegisterSong(handle);
}
void I_UnRegisterSong(INT32 handle)
{
UNREFERENCED_PARAMETER(handle);
if (music_stream)
FMR(FMOD_Sound_Release(music_stream));
music_stream = NULL;
}