mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-26 13:10:59 +00:00
- ... and the raw OPL format.
This commit is contained in:
parent
dbb4539f4f
commit
dbabc3c0f6
10 changed files with 55 additions and 40 deletions
|
@ -149,7 +149,7 @@ protected:
|
||||||
MIDIDevice *CreateFluidSynthMIDIDevice(int samplerate, const FluidConfig* config, int (*printfunc)(const char*, ...));
|
MIDIDevice *CreateFluidSynthMIDIDevice(int samplerate, const FluidConfig* config, int (*printfunc)(const char*, ...));
|
||||||
MIDIDevice *CreateADLMIDIDevice(const ADLConfig* config);
|
MIDIDevice *CreateADLMIDIDevice(const ADLConfig* config);
|
||||||
MIDIDevice *CreateOPNMIDIDevice(const OpnConfig *args);
|
MIDIDevice *CreateOPNMIDIDevice(const OpnConfig *args);
|
||||||
MIDIDevice *CreateOplMIDIDevice(const OPLMidiConfig* config);
|
MIDIDevice *CreateOplMIDIDevice(const OPLConfig* config);
|
||||||
MIDIDevice *CreateTimidityMIDIDevice(GUSConfig *config, int samplerate);
|
MIDIDevice *CreateTimidityMIDIDevice(GUSConfig *config, int samplerate);
|
||||||
MIDIDevice *CreateTimidityPPMIDIDevice(TimidityConfig *config, int samplerate);
|
MIDIDevice *CreateTimidityPPMIDIDevice(TimidityConfig *config, int samplerate);
|
||||||
MIDIDevice *CreateWildMIDIDevice(WildMidiConfig *config, int samplerate);
|
MIDIDevice *CreateWildMIDIDevice(WildMidiConfig *config, int samplerate);
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
class OPLMIDIDevice : public SoftSynthMIDIDevice, protected OPLmusicBlock
|
class OPLMIDIDevice : public SoftSynthMIDIDevice, protected OPLmusicBlock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OPLMIDIDevice(const OPLMidiConfig *config);
|
OPLMIDIDevice(const OPLConfig *config);
|
||||||
int OpenRenderer();
|
int OpenRenderer();
|
||||||
void Close();
|
void Close();
|
||||||
int GetTechnology() const;
|
int GetTechnology() const;
|
||||||
|
@ -84,7 +84,7 @@ protected:
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
OPLMIDIDevice::OPLMIDIDevice(const OPLMidiConfig *config)
|
OPLMIDIDevice::OPLMIDIDevice(const OPLConfig *config)
|
||||||
: SoftSynthMIDIDevice((int)OPL_SAMPLE_RATE), OPLmusicBlock(config->core, config->numchips)
|
: SoftSynthMIDIDevice((int)OPL_SAMPLE_RATE), OPLmusicBlock(config->core, config->numchips)
|
||||||
{
|
{
|
||||||
FullPan = config->fullpan;
|
FullPan = config->fullpan;
|
||||||
|
@ -314,7 +314,7 @@ std::string OPLMIDIDevice::GetStats()
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
MIDIDevice* CreateOplMIDIDevice(const OPLMidiConfig* config)
|
MIDIDevice* CreateOplMIDIDevice(const OPLConfig* config)
|
||||||
{
|
{
|
||||||
return new OPLMIDIDevice(config);
|
return new OPLMIDIDevice(config);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,12 @@ struct FluidConfig
|
||||||
float fluid_chorus_depth = 8;
|
float fluid_chorus_depth = 8;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OPLMidiConfig
|
struct OPLConfig
|
||||||
{
|
{
|
||||||
int numchips = 2;
|
int numchips = 2;
|
||||||
int core = 0;
|
int core = 0;
|
||||||
bool fullpan = true;
|
bool fullpan = true;
|
||||||
|
bool genmidiset = false;
|
||||||
uint8_t OPLinstruments[36 * 175]; // it really is 'struct GenMidiInstrument OPLinstruments[GENMIDI_NUM_TOTAL]'; but since this is a public header it cannot pull in a dependency from oplsynth.
|
uint8_t OPLinstruments[36 * 175]; // it really is 'struct GenMidiInstrument OPLinstruments[GENMIDI_NUM_TOTAL]'; but since this is a public header it cannot pull in a dependency from oplsynth.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -147,10 +147,9 @@ protected:
|
||||||
virtual bool open(FileReader &reader) = 0;
|
virtual bool open(FileReader &reader) = 0;
|
||||||
friend class SoundRenderer;
|
friend class SoundRenderer;
|
||||||
|
|
||||||
private:
|
|
||||||
// Make non-copyable
|
// Make non-copyable
|
||||||
SoundDecoder(const SoundDecoder &rhs);
|
SoundDecoder(const SoundDecoder &rhs) = delete;
|
||||||
SoundDecoder& operator=(const SoundDecoder &rhs);
|
SoundDecoder& operator=(const SoundDecoder &rhs) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MusInfo;
|
class MusInfo;
|
||||||
|
|
|
@ -457,7 +457,11 @@ MusInfo *I_RegisterSong (FileReader &reader, MidiDeviceSetting *device)
|
||||||
(id[0] == MAKE_ID('D','B','R','A') && id[1] == MAKE_ID('W','O','P','L')) || // DosBox Raw OPL
|
(id[0] == MAKE_ID('D','B','R','A') && id[1] == MAKE_ID('W','O','P','L')) || // DosBox Raw OPL
|
||||||
(id[0] == MAKE_ID('A','D','L','I') && *((uint8_t *)id + 4) == 'B')) // Martin Fernandez's modified IMF
|
(id[0] == MAKE_ID('A','D','L','I') && *((uint8_t *)id + 4) == 'B')) // Martin Fernandez's modified IMF
|
||||||
{
|
{
|
||||||
streamsource = OPL_OpenSong(reader, device != nullptr? device->args.GetChars() : "");
|
OPL_SetupConfig(&oplConfig, device->args.GetChars(), false);
|
||||||
|
auto mreader = new FileReaderMusicInterface(reader);
|
||||||
|
streamsource = OPL_OpenSong(mreader, &oplConfig);
|
||||||
|
reader = mreader->GetReader(); // We need to get this back for the rest of this function.
|
||||||
|
delete mreader;
|
||||||
}
|
}
|
||||||
else if ((id[0] == MAKE_ID('R', 'I', 'F', 'F') && id[2] == MAKE_ID('C', 'D', 'X', 'A')))
|
else if ((id[0] == MAKE_ID('R', 'I', 'F', 'F') && id[2] == MAKE_ID('C', 'D', 'X', 'A')))
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@ class OPLmusicFile;
|
||||||
|
|
||||||
extern ADLConfig adlConfig;
|
extern ADLConfig adlConfig;
|
||||||
extern FluidConfig fluidConfig;
|
extern FluidConfig fluidConfig;
|
||||||
extern OPLMidiConfig oplMidiConfig;
|
extern OPLConfig oplConfig;
|
||||||
extern OpnConfig opnConfig;
|
extern OpnConfig opnConfig;
|
||||||
extern GUSConfig gusConfig;
|
extern GUSConfig gusConfig;
|
||||||
extern TimidityConfig timidityConfig;
|
extern TimidityConfig timidityConfig;
|
||||||
|
@ -141,7 +141,7 @@ public:
|
||||||
|
|
||||||
void Fluid_SetupConfig(FluidConfig *config, const char* patches, bool systemfallback);
|
void Fluid_SetupConfig(FluidConfig *config, const char* patches, bool systemfallback);
|
||||||
void ADL_SetupConfig(ADLConfig *config, const char *Args);
|
void ADL_SetupConfig(ADLConfig *config, const char *Args);
|
||||||
void OPL_SetupConfig(OPLMidiConfig *config, const char *args);
|
void OPL_SetupConfig(OPLConfig *config, const char *args, bool midi = true);
|
||||||
void OPN_SetupConfig(OpnConfig *config, const char *Args);
|
void OPN_SetupConfig(OpnConfig *config, const char *Args);
|
||||||
bool GUS_SetupConfig(GUSConfig *config, const char *args);
|
bool GUS_SetupConfig(GUSConfig *config, const char *args);
|
||||||
bool Timidity_SetupConfig(TimidityConfig* config, const char* args);
|
bool Timidity_SetupConfig(TimidityConfig* config, const char* args);
|
||||||
|
@ -156,7 +156,7 @@ StreamSource *MOD_OpenSong(MusicIO::FileInterface* reader, DumbConfig* config, i
|
||||||
StreamSource* GME_OpenSong(MusicIO::FileInterface* reader, const char* fmt, float stereo_depth, int sample_rate);
|
StreamSource* GME_OpenSong(MusicIO::FileInterface* reader, const char* fmt, float stereo_depth, int sample_rate);
|
||||||
StreamSource *SndFile_OpenSong(FileReader &fr);
|
StreamSource *SndFile_OpenSong(FileReader &fr);
|
||||||
StreamSource* XA_OpenSong(FileReader& reader);
|
StreamSource* XA_OpenSong(FileReader& reader);
|
||||||
StreamSource *OPL_OpenSong(FileReader &reader, const char *args);
|
StreamSource* OPL_OpenSong(MusicIO::FileInterface* reader, OPLConfig *config);
|
||||||
|
|
||||||
// stream song ------------------------------------------
|
// stream song ------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ static void CheckRestart(int devtype)
|
||||||
|
|
||||||
ADLConfig adlConfig;
|
ADLConfig adlConfig;
|
||||||
FluidConfig fluidConfig;
|
FluidConfig fluidConfig;
|
||||||
OPLMidiConfig oplMidiConfig;
|
OPLConfig oplConfig;
|
||||||
OpnConfig opnConfig;
|
OpnConfig opnConfig;
|
||||||
GUSConfig gusConfig;
|
GUSConfig gusConfig;
|
||||||
TimidityConfig timidityConfig;
|
TimidityConfig timidityConfig;
|
||||||
|
@ -477,7 +477,7 @@ CUSTOM_CVAR(Int, opl_numchips, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
{
|
{
|
||||||
if (currSong != NULL)
|
if (currSong != NULL)
|
||||||
currSong->ChangeSettingInt("opl.numchips", self);
|
currSong->ChangeSettingInt("opl.numchips", self);
|
||||||
oplMidiConfig.numchips = self;
|
oplConfig.numchips = self;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,10 +488,13 @@ CUSTOM_CVAR(Int, opl_core, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
|
|
||||||
CUSTOM_CVAR(Bool, opl_fullpan, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
CUSTOM_CVAR(Bool, opl_fullpan, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
{
|
{
|
||||||
oplMidiConfig.fullpan = self;
|
oplConfig.fullpan = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OPL_SetupConfig(OPLMidiConfig *config, const char *args)
|
void OPL_SetupConfig(OPLConfig *config, const char *args, bool midi)
|
||||||
|
{
|
||||||
|
// This needs to be done only once.
|
||||||
|
if (!config->genmidiset && midi)
|
||||||
{
|
{
|
||||||
// The OPL renderer should not care about where this comes from.
|
// The OPL renderer should not care about where this comes from.
|
||||||
// Note: No I_Error here - this needs to be consistent with the rest of the music code.
|
// Note: No I_Error here - this needs to be consistent with the rest of the music code.
|
||||||
|
@ -502,7 +505,9 @@ void OPL_SetupConfig(OPLMidiConfig *config, const char *args)
|
||||||
uint8_t filehdr[8];
|
uint8_t filehdr[8];
|
||||||
data.Read(filehdr, 8);
|
data.Read(filehdr, 8);
|
||||||
if (memcmp(filehdr, "#OPL_II#", 8)) throw std::runtime_error("Corrupt GENMIDI lump");
|
if (memcmp(filehdr, "#OPL_II#", 8)) throw std::runtime_error("Corrupt GENMIDI lump");
|
||||||
data.Read(oplMidiConfig.OPLinstruments, 175 * 36);
|
data.Read(oplConfig.OPLinstruments, 175 * 36);
|
||||||
|
config->genmidiset = true;
|
||||||
|
}
|
||||||
|
|
||||||
config->core = opl_core;
|
config->core = opl_core;
|
||||||
if (args != NULL && *args >= '0' && *args < '4') config->core = *args - '0';
|
if (args != NULL && *args >= '0' && *args < '4') config->core = *args - '0';
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
#include "m_swap.h"
|
#include "m_swap.h"
|
||||||
#include "zmusic/mididefs.h"
|
#include "zmusic/mididefs.h"
|
||||||
#include "zmusic/midiconfig.h"
|
#include "zmusic/midiconfig.h"
|
||||||
#include "../..//libraries/music_common/fileio.h"
|
#include "../../libraries/music_common/fileio.h"
|
||||||
|
|
||||||
// MACROS ------------------------------------------------------------------
|
// MACROS ------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -221,8 +221,8 @@ MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype, int samplerate)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MDEV_OPL:
|
case MDEV_OPL:
|
||||||
OPL_SetupConfig(&oplMidiConfig, Args);
|
OPL_SetupConfig(&oplConfig, Args);
|
||||||
dev = CreateOplMIDIDevice(&oplMidiConfig);
|
dev = CreateOplMIDIDevice(&oplConfig);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MDEV_TIMIDITY:
|
case MDEV_TIMIDITY:
|
||||||
|
|
|
@ -31,13 +31,11 @@
|
||||||
**---------------------------------------------------------------------------
|
**---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "i_musicinterns.h"
|
|
||||||
#include "streamsource.h"
|
#include "streamsource.h"
|
||||||
#include "../libraries/oplsynth/oplsynth/opl.h"
|
#include "../libraries/oplsynth/oplsynth/opl.h"
|
||||||
#include "../libraries/oplsynth/oplsynth/opl_mus_player.h"
|
#include "../libraries/oplsynth/oplsynth/opl_mus_player.h"
|
||||||
|
#include "../libraries/music_common/fileio.h"
|
||||||
EXTERN_CVAR (Int, opl_numchips)
|
#include "zmusic/midiconfig.h"
|
||||||
EXTERN_CVAR(Int, opl_core)
|
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -49,7 +47,7 @@ EXTERN_CVAR(Int, opl_core)
|
||||||
class OPLMUSSong : public StreamSource
|
class OPLMUSSong : public StreamSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OPLMUSSong (FileReader &reader, const char *args);
|
OPLMUSSong (MusicIO::FileInterface *reader, OPLConfig *config);
|
||||||
~OPLMUSSong ();
|
~OPLMUSSong ();
|
||||||
bool Start() override;
|
bool Start() override;
|
||||||
void ChangeSettingInt(const char *name, int value) override;
|
void ChangeSettingInt(const char *name, int value) override;
|
||||||
|
@ -69,12 +67,20 @@ protected:
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
OPLMUSSong::OPLMUSSong (FileReader &reader, const char *args)
|
OPLMUSSong::OPLMUSSong(MusicIO::FileInterface* reader, OPLConfig* config)
|
||||||
{
|
{
|
||||||
current_opl_core = opl_core;
|
const char* error = nullptr;
|
||||||
if (args != NULL && *args >= '0' && *args < '4') current_opl_core = *args - '0';
|
reader->seek(0, SEEK_END);
|
||||||
|
auto fs = reader->tell();
|
||||||
Music = nullptr ;// new OPLmusicFile(reader, current_opl_core);
|
reader->seek(0, SEEK_SET);
|
||||||
|
std::vector<uint8_t> data(fs);
|
||||||
|
reader->read(data.data(), (int)data.size());
|
||||||
|
Music = new OPLmusicFile(data.data(), data.size(), config->core, config->numchips, error);
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
delete Music;
|
||||||
|
throw std::runtime_error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -139,7 +145,7 @@ bool OPLMUSSong::GetData(void *buffer, size_t len)
|
||||||
return Music->ServiceStream(buffer, int(len)) ? len : 0;
|
return Music->ServiceStream(buffer, int(len)) ? len : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamSource *OPL_OpenSong(FileReader &reader, const char *args)
|
StreamSource *OPL_OpenSong(MusicIO::FileInterface* reader, OPLConfig *config)
|
||||||
{
|
{
|
||||||
return new OPLMUSSong(reader, args);
|
return new OPLMUSSong(reader, config);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue