Working on MP3 support

This commit is contained in:
Ray 2018-07-19 23:15:46 +02:00
parent 103044926b
commit 6e812cf147
3 changed files with 5 additions and 5 deletions

Binary file not shown.

View File

@ -1373,13 +1373,13 @@ Music LoadMusicStream(const char *fileName)
#if defined(SUPPORT_FILEFORMAT_MP3)
else if (IsFileExtension(fileName, ".mp3"))
{
drmp3_init_file(&music->ctxMp3, fileName, NULL)
drmp3_init_file(&music->ctxMp3, fileName, NULL);
if (music->ctxMp3 == NULL) TraceLog(LOG_WARNING, "[%s] MP3 audio file could not be opened", fileName);
if (music->ctxMp3.framesRemaining <= 0) TraceLog(LOG_WARNING, "[%s] MP3 audio file could not be opened", fileName);
else
{
music->stream = InitAudioStream(music->ctxMp3.sampleRate, 16, music->ctxMp3.channels);
//music->totalSamples = (unsigned int)music->ctxMp3.totalSampleCount/music->ctxMp3.channels; //TODO!
music->totalSamples = (unsigned int)music->ctxMp3.framesRemaining*music->ctxMp3.channels;
music->samplesLeft = music->totalSamples;
music->ctxType = MUSIC_AUDIO_MP3;
music->loopCount = -1; // Infinite loop by default
@ -1594,7 +1594,7 @@ void UpdateMusicStream(Music music)
case MUSIC_AUDIO_MP3:
{
// NOTE: Returns the number of samples to process
unsigned int numSamplesMp3 = (unsigned int)drmp3_read_f32(music->ctxMp3, samplesCount*music->stream.channels, (short *)pcm);
unsigned int numSamplesMp3 = (unsigned int)drmp3_read_f32(&music->ctxMp3, samplesCount*music->stream.channels, (float *)pcm);
} break;
#endif

View File

@ -124,7 +124,7 @@
#define SUPPORT_FILEFORMAT_XM 1
#define SUPPORT_FILEFORMAT_MOD 1
//#define SUPPORT_FILEFORMAT_FLAC 1
//#define SUPPORT_FILEFORMAT_MP3 1
#define SUPPORT_FILEFORMAT_MP3 1
//------------------------------------------------------------------------------------