mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +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 *CreateADLMIDIDevice(const ADLConfig* config);
|
||||
MIDIDevice *CreateOPNMIDIDevice(const OpnConfig *args);
|
||||
MIDIDevice *CreateOplMIDIDevice(const OPLMidiConfig* config);
|
||||
MIDIDevice *CreateOplMIDIDevice(const OPLConfig* config);
|
||||
MIDIDevice *CreateTimidityMIDIDevice(GUSConfig *config, int samplerate);
|
||||
MIDIDevice *CreateTimidityPPMIDIDevice(TimidityConfig *config, int samplerate);
|
||||
MIDIDevice *CreateWildMIDIDevice(WildMidiConfig *config, int samplerate);
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
class OPLMIDIDevice : public SoftSynthMIDIDevice, protected OPLmusicBlock
|
||||
{
|
||||
public:
|
||||
OPLMIDIDevice(const OPLMidiConfig *config);
|
||||
OPLMIDIDevice(const OPLConfig *config);
|
||||
int OpenRenderer();
|
||||
void Close();
|
||||
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)
|
||||
{
|
||||
FullPan = config->fullpan;
|
||||
|
@ -314,7 +314,7 @@ std::string OPLMIDIDevice::GetStats()
|
|||
return out;
|
||||
}
|
||||
|
||||
MIDIDevice* CreateOplMIDIDevice(const OPLMidiConfig* config)
|
||||
MIDIDevice* CreateOplMIDIDevice(const OPLConfig* config)
|
||||
{
|
||||
return new OPLMIDIDevice(config);
|
||||
}
|
||||
|
|
|
@ -38,11 +38,12 @@ struct FluidConfig
|
|||
float fluid_chorus_depth = 8;
|
||||
};
|
||||
|
||||
struct OPLMidiConfig
|
||||
struct OPLConfig
|
||||
{
|
||||
int numchips = 2;
|
||||
int core = 0;
|
||||
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.
|
||||
};
|
||||
|
||||
|
|
|
@ -147,10 +147,9 @@ protected:
|
|||
virtual bool open(FileReader &reader) = 0;
|
||||
friend class SoundRenderer;
|
||||
|
||||
private:
|
||||
// Make non-copyable
|
||||
SoundDecoder(const SoundDecoder &rhs);
|
||||
SoundDecoder& operator=(const SoundDecoder &rhs);
|
||||
SoundDecoder(const SoundDecoder &rhs) = delete;
|
||||
SoundDecoder& operator=(const SoundDecoder &rhs) = delete;
|
||||
};
|
||||
|
||||
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('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')))
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ class OPLmusicFile;
|
|||
|
||||
extern ADLConfig adlConfig;
|
||||
extern FluidConfig fluidConfig;
|
||||
extern OPLMidiConfig oplMidiConfig;
|
||||
extern OPLConfig oplConfig;
|
||||
extern OpnConfig opnConfig;
|
||||
extern GUSConfig gusConfig;
|
||||
extern TimidityConfig timidityConfig;
|
||||
|
@ -141,7 +141,7 @@ public:
|
|||
|
||||
void Fluid_SetupConfig(FluidConfig *config, const char* patches, bool systemfallback);
|
||||
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);
|
||||
bool GUS_SetupConfig(GUSConfig *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 *SndFile_OpenSong(FileReader &fr);
|
||||
StreamSource* XA_OpenSong(FileReader& reader);
|
||||
StreamSource *OPL_OpenSong(FileReader &reader, const char *args);
|
||||
StreamSource* OPL_OpenSong(MusicIO::FileInterface* reader, OPLConfig *config);
|
||||
|
||||
// stream song ------------------------------------------
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ static void CheckRestart(int devtype)
|
|||
|
||||
ADLConfig adlConfig;
|
||||
FluidConfig fluidConfig;
|
||||
OPLMidiConfig oplMidiConfig;
|
||||
OPLConfig oplConfig;
|
||||
OpnConfig opnConfig;
|
||||
GUSConfig gusConfig;
|
||||
TimidityConfig timidityConfig;
|
||||
|
@ -477,7 +477,7 @@ CUSTOM_CVAR(Int, opl_numchips, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
|||
{
|
||||
if (currSong != NULL)
|
||||
currSong->ChangeSettingInt("opl.numchips", self);
|
||||
oplMidiConfig.numchips = self;
|
||||
oplConfig.numchips = self;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -488,21 +488,26 @@ CUSTOM_CVAR(Int, opl_core, 0, 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)
|
||||
{
|
||||
// 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.
|
||||
auto lump = Wads.CheckNumForName("GENMIDI", ns_global);
|
||||
if (lump < 0) throw std::runtime_error("No GENMIDI lump found");
|
||||
auto data = Wads.OpenLumpReader(lump);
|
||||
// This needs to be done only once.
|
||||
if (!config->genmidiset && midi)
|
||||
{
|
||||
// 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.
|
||||
auto lump = Wads.CheckNumForName("GENMIDI", ns_global);
|
||||
if (lump < 0) throw std::runtime_error("No GENMIDI lump found");
|
||||
auto data = Wads.OpenLumpReader(lump);
|
||||
|
||||
uint8_t filehdr[8];
|
||||
data.Read(filehdr, 8);
|
||||
if (memcmp(filehdr, "#OPL_II#", 8)) throw std::runtime_error("Corrupt GENMIDI lump");
|
||||
data.Read(oplMidiConfig.OPLinstruments, 175 * 36);
|
||||
uint8_t filehdr[8];
|
||||
data.Read(filehdr, 8);
|
||||
if (memcmp(filehdr, "#OPL_II#", 8)) throw std::runtime_error("Corrupt GENMIDI lump");
|
||||
data.Read(oplConfig.OPLinstruments, 175 * 36);
|
||||
config->genmidiset = true;
|
||||
}
|
||||
|
||||
config->core = opl_core;
|
||||
if (args != NULL && *args >= '0' && *args < '4') config->core = *args - '0';
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include "m_swap.h"
|
||||
#include "zmusic/mididefs.h"
|
||||
#include "zmusic/midiconfig.h"
|
||||
#include "../..//libraries/music_common/fileio.h"
|
||||
#include "../../libraries/music_common/fileio.h"
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -221,8 +221,8 @@ MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype, int samplerate)
|
|||
break;
|
||||
|
||||
case MDEV_OPL:
|
||||
OPL_SetupConfig(&oplMidiConfig, Args);
|
||||
dev = CreateOplMIDIDevice(&oplMidiConfig);
|
||||
OPL_SetupConfig(&oplConfig, Args);
|
||||
dev = CreateOplMIDIDevice(&oplConfig);
|
||||
break;
|
||||
|
||||
case MDEV_TIMIDITY:
|
||||
|
|
|
@ -31,13 +31,11 @@
|
|||
**---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "i_musicinterns.h"
|
||||
#include "streamsource.h"
|
||||
#include "../libraries/oplsynth/oplsynth/opl.h"
|
||||
#include "../libraries/oplsynth/oplsynth/opl_mus_player.h"
|
||||
|
||||
EXTERN_CVAR (Int, opl_numchips)
|
||||
EXTERN_CVAR(Int, opl_core)
|
||||
#include "../libraries/music_common/fileio.h"
|
||||
#include "zmusic/midiconfig.h"
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
@ -49,7 +47,7 @@ EXTERN_CVAR(Int, opl_core)
|
|||
class OPLMUSSong : public StreamSource
|
||||
{
|
||||
public:
|
||||
OPLMUSSong (FileReader &reader, const char *args);
|
||||
OPLMUSSong (MusicIO::FileInterface *reader, OPLConfig *config);
|
||||
~OPLMUSSong ();
|
||||
bool Start() 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;
|
||||
if (args != NULL && *args >= '0' && *args < '4') current_opl_core = *args - '0';
|
||||
|
||||
Music = nullptr ;// new OPLmusicFile(reader, current_opl_core);
|
||||
const char* error = nullptr;
|
||||
reader->seek(0, SEEK_END);
|
||||
auto fs = reader->tell();
|
||||
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;
|
||||
}
|
||||
|
||||
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