diff --git a/examples/audio/resources/applause.mp3 b/examples/audio/resources/applause.mp3 new file mode 100644 index 00000000..084a7d1f Binary files /dev/null and b/examples/audio/resources/applause.mp3 differ diff --git a/src/audio.c b/src/audio.c index 31a56215..b6e2e4c6 100644 --- a/src/audio.c +++ b/src/audio.c @@ -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 diff --git a/src/config.h b/src/config.h index ea98897c..a889fd0c 100644 --- a/src/config.h +++ b/src/config.h @@ -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 //------------------------------------------------------------------------------------