Simplified music system (a bit)
This commit is contained in:
parent
5b7237f97f
commit
6a6990bd77
12 changed files with 286 additions and 257 deletions
16
Makefile
16
Makefile
|
@ -39,7 +39,7 @@ CC=gcc -m32
|
|||
override BASE_CFLAGS += -Dstricmp=strcasecmp -Wunused -I./include/
|
||||
RELEASE_CFLAGS=$(BASE_CFLAGS) -O2 -funroll-loops -ffast-math -fomit-frame-pointer -funsigned-char -fno-strength-reduce
|
||||
DEBUG_CFLAGS=$(BASE_CFLAGS) -g
|
||||
LDFLAGS=-lm -ldl
|
||||
override LDFLAGS += -lm -ldl
|
||||
XLDFLAGS=-L/usr/X11R6/lib -lX11 -lXext -lXxf86dga
|
||||
XCFLAGS=-DX11
|
||||
|
||||
|
@ -180,9 +180,8 @@ NGUNIX_OBJS = \
|
|||
$(BUILDDIR)/view.o \
|
||||
$(BUILDDIR)/wad.o \
|
||||
$(BUILDDIR)/world.o \
|
||||
$(BUILDDIR)/tracker_linux.o \
|
||||
$(BUILDDIR)/xmms-ctl.o \
|
||||
$(BUILDDIR)/cd_null.o \
|
||||
$(BUILDDIR)/tracker_fmodex.o \
|
||||
$(BUILDDIR)/tracker_main.o \
|
||||
$(BUILDDIR)/sys_linux.o \
|
||||
$(BUILDDIR)/vid_x.o \
|
||||
$(BUILDDIR)/snd_dma.o \
|
||||
|
@ -532,13 +531,10 @@ $(BUILDDIR)/wad.o : $(MOUNT_DIR)/wad.c
|
|||
$(BUILDDIR)/world.o : $(MOUNT_DIR)/world.c
|
||||
$(DO_CC)
|
||||
|
||||
$(BUILDDIR)/tracker_linux.o : $(MOUNT_DIR)/../tracker/tracker_linux.c
|
||||
$(DO_DUMB)
|
||||
$(BUILDDIR)/tracker_fmodex.o :$(MOUNT_DIR)/../tracker/tracker_fmodex.c
|
||||
$(DO_CC)
|
||||
|
||||
$(BUILDDIR)/xmms-ctl.o : $(MOUNT_DIR)/../audio/xmms-ctl.c
|
||||
$(DO_DUMB)
|
||||
|
||||
$(BUILDDIR)/cd_null.o : $(MOUNT_DIR)/../audio/cd_null.c
|
||||
$(BUILDDIR)/tracker_main.o :$(MOUNT_DIR)/../tracker/tracker_main.c
|
||||
$(DO_CC)
|
||||
|
||||
$(BUILDDIR)/sys_linux.o :$(MOUNT_DIR)/../system/sys_linux.c
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
#include "globaldef.h"
|
||||
|
||||
void CDAudio_Play(byte track, qboolean looping)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CDAudio_Stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CDAudio_Pause(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CDAudio_Resume(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CDAudio_Update(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int CDAudio_Init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void CDAudio_Shutdown(void)
|
||||
{
|
||||
}
|
|
@ -310,14 +310,8 @@ void S_Shutdown(void)
|
|||
|
||||
if (shm)
|
||||
shm->gamealive = 0;
|
||||
#ifdef ASS_MIDI
|
||||
MUSIC_Shutdown();
|
||||
#endif
|
||||
Tracker_Shutdown();
|
||||
|
||||
#ifdef XMMSCTL
|
||||
XMMS_Shutdown();
|
||||
#endif
|
||||
Music_Shutdown();
|
||||
|
||||
shm = 0;
|
||||
sound_started = 0;
|
||||
|
|
|
@ -1459,10 +1459,7 @@ void CL_ParseServerMessage (void)
|
|||
|
||||
if (cl.paused)
|
||||
{
|
||||
Tracker_Pause ();
|
||||
#ifdef XMMSCTL
|
||||
XMMS_Pause();
|
||||
#endif
|
||||
Music_Pause();
|
||||
|
||||
#ifdef _WIN32
|
||||
VID_HandlePause (true);
|
||||
|
@ -1470,11 +1467,7 @@ void CL_ParseServerMessage (void)
|
|||
}
|
||||
else
|
||||
{
|
||||
Tracker_Resume ();
|
||||
#ifdef XMMSCTL
|
||||
XMMS_Resume();
|
||||
#endif
|
||||
|
||||
Music_Resume();
|
||||
#ifdef _WIN32
|
||||
VID_HandlePause (false);
|
||||
#endif
|
||||
|
@ -1535,19 +1528,10 @@ void CL_ParseServerMessage (void)
|
|||
cl.cdtrack = MSG_ReadByte ();
|
||||
cl.looptrack = MSG_ReadByte ();
|
||||
if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
|
||||
{
|
||||
Tracker_Play ((byte)cls.forcetrack, true);
|
||||
#ifdef XMMSCTL
|
||||
XMMS_Play ((byte)cls.forcetrack, true);
|
||||
#endif
|
||||
}
|
||||
Music_Play ((byte)cls.forcetrack, true);
|
||||
else
|
||||
{
|
||||
Tracker_Play ((byte)cl.cdtrack, true);
|
||||
#ifdef XMMSCTL
|
||||
XMMS_Play ((byte)cl.cdtrack, true);
|
||||
#endif
|
||||
}
|
||||
Music_Play ((byte)cl.cdtrack, true);
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -917,11 +917,7 @@ void _Host_Frame (float time)
|
|||
else
|
||||
S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
|
||||
|
||||
#ifdef ASS_MIDI
|
||||
MIDI_Update(); // leilei - update our midi
|
||||
#endif
|
||||
CDAudio_Update();
|
||||
Tracker_Update();
|
||||
Music_Update();
|
||||
|
||||
if (host_speeds->value)
|
||||
{
|
||||
|
@ -1332,16 +1328,10 @@ void Host_Init (quakeparms_t *parms)
|
|||
|
||||
#endif
|
||||
|
||||
#ifndef BENCH
|
||||
CDAudio_Init ();
|
||||
Tracker_Init ();
|
||||
|
||||
#ifdef XMMSCTL
|
||||
XMMS_Init();
|
||||
#endif
|
||||
|
||||
Music_Init();
|
||||
Sbar_Init ();
|
||||
#endif
|
||||
|
||||
CL_Init ();
|
||||
|
||||
#if defined(_WIN32) || defined(DOSQUAKE) // on non dos/win32, mouse comes before video for security reasons
|
||||
|
@ -1349,6 +1339,8 @@ void Host_Init (quakeparms_t *parms)
|
|||
#endif
|
||||
}
|
||||
|
||||
// Cbuf_InsertText ("exec default.cfg\n");
|
||||
// Cbuf_InsertText ("exec config.cfg\n");
|
||||
Cbuf_InsertText ("exec ngunix.rc\n");
|
||||
|
||||
#ifdef BENCH
|
||||
|
@ -1390,13 +1382,7 @@ void Host_Shutdown(void)
|
|||
#ifndef BENCH
|
||||
Host_WriteConfiguration ();
|
||||
#endif
|
||||
CDAudio_Shutdown ();
|
||||
Tracker_Shutdown ();
|
||||
|
||||
#ifdef XMMSCTL
|
||||
XMMS_Shutdown();
|
||||
#endif
|
||||
|
||||
Music_Shutdown ();
|
||||
NET_Shutdown ();
|
||||
S_Shutdown();
|
||||
IN_Shutdown ();
|
||||
|
|
|
@ -207,7 +207,7 @@ extern cvar_t *vid_stretch_by_2;
|
|||
|
||||
#define MENU_BRIGHTNESS 105
|
||||
#define MENU_MOUSESPEED 106
|
||||
#define MENU_CD_VOLUME 107
|
||||
#define MENU_MUSIC_VOLUME 107
|
||||
#define MENU_SOUND_VOLUME 108
|
||||
#define MENU_ALWAYS_RUN 109
|
||||
#define MENU_INVERT_MOUSE 110
|
||||
|
@ -254,7 +254,7 @@ extern cvar_t *vid_stretch_by_2;
|
|||
#define MENU_LOWWORLD 179
|
||||
#define MENU_LOWMODELS 180
|
||||
#define MENU_LERPMODELS 181
|
||||
#define MENU_MIDI_VOLUME 182
|
||||
|
||||
#define MENU_COLOREDDYNS 183
|
||||
#define MENU_TRANQUALITY 184
|
||||
#define MENU_LIGHTQUALITY 185
|
||||
|
@ -371,8 +371,8 @@ int sound_options_cursor;
|
|||
menu_definition_t m_menu_sound_options[] =
|
||||
{ // Sound Options
|
||||
{MENU_OPTIONS, MENU_OPTIONS}, // this is the ESC key function and title
|
||||
{MENU_CD_VOLUME, MENU_SELECTABLE},
|
||||
{MENU_MIDI_VOLUME, MENU_SELECTABLE},
|
||||
{MENU_MUSIC_VOLUME, MENU_SELECTABLE},
|
||||
|
||||
{MENU_SOUND_VOLUME, MENU_SELECTABLE},
|
||||
{MENU_SOUND_PITCH, MENU_SELECTABLE},
|
||||
{MENU_CLASSICSPAT, MENU_SELECTABLE},
|
||||
|
@ -1956,24 +1956,13 @@ int M_DrawFunction (menu_definition_t *menu_definition, int y)
|
|||
y += 8;
|
||||
break;
|
||||
|
||||
case MENU_CD_VOLUME:
|
||||
M_Print (16, y, " CD Music Volume");
|
||||
case MENU_MUSIC_VOLUME:
|
||||
M_Print (16, y, " Music Volume");
|
||||
r = bgmvolume->value;
|
||||
M_DrawSlider (220, y, r);
|
||||
y += 8;
|
||||
break;
|
||||
|
||||
case MENU_MIDI_VOLUME:
|
||||
#ifndef linux
|
||||
M_Print (16, y, " MIDI Music Volume");
|
||||
#else
|
||||
M_Print (16, y, " Tracker Volume");
|
||||
#endif
|
||||
r = midivolume->value;
|
||||
M_DrawSlider (220, y, r);
|
||||
y += 8;
|
||||
break;
|
||||
|
||||
case MENU_SOUND_VOLUME:
|
||||
M_Print (16, y, " Sound Volume");
|
||||
r = volume->value;
|
||||
|
@ -2767,7 +2756,7 @@ void M_ExecFunction (menu_definition_t *menu_definition, int key)
|
|||
}
|
||||
break;
|
||||
|
||||
case MENU_CD_VOLUME:
|
||||
case MENU_MUSIC_VOLUME:
|
||||
if (dir != 0)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
@ -2783,24 +2772,6 @@ void M_ExecFunction (menu_definition_t *menu_definition, int key)
|
|||
m_changesound = true;
|
||||
}
|
||||
break;
|
||||
case MENU_MIDI_VOLUME:
|
||||
if (dir != 0)
|
||||
{
|
||||
midivolume->value += dir * 0.1;
|
||||
if (midivolume->value < 0)
|
||||
midivolume->value = 0;
|
||||
if (midivolume->value > 1)
|
||||
midivolume->value = 1;
|
||||
Cvar_SetValue (midivolume, midivolume->value);
|
||||
#ifndef BENCH
|
||||
MIDI_Update();
|
||||
#endif
|
||||
m_changesound = true;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case MENU_SOUND_VOLUME:
|
||||
if (dir != 0)
|
||||
{
|
||||
|
|
|
@ -374,7 +374,7 @@ SV_NoclipMove
|
|||
*/
|
||||
void SV_NoclipMove (void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
vec3_t wishvel;
|
||||
float fmove, smove, umove;
|
||||
|
||||
|
@ -388,10 +388,9 @@ void SV_NoclipMove (void)
|
|||
fmove = 0;
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
wishvel[i] = forward[i]*fmove + right[i]*smove + up[i]*umove;
|
||||
|
||||
wishvel[2] = -wishvel[2] * 2;
|
||||
wishvel[i] = (forward[i]*fmove) + (right[i]*smove) + (up[i]*umove);
|
||||
|
||||
wishvel[2] *= -2;
|
||||
VectorCopy (wishvel, velocity);
|
||||
}
|
||||
/*
|
||||
|
|
119
tracker/tracker_fmodex.c
Normal file
119
tracker/tracker_fmodex.c
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* FMOD PLAYBACK, LINKED DYNAMICALLY
|
||||
* THIS TOTALLY WON'T BUILD ON ITS OWN, I SWEAR.
|
||||
* YOU'D HAVE TO KNOW HOW TO LINK IT AND STUFF BY YOURSELF.
|
||||
*/
|
||||
|
||||
#include "globaldef.h"
|
||||
|
||||
#ifdef FMOD
|
||||
#include <fmodex/fmod.h>
|
||||
|
||||
FMOD_SYSTEM *fmod_system;
|
||||
FMOD_SOUND *fmod_sound;
|
||||
FMOD_CHANNEL *fmod_channel = 0;
|
||||
FMOD_RESULT fmod_result;
|
||||
|
||||
static byte fmod_track;
|
||||
static byte fmod_loop;
|
||||
static float fmod_volume = 1.0f;
|
||||
static qboolean fmod_initialised = false;
|
||||
char fmod_file[MAX_OSPATH];
|
||||
|
||||
void FmodEx_Play(byte track, qboolean looping)
|
||||
{
|
||||
if(!fmod_initialised)
|
||||
return;
|
||||
if (fmod_track == track)
|
||||
return;
|
||||
|
||||
fmod_track = track;
|
||||
fmod_loop = looping;
|
||||
fmod_volume = bgmvolume->value;
|
||||
|
||||
sprintf(fmod_file, "%s/music/track%d.ogg", com_gamedir, fmod_track);
|
||||
if(fmod_loop == true)
|
||||
fmod_result = FMOD_System_CreateSound (fmod_system, fmod_file, FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_NORMAL | FMOD_CREATESTREAM, 0, &fmod_sound);
|
||||
else
|
||||
fmod_result = FMOD_System_CreateSound (fmod_system, fmod_file, FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_OFF | FMOD_CREATESTREAM, 0, &fmod_sound);
|
||||
|
||||
if (fmod_result != FMOD_OK)
|
||||
{
|
||||
Con_Printf("FmodEx: Can't load %s!\n", fmod_file);
|
||||
return;
|
||||
}
|
||||
|
||||
FMOD_System_PlaySound (fmod_system, FMOD_CHANNEL_FREE, fmod_sound, 0, &fmod_channel);
|
||||
FMOD_Channel_SetVolume(fmod_channel, fmod_volume);
|
||||
}
|
||||
|
||||
void FmodEx_Stop(void)
|
||||
{
|
||||
FMOD_Sound_Release (fmod_sound);
|
||||
}
|
||||
|
||||
void FmodEx_Pause(void)
|
||||
{
|
||||
FMOD_Channel_SetPaused(fmod_channel, true);
|
||||
}
|
||||
|
||||
void FmodEx_Resume(void)
|
||||
{
|
||||
FMOD_Channel_SetPaused(fmod_channel, false);
|
||||
}
|
||||
|
||||
void FmodEx_Update(void)
|
||||
{
|
||||
if(fmod_volume != bgmvolume->value)
|
||||
{
|
||||
fmod_volume = bgmvolume->value;
|
||||
FMOD_Channel_SetVolume(fmod_channel, fmod_volume);
|
||||
}
|
||||
}
|
||||
|
||||
static void FmodEx_f (void)
|
||||
{
|
||||
char *command;
|
||||
int i;
|
||||
|
||||
if (Cmd_Argc() < 2)
|
||||
return;
|
||||
|
||||
command = Cmd_Argv (1);
|
||||
|
||||
if (Q_strcasecmp(command, "play") == 0)
|
||||
FmodEx_Play((byte)Q_atoi(Cmd_Argv (2)), false);
|
||||
else if (Q_strcasecmp(command, "pause") == 0)
|
||||
FmodEx_Pause();
|
||||
else if (Q_strcasecmp(command, "resume") == 0)
|
||||
FmodEx_Resume();
|
||||
else if (Q_strcasecmp(command, "stop") == 0)
|
||||
FmodEx_Stop();
|
||||
}
|
||||
|
||||
int FmodEx_Init(void)
|
||||
{
|
||||
unsigned int version;
|
||||
|
||||
if (FMOD_System_Create (&fmod_system)){
|
||||
Con_Printf ("FMOD_System_Create failed!\n"); return 0;}
|
||||
if (FMOD_System_GetVersion (fmod_system, &version)){
|
||||
Con_Printf ("FMOD_System_GetVersion failed!\n"); return 0;}
|
||||
if (FMOD_System_Init (fmod_system, 1, FMOD_INIT_NORMAL, NULL)){
|
||||
Con_Printf ("FMOD_System_Init failed!\n"); return 0; }
|
||||
|
||||
Cmd_AddCommand ("fmod", FmodEx_f);
|
||||
Con_Printf("FmodEx Initialised.\n");
|
||||
fmod_initialised = true;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void FmodEx_Shutdown(void)
|
||||
{
|
||||
FMOD_Sound_Release (fmod_sound);
|
||||
FMOD_System_Close (fmod_system);
|
||||
FMOD_System_Release (fmod_system);
|
||||
Con_Printf("FmodEx Shutdown.\n");
|
||||
}
|
||||
#endif
|
105
tracker/tracker_main.c
Normal file
105
tracker/tracker_main.c
Normal file
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
Copyright (C) 2015 Marco "eukara" Hladik
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
#include "globaldef.h"
|
||||
|
||||
/*
|
||||
* Handle the different forms of music playback systems handled in the engine.
|
||||
* Try to avoid using external libraries for convenience.
|
||||
*/
|
||||
|
||||
void Music_Play(byte track, qboolean looping)
|
||||
{
|
||||
#ifdef DUMB
|
||||
Tracker_Play (track, looping);
|
||||
#elif XMMSCTL
|
||||
XMMS_Play (track, looping);
|
||||
#elif FMOD
|
||||
FmodEx_Play(track, looping);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Music_Stop(void)
|
||||
{
|
||||
#ifdef DUMB
|
||||
Tracker_Stop();
|
||||
#elif XMMSCTL
|
||||
XMMS_Stop();
|
||||
#elif FMOD
|
||||
FmodEx_Stop();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void Music_Pause(void)
|
||||
{
|
||||
#ifdef DUMB
|
||||
Tracker_Pause();
|
||||
#elif XMMSCTL
|
||||
XMMS_Pause();
|
||||
#elif FMOD
|
||||
FmodEx_Pause();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Music_Resume(void)
|
||||
{
|
||||
#ifdef DUMB
|
||||
Tracker_Resume();
|
||||
#elif XMMSCTL
|
||||
XMMS_Resume();
|
||||
#elif FMOD
|
||||
FmodEx_Resume();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Music_Update(void)
|
||||
{
|
||||
#ifdef DUMB
|
||||
Tracker_Update();
|
||||
#elif XMMSCTL
|
||||
XMMS_Update();
|
||||
#elif FMOD
|
||||
FmodEx_Update();
|
||||
#endif
|
||||
}
|
||||
|
||||
int Music_Init(void)
|
||||
{
|
||||
#ifdef DUMB
|
||||
Tracker_Init();
|
||||
#elif XMMSCTL
|
||||
XMMS_Init();
|
||||
#elif FMOD
|
||||
FmodEx_Init();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Music_Shutdown(void)
|
||||
{
|
||||
#ifdef DUMB
|
||||
Tracker_Shutdown();
|
||||
#elif XMMSCTL
|
||||
XMMS_Shutdown();
|
||||
#elif FMOD
|
||||
FmodEx_Shutdown();
|
||||
#endif
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
Copyright (C) 2015 Marco "eukara" Hladik
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
#include "globaldef.h"
|
||||
|
||||
void Tracker_Play(byte track, qboolean looping)
|
||||
{
|
||||
}
|
||||
|
||||
void Tracker_Stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
void Tracker_Pause(void)
|
||||
{
|
||||
}
|
||||
|
||||
void Tracker_Resume(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void Tracker_f (void)
|
||||
{
|
||||
}
|
||||
|
||||
void Tracker_Update(void)
|
||||
{
|
||||
}
|
||||
|
||||
int Tracker_Init(void)
|
||||
{
|
||||
}
|
||||
|
||||
void Tracker_Shutdown(void)
|
||||
{
|
||||
}
|
|
@ -31,6 +31,7 @@ static qboolean xmmsctl_initialized = false;
|
|||
static int xmms_old_repeat;
|
||||
static int xmms_old_shuffle;
|
||||
static int xmms_old_advance;
|
||||
static float xmms_volume;
|
||||
|
||||
int XMMS_GetValue(char *parm)
|
||||
{
|
||||
|
@ -65,6 +66,7 @@ void XMMS_Play(byte track, qboolean looping)
|
|||
xmms_loop = looping == true ? 1 : 0;
|
||||
xmms_track = (int) track;
|
||||
xmms_playing = true;
|
||||
xmms_volume = bgmvolume->value;
|
||||
|
||||
if(xmms_loop)
|
||||
{
|
||||
|
@ -79,6 +81,7 @@ void XMMS_Play(byte track, qboolean looping)
|
|||
system("xmms-ctl -set-repeat");
|
||||
}
|
||||
|
||||
system("xmms-ctl -set-volume %s" xmms_volume);
|
||||
Con_Printf("XMMS: Now playing song %i, looping %i\n", xmms_track, xmms_loop);
|
||||
}
|
||||
|
||||
|
@ -114,6 +117,11 @@ void XMMS_Resume(void)
|
|||
|
||||
void XMMS_Update(void)
|
||||
{
|
||||
if(xmms_volume != bgmvolume->value)
|
||||
{
|
||||
xmms_volume = bgmvolume->value;
|
||||
system("xmms-ctl -set-volume %s" bgmvolume->value);
|
||||
}
|
||||
}
|
||||
|
||||
static void XMMS_f (void)
|
||||
|
@ -127,34 +135,15 @@ static void XMMS_f (void)
|
|||
command = Cmd_Argv (1);
|
||||
|
||||
if (Q_strcasecmp(command, "play") == 0)
|
||||
{
|
||||
XMMS_Play((byte)Q_atoi(Cmd_Argv (2)), false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "stop") == 0)
|
||||
{
|
||||
else if (Q_strcasecmp(command, "stop") == 0)
|
||||
XMMS_Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "pause") == 0)
|
||||
{
|
||||
else if (Q_strcasecmp(command, "pause") == 0)
|
||||
XMMS_Pause();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "resume") == 0)
|
||||
{
|
||||
else if (Q_strcasecmp(command, "resume") == 0)
|
||||
XMMS_Resume();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "quit") == 0)
|
||||
{
|
||||
else if (Q_strcasecmp(command, "quit") == 0)
|
||||
system("xmms-ctl -quit");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int XMMS_Init(void)
|
|
@ -18,6 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
/*
|
||||
* XMMS Music playback for the engine
|
||||
*
|
||||
* Unlike the XMMS-CTL extension, this one actually talks to the player with libxmms, sadly
|
||||
* this will only work with 32bit installations of XMMS which are rather uncommon these days.
|
||||
*/
|
||||
|
||||
#include "globaldef.h"
|
||||
#include <xmms/xmmsctrl.h>
|
||||
|
||||
|
@ -27,6 +34,7 @@ static int xmms_track;
|
|||
|
||||
static qboolean xmms_playing = false;
|
||||
static qboolean xmms_wasplaying = false;
|
||||
static float xmms_volume = 1.0f;
|
||||
|
||||
void Tracker_Play(byte track, qboolean looping)
|
||||
{
|
||||
|
@ -35,6 +43,7 @@ void Tracker_Play(byte track, qboolean looping)
|
|||
xmms_loop = looping == true ? 0 : 1;
|
||||
xmms_track = (int) track;
|
||||
xmms_playing = true;
|
||||
xmms_volume = bgmvolume->value;
|
||||
}
|
||||
|
||||
void Tracker_Stop(void)
|
||||
|
@ -69,6 +78,11 @@ void Tracker_Update(void)
|
|||
if(xmms_remote_get_playlist_pos(xmms_session) != xmms_track)
|
||||
xmms_remote_set_playlist_pos(xmms_session, xmms_track);
|
||||
|
||||
if(xmms_volume != bgmvolume->value)
|
||||
{
|
||||
xmms_volume = bgmvolume->value;
|
||||
xmms_remote_set_main_volume(xmms_session, (int)(xmms_volume * 100));
|
||||
}
|
||||
}
|
||||
|
||||
static void XMMS_f (void)
|
||||
|
@ -82,36 +96,16 @@ static void XMMS_f (void)
|
|||
command = Cmd_Argv (1);
|
||||
|
||||
if (Q_strcasecmp(command, "play") == 0)
|
||||
{
|
||||
Tracker_Play((byte)Q_atoi(Cmd_Argv (2)), false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "stop") == 0)
|
||||
{
|
||||
else if (Q_strcasecmp(command, "stop") == 0)
|
||||
Tracker_Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "pause") == 0)
|
||||
{
|
||||
else if (Q_strcasecmp(command, "pause") == 0)
|
||||
Tracker_Pause();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "resume") == 0)
|
||||
{
|
||||
else if (Q_strcasecmp(command, "resume") == 0)
|
||||
Tracker_Resume();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "quit") == 0)
|
||||
{
|
||||
else if (Q_strcasecmp(command, "quit") == 0)
|
||||
xmms_remote_quit(xmms_session);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "info") == 0)
|
||||
else if (Q_strcasecmp(command, "info") == 0)
|
||||
{
|
||||
Con_Printf("%u tracks\n", xmms_remote_get_playlist_length(xmms_session));
|
||||
if (xmms_playing)
|
||||
|
@ -121,18 +115,19 @@ static void XMMS_f (void)
|
|||
Con_Printf("Volume is %f\n", xmms_remote_get_main_volume(xmms_session));
|
||||
return;
|
||||
}
|
||||
if(Q_strcasecmp(command, "tracks") == 0)
|
||||
else if(Q_strcasecmp(command, "tracks") == 0)
|
||||
for(i = 0; i < xmms_remote_get_playlist_length(xmms_session); i++)
|
||||
Con_Printf("#%i %s\n", i, xmms_remote_get_playlist_title(xmms_session, i));
|
||||
}
|
||||
|
||||
int Tracker_Init(void)
|
||||
{
|
||||
Cmd_AddCommand ("xmms", XMMS_f); // link DUMB
|
||||
Cmd_AddCommand ("xmms", XMMS_f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void Tracker_Shutdown(void)
|
||||
{
|
||||
Tracker_Stop();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue