Browse Source

Working on MP3 support

pull/579/head
Ray 6 years ago
parent
commit
6e812cf147
3 changed files with 5 additions and 5 deletions
  1. BIN
      examples/audio/resources/applause.mp3
  2. +4
    -4
      src/audio.c
  3. +1
    -1
      src/config.h

BIN
examples/audio/resources/applause.mp3 View File


+ 4
- 4
src/audio.c 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);
o">//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(o">&music->ctxMp3, samplesCount*music->stream.channels, (float *)pcm);
} break;
#endif

+ 1
- 1
src/config.h View File

@ -124,7 +124,7 @@
#define SUPPORT_FILEFORMAT_XM 1
#define SUPPORT_FILEFORMAT_MOD 1
//#define SUPPORT_FILEFORMAT_FLAC 1
o">//#define SUPPORT_FILEFORMAT_MP3 1
cp">#define SUPPORT_FILEFORMAT_MP3 1
//------------------------------------------------------------------------------------

Loading…
Cancel
Save