Skip to content

Commit

Permalink
[raudio] Support 24-bit FLACs in LoadMusicStreamFromMemory (#4279)
Browse files Browse the repository at this point in the history
Force conversion to 16-bit, same as how it is done in `LoadMusicStream`.
This fixes the problem where 24-bit FLACs play silence or broken sound.
  • Loading branch information
konstruktor227 authored Aug 23, 2024
1 parent 3079c69 commit b0c3013
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/raudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,9 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
{
music.ctxType = MUSIC_AUDIO_FLAC;
music.ctxData = ctxFlac;
music.stream = LoadAudioStream(ctxFlac->sampleRate, ctxFlac->bitsPerSample, ctxFlac->channels);
int sampleSize = ctxFlac->bitsPerSample;
if (ctxFlac->bitsPerSample == 24) sampleSize = 16; // Forcing conversion to s16 on UpdateMusicStream()
music.stream = LoadAudioStream(ctxFlac->sampleRate, sampleSize, ctxFlac->channels);
music.frameCount = (unsigned int)ctxFlac->totalPCMFrameCount;
music.looping = true; // Looping enabled by default
musicLoaded = true;
Expand Down

0 comments on commit b0c3013

Please sign in to comment.