mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-18 14:41:40 +00:00
- Added writemidi console command. If the currently playing song is a MIDI variant, this will
write it to disk. SVN r3383 (trunk)
This commit is contained in:
parent
d3ad8ca3d8
commit
c3dba9ca9a
3 changed files with 51 additions and 3 deletions
|
@ -830,3 +830,51 @@ CCMD (writewave)
|
|||
Printf ("Usage: writewave <filename> [sample rate]");
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// CCMD writemidi
|
||||
//
|
||||
// If the currently playing song is a MIDI variant, write it to disk.
|
||||
// If successful, the current song will restart, since MIDI file generation
|
||||
// involves a simulated playthrough of the song.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
CCMD (writemidi)
|
||||
{
|
||||
if (argv.argc() != 2)
|
||||
{
|
||||
Printf("Usage: writemidi <filename>");
|
||||
return;
|
||||
}
|
||||
if (currSong == NULL)
|
||||
{
|
||||
Printf("No song is currently playing.\n");
|
||||
return;
|
||||
}
|
||||
if (!currSong->IsMIDI())
|
||||
{
|
||||
Printf("Current song is not MIDI-based.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
TArray<BYTE> midi;
|
||||
FILE *f;
|
||||
bool success;
|
||||
|
||||
static_cast<MIDIStreamer *>(currSong)->CreateSMF(midi, 1);
|
||||
f = fopen(argv[1], "wb");
|
||||
if (f == NULL)
|
||||
{
|
||||
Printf("Could not open %s.\n", argv[1]);
|
||||
return;
|
||||
}
|
||||
success = (fwrite(&midi[0], 1, midi.Size(), f) == (size_t)midi.Size());
|
||||
fclose (f);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
Printf("Could not write to music file.\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -425,7 +425,7 @@ public:
|
|||
void FluidSettingInt(const char *setting, int value);
|
||||
void FluidSettingNum(const char *setting, double value);
|
||||
void FluidSettingStr(const char *setting, const char *value);
|
||||
void CreateSMF(TArray<BYTE> &file);
|
||||
void CreateSMF(TArray<BYTE> &file, int looplimit=0);
|
||||
|
||||
protected:
|
||||
MIDIStreamer(const char *dumpname, EMidiDevice type);
|
||||
|
|
|
@ -1062,14 +1062,14 @@ void MIDIStreamer::Precache()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void MIDIStreamer::CreateSMF(TArray<BYTE> &file)
|
||||
void MIDIStreamer::CreateSMF(TArray<BYTE> &file, int looplimit)
|
||||
{
|
||||
DWORD delay = 0;
|
||||
BYTE running_status = 0;
|
||||
|
||||
// Always create songs aimed at GM devices.
|
||||
CheckCaps(MOD_MIDIPORT);
|
||||
LoopLimit = EXPORT_LOOP_LIMIT;
|
||||
LoopLimit = looplimit <= 0 ? EXPORT_LOOP_LIMIT : looplimit;
|
||||
DoRestart();
|
||||
Tempo = InitialTempo;
|
||||
|
||||
|
|
Loading…
Reference in a new issue