summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2020-08-11 19:08:07 +0200
committerraysan5 <[email protected]>2020-08-11 19:08:07 +0200
commitad1b3330b76fab1fd8fae98ff26845aa6e515fac (patch)
tree6750e19053c40555daf1a4167c8eb5936965148c /src
parent702341ae6e8cd32989384f2c25e483160aa9b310 (diff)
downloadraylib-ad1b3330b76fab1fd8fae98ff26845aa6e515fac.tar.gz
raylib-ad1b3330b76fab1fd8fae98ff26845aa6e515fac.zip
Support mulstiple WAV sampleSize for MusicStream #1340
24bit per sample is not supported internally and automatically converted 16bit
Diffstat (limited to 'src')
-rw-r--r--src/raudio.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/raudio.c b/src/raudio.c
index b85e755e..a0f4b7cd 100644
--- a/src/raudio.c
+++ b/src/raudio.c
@@ -1093,8 +1093,11 @@ Music LoadMusicStream(const char *fileName)
{
music.ctxType = MUSIC_AUDIO_WAV;
music.ctxData = ctxWav;
+
+ int sampleSize = ctxWav->bitsPerSample;
+ if (ctxWav->bitsPerSample == 24) sampleSize = 16; // Forcing conversion to s16 on UpdateMusicStream()
- music.stream = InitAudioStream(ctxWav->sampleRate, ctxWav->bitsPerSample, ctxWav->channels);
+ music.stream = InitAudioStream(ctxWav->sampleRate, sampleSize, ctxWav->channels);
music.sampleCount = (unsigned int)ctxWav->totalPCMFrameCount*ctxWav->channels;
music.looping = true; // Looping enabled by default
musicLoaded = true;
@@ -1351,7 +1354,8 @@ void UpdateMusicStream(Music music)
case MUSIC_AUDIO_WAV:
{
// NOTE: Returns the number of samples to process (not required)
- drwav_read_pcm_frames_s16((drwav *)music.ctxData, samplesCount/music.stream.channels, (short *)pcm);
+ if (music.stream.sampleSize == 16) drwav_read_pcm_frames_s16((drwav *)music.ctxData, samplesCount/music.stream.channels, (short *)pcm);
+ else if (music.stream.sampleSize == 32) drwav_read_pcm_frames_f32((drwav *)music.ctxData, samplesCount/music.stream.channels, (float *)pcm);
} break;
#endif