From 4f94624de95bdaaf61831f1120fee118162214cb Mon Sep 17 00:00:00 2001 From: torph <73564623+Torphedo@users.noreply.github.com> Date: Sun, 8 Feb 2026 02:58:35 -0500 Subject: [PATCH] [raudio]: Get format size from miniaudio instead of switch --- src/raudio.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/src/raudio.c b/src/raudio.c index 589bd958b..654e47d6e 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -1328,20 +1328,10 @@ Music LoadMusicStream(const char *fileName) music.ctxType = MUSIC_AUDIO_DECODER; music.ctxData = ctxDecoder; - ma_uint32 format, channels, sampleRate, sampleSize; + ma_uint32 format, channels, sampleRate; ma_channel channelMap; ma_decoder_get_data_format(ctxDecoder, &format, &channels, &sampleRate, &channelMap, 0); - switch (format) { - case ma_format_s16: - sampleSize = 16; - break; - case ma_format_f32: - sampleSize = 32; - break; - default: - sampleSize = 0; - break; - } + const ma_uint32 sampleSize = ma_get_bytes_per_sample(format) * 8; music.stream = LoadAudioStream(sampleRate, sampleSize, channels); ma_uint64 frameCount = 0; @@ -1503,20 +1493,10 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, music.ctxType = MUSIC_AUDIO_DECODER; music.ctxData = ctxDecoder; - ma_uint32 format, channels, sampleRate, sampleSize; + ma_uint32 format, channels, sampleRate; ma_channel channelMap; ma_decoder_get_data_format(ctxDecoder, &format, &channels, &sampleRate, &channelMap, 0); - switch (format) { - case ma_format_s16: - sampleSize = 16; - break; - case ma_format_f32: - sampleSize = 32; - break; - default: - sampleSize = 0; - break; - } + const ma_uint32 sampleSize = ma_get_bytes_per_sample(format) * 8; music.stream = LoadAudioStream(sampleRate, sampleSize, channels); ma_uint64 frameCount = 0;