Skip to content

Commit b0c3013

Browse files
authored
[raudio] Support 24-bit FLACs in LoadMusicStreamFromMemory (#4279)
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.
1 parent 3079c69 commit b0c3013

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/raudio.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,9 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
16261626
{
16271627
music.ctxType = MUSIC_AUDIO_FLAC;
16281628
music.ctxData = ctxFlac;
1629-
music.stream = LoadAudioStream(ctxFlac->sampleRate, ctxFlac->bitsPerSample, ctxFlac->channels);
1629+
int sampleSize = ctxFlac->bitsPerSample;
1630+
if (ctxFlac->bitsPerSample == 24) sampleSize = 16; // Forcing conversion to s16 on UpdateMusicStream()
1631+
music.stream = LoadAudioStream(ctxFlac->sampleRate, sampleSize, ctxFlac->channels);
16301632
music.frameCount = (unsigned int)ctxFlac->totalPCMFrameCount;
16311633
music.looping = true; // Looping enabled by default
16321634
musicLoaded = true;

0 commit comments

Comments
 (0)