mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-15 08:52:04 +00:00
3a5afd1418
can be played as OPL can also be dumped. - Removed the opl_enable cvar, since OPL playback is now selectable as just another MIDI device. - Added support for DRO playback and dual-chip RAW playback. - Removed MUS support from OPLMUSSong, since using the OPLMIDIDevice with MUSSong2 works just as well. There are still lots of leftover bits in the class that should probably be removed at some point, too. - Added dual-chip dumping support for the RAW format. - Added DosBox Raw OPL (.DRO) dumping support. For whatever reason, in_adlib calculates the song length for this format wrong, even though the exact length is stored right in the header. (But in_adlib seems buggy in general; too bad it's the only Windows version of Adplug that seems to exist.) - Rewrote the OPL dumper to work with MIDI as well as MUS. SVN r872 (trunk)
94 lines
1.9 KiB
C++
94 lines
1.9 KiB
C++
#include "i_musicinterns.h"
|
|
|
|
static bool OPL_Active;
|
|
|
|
CUSTOM_CVAR (Bool, opl_onechip, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|
{
|
|
if (OPL_Active && currSong != NULL)
|
|
{
|
|
static_cast<OPLMUSSong *>(currSong)->ResetChips ();
|
|
}
|
|
}
|
|
|
|
OPLMUSSong::OPLMUSSong (FILE *file, char *musiccache, int len)
|
|
{
|
|
int samples = int(OPL_SAMPLE_RATE / 14);
|
|
|
|
Music = new OPLmusicFile (file, musiccache, len);
|
|
|
|
m_Stream = GSnd->CreateStream (FillStream, samples*4,
|
|
SoundStream::Mono | SoundStream::Float, int(OPL_SAMPLE_RATE), this);
|
|
if (m_Stream == NULL)
|
|
{
|
|
Printf (PRINT_BOLD, "Could not create music stream.\n");
|
|
delete Music;
|
|
return;
|
|
}
|
|
OPL_Active = true;
|
|
}
|
|
|
|
OPLMUSSong::~OPLMUSSong ()
|
|
{
|
|
OPL_Active = false;
|
|
Stop ();
|
|
if (Music != NULL)
|
|
{
|
|
delete Music;
|
|
}
|
|
}
|
|
|
|
bool OPLMUSSong::IsValid () const
|
|
{
|
|
return m_Stream != NULL;
|
|
}
|
|
|
|
void OPLMUSSong::ResetChips ()
|
|
{
|
|
Music->ResetChips ();
|
|
}
|
|
|
|
bool OPLMUSSong::IsPlaying ()
|
|
{
|
|
return m_Status == STATE_Playing;
|
|
}
|
|
|
|
void OPLMUSSong::Play (bool looping)
|
|
{
|
|
m_Status = STATE_Stopped;
|
|
m_Looping = looping;
|
|
|
|
Music->SetLooping (looping);
|
|
Music->Restart ();
|
|
|
|
if (m_Stream == NULL || m_Stream->Play (true, snd_musicvolume, false))
|
|
{
|
|
m_Status = STATE_Playing;
|
|
}
|
|
}
|
|
|
|
bool OPLMUSSong::FillStream (SoundStream *stream, void *buff, int len, void *userdata)
|
|
{
|
|
OPLMUSSong *song = (OPLMUSSong *)userdata;
|
|
return song->Music->ServiceStream (buff, len);
|
|
}
|
|
|
|
MusInfo *OPLMUSSong::GetOPLDumper(const char *filename)
|
|
{
|
|
return new OPLMUSDumper(this, filename);
|
|
}
|
|
|
|
OPLMUSSong::OPLMUSSong(const OPLMUSSong *original, const char *filename)
|
|
{
|
|
Music = new OPLmusicFile(original->Music, filename);
|
|
m_Stream = NULL;
|
|
}
|
|
|
|
OPLMUSDumper::OPLMUSDumper(const OPLMUSSong *original, const char *filename)
|
|
: OPLMUSSong(original, filename)
|
|
{
|
|
}
|
|
|
|
void OPLMUSDumper::Play(bool looping)
|
|
{
|
|
Music->Dump();
|
|
}
|