Support mulstiple WAV sampleSize for MusicStream #1340
24bit per sample is not supported internally and automatically converted 16bit
This commit is contained in:
parent
702341ae6e
commit
ad1b3330b7
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user