Review QOA sound loading -WIP-
This commit is contained in:
parent
ff70a04bf5
commit
c91190fc6e
1 changed files with 19 additions and 9 deletions
28
src/raudio.c
28
src/raudio.c
|
@ -829,18 +829,26 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
|
||||||
{
|
{
|
||||||
qoa_desc qoa = { 0 };
|
qoa_desc qoa = { 0 };
|
||||||
|
|
||||||
// NOTE: Returned sample data is always 16 bit?
|
unsigned int result = qoa_decode_header(fileData, dataSize, &qoa);
|
||||||
wave.data = qoa_decode(fileData, dataSize, &qoa);
|
|
||||||
wave.sampleSize = 16;
|
if (result > 0)
|
||||||
|
|
||||||
if (wave.data != NULL)
|
|
||||||
{
|
{
|
||||||
wave.channels = qoa.channels;
|
|
||||||
wave.sampleRate = qoa.samplerate;
|
// Calculate the total audio frame count
|
||||||
wave.frameCount = qoa.samples;
|
wave.frameCount = qoa.samples;
|
||||||
|
|
||||||
|
// NOTE: Returned sample data is always 16 bit
|
||||||
|
wave.data = qoa_decode(fileData, dataSize, &qoa);
|
||||||
|
wave.sampleSize = 16;
|
||||||
|
|
||||||
|
if (wave.data != NULL)
|
||||||
|
{
|
||||||
|
wave.channels = qoa.channels;
|
||||||
|
wave.sampleRate = qoa.samplerate;
|
||||||
|
}
|
||||||
|
else TRACELOG(LOG_WARNING, "WAVE: Failed to load QOA data");
|
||||||
}
|
}
|
||||||
else TRACELOG(LOG_WARNING, "WAVE: Failed to load QOA data");
|
else TRACELOG(LOG_WARNING, "WAVE: Failed to load QOA data");
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
||||||
|
@ -1380,6 +1388,7 @@ Music LoadMusicStream(const char *fileName)
|
||||||
qoa_desc *ctxQoa = RL_CALLOC(1, sizeof(qoa_desc));
|
qoa_desc *ctxQoa = RL_CALLOC(1, sizeof(qoa_desc));
|
||||||
|
|
||||||
// TODO: QOA stream support: Init context from file
|
// TODO: QOA stream support: Init context from file
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
music.ctxType = MUSIC_AUDIO_QOA;
|
music.ctxType = MUSIC_AUDIO_QOA;
|
||||||
music.ctxData = ctxQoa;
|
music.ctxData = ctxQoa;
|
||||||
|
@ -1578,11 +1587,12 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
|
||||||
qoa_desc *ctxQoa = RL_CALLOC(1, sizeof(qoa_desc));
|
qoa_desc *ctxQoa = RL_CALLOC(1, sizeof(qoa_desc));
|
||||||
|
|
||||||
// TODO: Init QOA context data
|
// TODO: Init QOA context data
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
music.ctxType = MUSIC_AUDIO_QOA;
|
music.ctxType = MUSIC_AUDIO_QOA;
|
||||||
music.ctxData = ctxQoa;
|
music.ctxData = ctxQoa;
|
||||||
|
|
||||||
if (success)
|
if (result > 0)
|
||||||
{
|
{
|
||||||
music.stream = LoadAudioStream(ctxQoa->samplerate, 16, ctxQoa->channels);
|
music.stream = LoadAudioStream(ctxQoa->samplerate, 16, ctxQoa->channels);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue