mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-29 15:32:54 +00:00
- XA, too.
This commit is contained in:
parent
dbabc3c0f6
commit
b883d27a1f
3 changed files with 20 additions and 14 deletions
|
@ -465,7 +465,8 @@ MusInfo *I_RegisterSong (FileReader &reader, MidiDeviceSetting *device)
|
||||||
}
|
}
|
||||||
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')))
|
||||||
{
|
{
|
||||||
streamsource = XA_OpenSong(reader);
|
auto mreader = new FileReaderMusicInterface(reader);
|
||||||
|
streamsource = XA_OpenSong(mreader); // this takes over the reader.
|
||||||
}
|
}
|
||||||
// Check for game music
|
// Check for game music
|
||||||
else if ((fmt = GME_CheckFormat(id[0])) != nullptr && fmt[0] != '\0')
|
else if ((fmt = GME_CheckFormat(id[0])) != nullptr && fmt[0] != '\0')
|
||||||
|
|
|
@ -155,7 +155,7 @@ class StreamSource;
|
||||||
StreamSource *MOD_OpenSong(MusicIO::FileInterface* reader, DumbConfig* config, int samplerate);
|
StreamSource *MOD_OpenSong(MusicIO::FileInterface* reader, DumbConfig* config, int samplerate);
|
||||||
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(MusicIO::FileInterface* reader);
|
||||||
StreamSource* OPL_OpenSong(MusicIO::FileInterface* reader, OPLConfig *config);
|
StreamSource* OPL_OpenSong(MusicIO::FileInterface* reader, OPLConfig *config);
|
||||||
|
|
||||||
// stream song ------------------------------------------
|
// stream song ------------------------------------------
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "i_musicinterns.h"
|
|
||||||
#include "streamsource.h"
|
#include "streamsource.h"
|
||||||
|
#include "../libraries/music_common/fileio.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PlayStation XA (ADPCM) source support for MultiVoc
|
* PlayStation XA (ADPCM) source support for MultiVoc
|
||||||
* Adapted and remixed from superxa2wav
|
* Adapted and remixed from superxa2wav
|
||||||
|
@ -27,8 +28,9 @@ XA_DATA_START = (0x44-48)
|
||||||
inline float constexpr DblToPCMF(double dt) { return float(dt) * (1.f/32768.f); }
|
inline float constexpr DblToPCMF(double dt) { return float(dt) * (1.f/32768.f); }
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FileReader reader;
|
MusicIO::FileInterface *reader;
|
||||||
size_t committed;
|
size_t committed;
|
||||||
|
size_t length;
|
||||||
bool blockIsMono;
|
bool blockIsMono;
|
||||||
bool blockIs18K;
|
bool blockIs18K;
|
||||||
bool finished;
|
bool finished;
|
||||||
|
@ -184,12 +186,12 @@ static void getNextXABlock(xa_data *xad, bool looping )
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
size_t bytes = xad->reader.GetLength() - xad->reader.Tell();
|
size_t bytes = xad->length - xad->reader->tell();
|
||||||
|
|
||||||
if (sizeof(XASector) < bytes)
|
if (sizeof(XASector) < bytes)
|
||||||
bytes = sizeof(XASector);
|
bytes = sizeof(XASector);
|
||||||
|
|
||||||
xad->reader.Read(&ssct, bytes);
|
xad->reader->read(&ssct, (int)bytes);
|
||||||
}
|
}
|
||||||
while (ssct.sectorFiller[46] != (SUBMODE_REAL_TIME_SECTOR | SUBMODE_FORM | SUBMODE_AUDIO_DATA));
|
while (ssct.sectorFiller[46] != (SUBMODE_REAL_TIME_SECTOR | SUBMODE_FORM | SUBMODE_AUDIO_DATA));
|
||||||
|
|
||||||
|
@ -208,11 +210,11 @@ static void getNextXABlock(xa_data *xad, bool looping )
|
||||||
decodeSoundSectMono(&ssct, xad);
|
decodeSoundSectMono(&ssct, xad);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xad->reader.GetLength() == xad->reader.Tell())
|
if (xad->length == xad->reader->tell())
|
||||||
{
|
{
|
||||||
if (looping)
|
if (looping)
|
||||||
{
|
{
|
||||||
xad->reader.Seek(XA_DATA_START, FileReader::SeekSet);
|
xad->reader->seek(XA_DATA_START, SEEK_SET);
|
||||||
xad->t1 = xad->t2 = xad->t1_x = xad->t2_x = 0;
|
xad->t1 = xad->t2 = xad->t1_x = xad->t2_x = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -231,7 +233,7 @@ static void getNextXABlock(xa_data *xad, bool looping )
|
||||||
class XASong : public StreamSource
|
class XASong : public StreamSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XASong(FileReader & readr);
|
XASong(MusicIO::FileInterface *readr);
|
||||||
SoundStreamInfo GetFormat() override;
|
SoundStreamInfo GetFormat() override;
|
||||||
bool Start() override;
|
bool Start() override;
|
||||||
bool GetData(void *buffer, size_t len) override;
|
bool GetData(void *buffer, size_t len) override;
|
||||||
|
@ -246,11 +248,14 @@ protected:
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
XASong::XASong(FileReader &reader)
|
XASong::XASong(MusicIO::FileInterface * reader)
|
||||||
{
|
{
|
||||||
reader.Seek(XA_DATA_START, FileReader::SeekSet);
|
reader->seek(0, SEEK_END);
|
||||||
xad.reader = std::move(reader);
|
xad.length = reader->tell();
|
||||||
|
reader->seek(XA_DATA_START, SEEK_SET);
|
||||||
|
xad.reader = reader;
|
||||||
xad.t1 = xad.t2 = xad.t1_x = xad.t2_x = 0;
|
xad.t1 = xad.t2 = xad.t1_x = xad.t2_x = 0;
|
||||||
|
|
||||||
getNextXABlock(&xad, false);
|
getNextXABlock(&xad, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +275,7 @@ bool XASong::Start()
|
||||||
{
|
{
|
||||||
if (xad.finished && m_Looping)
|
if (xad.finished && m_Looping)
|
||||||
{
|
{
|
||||||
xad.reader.Seek(XA_DATA_START, FileReader::SeekSet);
|
xad.reader->seek(XA_DATA_START, SEEK_SET);
|
||||||
xad.t1 = xad.t2 = xad.t1_x = xad.t2_x = 0;
|
xad.t1 = xad.t2 = xad.t1_x = xad.t2_x = 0;
|
||||||
xad.finished = false;
|
xad.finished = false;
|
||||||
}
|
}
|
||||||
|
@ -342,7 +347,7 @@ bool XASong::GetData(void *vbuff, size_t len)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
StreamSource *XA_OpenSong(FileReader &reader)
|
StreamSource *XA_OpenSong(MusicIO::FileInterface *reader)
|
||||||
{
|
{
|
||||||
return new XASong(reader);
|
return new XASong(reader);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue