mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-28 09:50:42 +00:00
d6e52ed526
This shitcans the SDL_mixer requirement but leaves platforms other than Windows without built-in MIDI playback capability until Nuke.YKT's OPL3 emulator is merged. This also reworks sdlmusic.cpp into music_external.cpp, including an untested port of the code to Windows. git-svn-id: https://svn.eduke32.com/eduke32@8214 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # GNUmakefile # platform/Windows/eduke32.vcxproj # platform/Windows/props/build_common.props # source/audiolib/src/sdlmusic.cpp # Conflicts: # Common.mak # GNUmakefile # platform/Windows/audiolib.vcxproj # platform/Windows/eduke32.vcxproj # platform/Windows/eduke32.vcxproj.filters # platform/Windows/props/build_common.props # source/audiolib/src/driver_sdl.cpp # source/audiolib/src/sdlmusic.cpp # source/build/include/vfs.h # source/build/include/winbits.h # source/build/src/winbits.cpp
109 lines
2.8 KiB
C++
109 lines
2.8 KiB
C++
//-------------------------------------------------------------------------
|
|
/*
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
Copyright (C) 2019 Nuke.YKT
|
|
|
|
This file is part of NBlood.
|
|
|
|
NBlood is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License version 2
|
|
as published by the Free Software Foundation.
|
|
|
|
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
//-------------------------------------------------------------------------
|
|
|
|
// This object is shared by all Build games with MIDI playback!
|
|
|
|
#include "compat.h"
|
|
#include "music.h"
|
|
#include "midi.h"
|
|
#include "mpu401.h"
|
|
|
|
int32_t MUSIC_SoundDevice = -1;
|
|
int32_t MUSIC_ErrorCode = MUSIC_Ok;
|
|
char const *errorMessage;
|
|
static midifuncs MUSIC_MidiFunctions;
|
|
|
|
int32_t MUSIC_InitMidi(int32_t card, midifuncs *Funcs, int32_t Address);
|
|
|
|
|
|
int32_t MUSIC_Init(int32_t SoundCard, int32_t Address)
|
|
{
|
|
MUSIC_SoundDevice = SoundCard;
|
|
|
|
return MUSIC_InitMidi(SoundCard, &MUSIC_MidiFunctions, Address);
|
|
}
|
|
|
|
|
|
int32_t MUSIC_Shutdown(void)
|
|
{
|
|
MIDI_StopSong();
|
|
|
|
return MUSIC_Ok;
|
|
}
|
|
|
|
|
|
void MUSIC_SetVolume(int32_t volume)
|
|
{
|
|
if (MUSIC_SoundDevice != -1)
|
|
MIDI_SetVolume(min(max(0, volume), 255));
|
|
}
|
|
|
|
|
|
int32_t MUSIC_GetVolume(void) { return MUSIC_SoundDevice == -1 ? 0 : MIDI_GetVolume(); }
|
|
void MUSIC_SetLoopFlag(int32_t loopflag) { MIDI_SetLoopFlag(loopflag); }
|
|
void MUSIC_Continue(void) { MIDI_ContinueSong(); }
|
|
void MUSIC_Pause(void) { MIDI_PauseSong(); }
|
|
|
|
int32_t MUSIC_StopSong(void)
|
|
{
|
|
MIDI_StopSong();
|
|
MUSIC_SetErrorCode(MUSIC_Ok);
|
|
return MUSIC_Ok;
|
|
}
|
|
|
|
|
|
int32_t MUSIC_PlaySong(char *song, int32_t songsize, int32_t loopflag, const char *fn /*= nullptr*/)
|
|
{
|
|
UNREFERENCED_PARAMETER(songsize);
|
|
UNREFERENCED_PARAMETER(fn);
|
|
|
|
MUSIC_SetErrorCode(MUSIC_Ok)
|
|
|
|
if (MIDI_PlaySong(song, loopflag) != MIDI_Ok)
|
|
{
|
|
MUSIC_SetErrorCode(MUSIC_FileError);
|
|
return MUSIC_Error;
|
|
}
|
|
|
|
return MUSIC_Ok;
|
|
}
|
|
|
|
|
|
int32_t MUSIC_InitMidi(int32_t card, midifuncs *Funcs, int32_t Address)
|
|
{
|
|
UNREFERENCED_PARAMETER(card);
|
|
UNREFERENCED_PARAMETER(Address);
|
|
Funcs->NoteOff = MPU_NoteOff;
|
|
Funcs->NoteOn = MPU_NoteOn;
|
|
Funcs->PolyAftertouch = MPU_PolyAftertouch;
|
|
Funcs->ControlChange = MPU_ControlChange;
|
|
Funcs->ProgramChange = MPU_ProgramChange;
|
|
Funcs->ChannelAftertouch = MPU_ChannelAftertouch;
|
|
Funcs->PitchBend = MPU_PitchBend;
|
|
|
|
MIDI_SetMidiFuncs(Funcs);
|
|
|
|
return MIDI_Ok;
|
|
}
|
|
|
|
void MUSIC_Update(void) { MIDI_UpdateMusic(); }
|