mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-17 17:11:19 +00:00
- a bit of cleanup - moving internal class declarations into the sources.
Now i_musicinterns.h doesn't bleed the entire implementation everywhere anymore.
This commit is contained in:
parent
b9b706e951
commit
d06ec56c2e
5 changed files with 148 additions and 149 deletions
|
@ -359,10 +359,6 @@ void MusInfo::MusicVolumeChanged()
|
|||
{
|
||||
}
|
||||
|
||||
void MusInfo::GMEDepthChanged(float val)
|
||||
{
|
||||
}
|
||||
|
||||
void MusInfo::ChangeSettingInt(const char *, int)
|
||||
{
|
||||
}
|
||||
|
@ -386,18 +382,6 @@ MusInfo *MusInfo::GetWaveDumper(const char *filename, int rate)
|
|||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// create a streamer
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
static MIDIStreamer *CreateMIDIStreamer(EMidiDevice devtype, const char *args)
|
||||
{
|
||||
auto me = new MIDIStreamer(devtype, args);
|
||||
return me;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// identify a music lump's type and set up a player for it
|
||||
|
@ -474,15 +458,7 @@ MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, MidiDeviceSetting *devi
|
|||
devtype = MDEV_SNDSYS;
|
||||
#endif
|
||||
|
||||
MIDIStreamer* streamer = CreateMIDIStreamer(devtype, device != nullptr ? device->args.GetChars() : "");
|
||||
if (streamer == nullptr)
|
||||
{
|
||||
delete source;
|
||||
reader->close();
|
||||
return nullptr;
|
||||
}
|
||||
streamer->SetMIDISource(source);
|
||||
info = streamer;
|
||||
info = CreateMIDIStreamer(source, devtype, device != nullptr ? device->args.GetChars() : "");
|
||||
}
|
||||
|
||||
// Check for CDDA "format"
|
||||
|
@ -498,7 +474,7 @@ MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, MidiDeviceSetting *devi
|
|||
if (subid == (('C') | (('D') << 8) | (('D') << 16) | (('A') << 24)))
|
||||
{
|
||||
// This is a CDDA file
|
||||
info = new CDDAFile(reader);
|
||||
info = CDDA_OpenSong(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -571,7 +547,7 @@ MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, MidiDeviceSetting *devi
|
|||
|
||||
MusInfo *I_RegisterCDSong (int track, int id)
|
||||
{
|
||||
MusInfo *info = new CDSong (track, id);
|
||||
MusInfo *info = CD_OpenSong (track, id);
|
||||
|
||||
if (info && !info->IsValid ())
|
||||
{
|
||||
|
@ -804,9 +780,7 @@ UNSAFE_CCMD (writewave)
|
|||
if (dev == MDEV_DEFAULT && snd_mididevice >= 0) dev = MDEV_FLUIDSYNTH; // The Windows system synth cannot dump a wave.
|
||||
try
|
||||
{
|
||||
MIDIStreamer streamer(dev, argv.argc() < 6 ? nullptr : argv[6]);
|
||||
streamer.SetMIDISource(source);
|
||||
streamer.DumpWave(argv[2], argv.argc() < 4 ? 0 : (int)strtol(argv[3], nullptr, 10), argv.argc() < 5 ? 0 : (int)strtol(argv[4], nullptr, 10));
|
||||
MIDIDumpWave(source, dev, argv.argc() < 6 ? nullptr : argv[6], argv[2], argv.argc() < 4 ? 0 : (int)strtol(argv[3], nullptr, 10), argv.argc() < 5 ? 0 : (int)strtol(argv[4], nullptr, 10));
|
||||
}
|
||||
catch (const std::runtime_error& err)
|
||||
{
|
||||
|
|
|
@ -82,7 +82,6 @@ public:
|
|||
virtual void ChangeSettingInt(const char *setting, int value); // FluidSynth settings
|
||||
virtual void ChangeSettingNum(const char *setting, double value); // "
|
||||
virtual void ChangeSettingString(const char *setting, const char *value); // "
|
||||
virtual void GMEDepthChanged(float val);
|
||||
|
||||
void Start(bool loop, float rel_vol = -1.f, int subsong = 0);
|
||||
|
||||
|
|
|
@ -19,123 +19,6 @@ class MIDIDevice;
|
|||
class OPLmusicFile;
|
||||
|
||||
|
||||
extern FluidConfig fluidConfig;
|
||||
extern OPLConfig oplConfig;
|
||||
extern OpnConfig opnConfig;
|
||||
extern GUSConfig gusConfig;
|
||||
extern TimidityConfig timidityConfig;
|
||||
extern WildMidiConfig wildMidiConfig;
|
||||
extern DumbConfig dumbConfig;
|
||||
|
||||
|
||||
class MIDIStreamer;
|
||||
|
||||
// Base class for streaming MUS and MIDI files ------------------------------
|
||||
|
||||
class MIDIStreamer : public MusInfo
|
||||
{
|
||||
public:
|
||||
MIDIStreamer(EMidiDevice type, const char *args);
|
||||
~MIDIStreamer();
|
||||
|
||||
void MusicVolumeChanged() override;
|
||||
void Play(bool looping, int subsong) override;
|
||||
void Pause() override;
|
||||
void Resume() override;
|
||||
void Stop() override;
|
||||
bool IsPlaying() override;
|
||||
bool IsMIDI() const override;
|
||||
bool IsValid() const override;
|
||||
bool SetSubsong(int subsong) override;
|
||||
void Update() override;
|
||||
FString GetStats() override;
|
||||
void ChangeSettingInt(const char *setting, int value) override;
|
||||
void ChangeSettingNum(const char *setting, double value) override;
|
||||
void ChangeSettingString(const char *setting, const char *value) override;
|
||||
int ServiceEvent();
|
||||
void SetMIDISource(MIDISource *_source);
|
||||
|
||||
int GetDeviceType() const override;
|
||||
|
||||
bool DumpWave(const char *filename, int subsong, int samplerate);
|
||||
static bool FillStream(SoundStream* stream, void* buff, int len, void* userdata);
|
||||
|
||||
|
||||
protected:
|
||||
MIDIStreamer(const char *dumpname, EMidiDevice type);
|
||||
|
||||
void OutputVolume (uint32_t volume);
|
||||
int FillBuffer(int buffer_num, int max_events, uint32_t max_time);
|
||||
int FillStopBuffer(int buffer_num);
|
||||
uint32_t *WriteStopNotes(uint32_t *events);
|
||||
int VolumeControllerChange(int channel, int volume);
|
||||
void SetTempo(int new_tempo);
|
||||
void Precache();
|
||||
void StartPlayback();
|
||||
bool InitPlayback();
|
||||
|
||||
//void SetMidiSynth(MIDIDevice *synth);
|
||||
|
||||
|
||||
static EMidiDevice SelectMIDIDevice(EMidiDevice devtype);
|
||||
MIDIDevice *CreateMIDIDevice(EMidiDevice devtype, int samplerate);
|
||||
|
||||
static void Callback(void *userdata);
|
||||
|
||||
enum
|
||||
{
|
||||
SONG_MORE,
|
||||
SONG_DONE,
|
||||
SONG_ERROR
|
||||
};
|
||||
|
||||
std::unique_ptr<MIDIDevice> MIDI;
|
||||
uint32_t Events[2][MAX_MIDI_EVENTS*3];
|
||||
MidiHeader Buffer[2];
|
||||
int BufferNum;
|
||||
int EndQueued;
|
||||
bool VolumeChanged;
|
||||
bool Restarting;
|
||||
bool InitialPlayback;
|
||||
uint32_t NewVolume;
|
||||
uint32_t Volume;
|
||||
EMidiDevice DeviceType;
|
||||
bool CallbackIsThreaded;
|
||||
int LoopLimit;
|
||||
FString Args;
|
||||
std::unique_ptr<MIDISource> source;
|
||||
std::unique_ptr<SoundStream> Stream;
|
||||
};
|
||||
|
||||
// CD track/disk played through the multimedia system -----------------------
|
||||
|
||||
class CDSong : public MusInfo
|
||||
{
|
||||
public:
|
||||
CDSong (int track, int id);
|
||||
~CDSong ();
|
||||
void Play (bool looping, int subsong);
|
||||
void Pause ();
|
||||
void Resume ();
|
||||
void Stop ();
|
||||
bool IsPlaying ();
|
||||
bool IsValid () const { return m_Inited; }
|
||||
|
||||
protected:
|
||||
CDSong () : m_Inited(false) {}
|
||||
|
||||
int m_Track;
|
||||
bool m_Inited;
|
||||
};
|
||||
|
||||
// CD track on a specific disk played through the multimedia system ---------
|
||||
|
||||
class CDDAFile : public CDSong
|
||||
{
|
||||
public:
|
||||
CDDAFile (MusicIO::FileInterface *reader);
|
||||
};
|
||||
|
||||
// Data interface
|
||||
|
||||
// Module played via foo_dumb -----------------------------------------------
|
||||
|
@ -145,8 +28,11 @@ class StreamSource;
|
|||
// stream song ------------------------------------------
|
||||
|
||||
MusInfo *OpenStreamSong(StreamSource *source);
|
||||
|
||||
const char *GME_CheckFormat(uint32_t header);
|
||||
MusInfo* CDDA_OpenSong(MusicIO::FileInterface* reader);
|
||||
MusInfo* CD_OpenSong(int track, int id);
|
||||
MusInfo* CreateMIDIStreamer(MIDISource *source, EMidiDevice devtype, const char* args);
|
||||
void MIDIDumpWave(MIDISource* source, EMidiDevice devtype, const char* devarg, const char* outname, int subsong, int samplerate);
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -34,6 +34,38 @@
|
|||
#include "i_musicinterns.h"
|
||||
#include "i_cd.h"
|
||||
|
||||
|
||||
// CD track/disk played through the multimedia system -----------------------
|
||||
|
||||
class CDSong : public MusInfo
|
||||
{
|
||||
public:
|
||||
CDSong(int track, int id);
|
||||
~CDSong();
|
||||
void Play(bool looping, int subsong);
|
||||
void Pause();
|
||||
void Resume();
|
||||
void Stop();
|
||||
bool IsPlaying();
|
||||
bool IsValid() const { return m_Inited; }
|
||||
|
||||
protected:
|
||||
CDSong() : m_Inited(false) {}
|
||||
|
||||
int m_Track;
|
||||
bool m_Inited;
|
||||
};
|
||||
|
||||
// CD track on a specific disk played through the multimedia system ---------
|
||||
|
||||
class CDDAFile : public CDSong
|
||||
{
|
||||
public:
|
||||
CDDAFile(MusicIO::FileInterface* reader);
|
||||
};
|
||||
|
||||
|
||||
|
||||
void CDSong::Play (bool looping, int subsong)
|
||||
{
|
||||
m_Status = STATE_Stopped;
|
||||
|
@ -146,3 +178,13 @@ CDDAFile::CDDAFile (MusicIO::FileInterface* reader)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
MusInfo* CD_OpenSong(int track, int id)
|
||||
{
|
||||
return new CDSong(track, id);
|
||||
}
|
||||
|
||||
MusInfo* CDDA_OpenSong(MusicIO::FileInterface* reader)
|
||||
{
|
||||
return new CDDAFile(reader);
|
||||
}
|
|
@ -68,6 +68,84 @@ extern unsigned mididevice;
|
|||
|
||||
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
||||
|
||||
// Base class for streaming MUS and MIDI files ------------------------------
|
||||
|
||||
class MIDIStreamer : public MusInfo
|
||||
{
|
||||
public:
|
||||
MIDIStreamer(EMidiDevice type, const char* args);
|
||||
~MIDIStreamer();
|
||||
|
||||
void MusicVolumeChanged() override;
|
||||
void Play(bool looping, int subsong) override;
|
||||
void Pause() override;
|
||||
void Resume() override;
|
||||
void Stop() override;
|
||||
bool IsPlaying() override;
|
||||
bool IsMIDI() const override;
|
||||
bool IsValid() const override;
|
||||
bool SetSubsong(int subsong) override;
|
||||
void Update() override;
|
||||
FString GetStats() override;
|
||||
void ChangeSettingInt(const char* setting, int value) override;
|
||||
void ChangeSettingNum(const char* setting, double value) override;
|
||||
void ChangeSettingString(const char* setting, const char* value) override;
|
||||
int ServiceEvent();
|
||||
void SetMIDISource(MIDISource* _source);
|
||||
|
||||
int GetDeviceType() const override;
|
||||
|
||||
bool DumpWave(const char* filename, int subsong, int samplerate);
|
||||
static bool FillStream(SoundStream* stream, void* buff, int len, void* userdata);
|
||||
|
||||
|
||||
protected:
|
||||
MIDIStreamer(const char* dumpname, EMidiDevice type);
|
||||
|
||||
void OutputVolume(uint32_t volume);
|
||||
int FillBuffer(int buffer_num, int max_events, uint32_t max_time);
|
||||
int FillStopBuffer(int buffer_num);
|
||||
uint32_t* WriteStopNotes(uint32_t* events);
|
||||
int VolumeControllerChange(int channel, int volume);
|
||||
void SetTempo(int new_tempo);
|
||||
void Precache();
|
||||
void StartPlayback();
|
||||
bool InitPlayback();
|
||||
|
||||
//void SetMidiSynth(MIDIDevice *synth);
|
||||
|
||||
|
||||
static EMidiDevice SelectMIDIDevice(EMidiDevice devtype);
|
||||
MIDIDevice* CreateMIDIDevice(EMidiDevice devtype, int samplerate);
|
||||
|
||||
static void Callback(void* userdata);
|
||||
|
||||
enum
|
||||
{
|
||||
SONG_MORE,
|
||||
SONG_DONE,
|
||||
SONG_ERROR
|
||||
};
|
||||
|
||||
std::unique_ptr<MIDIDevice> MIDI;
|
||||
uint32_t Events[2][MAX_MIDI_EVENTS * 3];
|
||||
MidiHeader Buffer[2];
|
||||
int BufferNum;
|
||||
int EndQueued;
|
||||
bool VolumeChanged;
|
||||
bool Restarting;
|
||||
bool InitialPlayback;
|
||||
uint32_t NewVolume;
|
||||
uint32_t Volume;
|
||||
EMidiDevice DeviceType;
|
||||
bool CallbackIsThreaded;
|
||||
int LoopLimit;
|
||||
FString Args;
|
||||
std::unique_ptr<MIDISource> source;
|
||||
std::unique_ptr<SoundStream> Stream;
|
||||
};
|
||||
|
||||
|
||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||
|
||||
// CODE --------------------------------------------------------------------
|
||||
|
@ -934,3 +1012,23 @@ bool MIDIStreamer::FillStream(SoundStream* stream, void* buff, int len, void* us
|
|||
SoftSynthMIDIDevice* device = (SoftSynthMIDIDevice*)userdata;
|
||||
return device->ServiceStream(buff, len);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// create a streamer
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
MusInfo* CreateMIDIStreamer(MIDISource *source, EMidiDevice devtype, const char* args)
|
||||
{
|
||||
auto me = new MIDIStreamer(devtype, args);
|
||||
me->SetMIDISource(source);
|
||||
return me;
|
||||
}
|
||||
|
||||
void MIDIDumpWave(MIDISource* source, EMidiDevice devtype, const char *devarg, const char *outname, int subsong, int samplerate)
|
||||
{
|
||||
MIDIStreamer me(devtype, devarg);
|
||||
me.SetMIDISource(source);
|
||||
me.DumpWave(outname, subsong, samplerate);
|
||||
}
|
Loading…
Reference in a new issue