From ad1b1fe539ee0dae2d93ee315c13d564d6273adc Mon Sep 17 00:00:00 2001 From: Mystia-Izakaya Date: Sat, 5 Sep 2026 21:51:09 +0300 Subject: [PATCH 1/3] Add functions for retrieving music and audio volume We have SetMusicVolume and SetAudioVolume, so why not also add GetMusicVolume and GetAudioVolume? --- src/raudio.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/raudio.c b/src/raudio.c index ec97bdee1246..e68bf21878bd 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -717,6 +717,19 @@ void SetAudioBufferVolume(AudioBuffer *buffer, float volume) } } +// Get volume of an audio buffer, returns -1 if invalid +float GetAudioBufferVolume(AudioBuffer *buffer) +{ + float volume = -1.0f; + if (buffer != NULL) + { + ma_mutex_lock(&AUDIO.System.lock); + volume = buffer->volume; + ma_mutex_unlock(&AUDIO.System.lock); + } + return volume; +} + // Set pitch for an audio buffer void SetAudioBufferPitch(AudioBuffer *buffer, float pitch) { @@ -1232,6 +1245,12 @@ void SetSoundVolume(Sound sound, float volume) SetAudioBufferVolume(sound.stream.buffer, volume); } +// Get volume of a sound, returns -1 if invalid +float GetSoundVolume(Sound sound) +{ + return GetAudioBufferVolume(sound.stream.buffer); +} + // Set pitch for a sound void SetSoundPitch(Sound sound, float pitch) { @@ -2063,6 +2082,12 @@ void SetMusicVolume(Music music, float volume) SetAudioStreamVolume(music.stream, volume); } +// Get volume of music, returns -1 if invalid +float GetMusicVolume(Music music) +{ + return GetAudioStreamVolume(music.stream); +} + // Set pitch for music void SetMusicPitch(Music music, float pitch) { @@ -2235,6 +2260,12 @@ void SetAudioStreamVolume(AudioStream stream, float volume) SetAudioBufferVolume(stream.buffer, volume); } +// Get volume for audio stream (1.0 is max level), returns -1 if invalid +float GetAudioStreamVolume(AudioStream stream) +{ + return GetAudioBufferVolume(stream.buffer); +} + // Set pitch for audio stream (1.0 is base level) void SetAudioStreamPitch(AudioStream stream, float pitch) { From 3260554bdc6f12a2f5fa471d28dd5ae66709091b Mon Sep 17 00:00:00 2001 From: Mystia-Izakaya Date: Sat, 5 Sep 2026 22:09:45 +0300 Subject: [PATCH 2/3] Update raudio.c --- src/raudio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/raudio.c b/src/raudio.c index e68bf21878bd..35879e173ca1 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -452,6 +452,7 @@ void StopAudioBuffer(AudioBuffer *buffer); void PauseAudioBuffer(AudioBuffer *buffer); void ResumeAudioBuffer(AudioBuffer *buffer); void SetAudioBufferVolume(AudioBuffer *buffer, float volume); +float GetAudioBufferVolume(AudioBuffer *buffer); void SetAudioBufferPitch(AudioBuffer *buffer, float pitch); void SetAudioBufferPan(AudioBuffer *buffer, float pan); void TrackAudioBuffer(AudioBuffer *buffer); From da827078c4ec075601c79d20f6d3009904517349 Mon Sep 17 00:00:00 2001 From: Mystia-Izakaya Date: Sat, 5 Sep 2026 22:13:27 +0300 Subject: [PATCH 3/3] Update raylib.h --- src/raylib.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/raylib.h b/src/raylib.h index 8f88e3d23d25..8ffb25ec45fb 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1708,6 +1708,7 @@ RLAPI void PauseSound(Sound sound); // Pause a RLAPI void ResumeSound(Sound sound); // Resume a paused sound RLAPI bool IsSoundPlaying(Sound sound); // Check if sound is currently playing RLAPI void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level) +RLAPI float GetSoundVolume(Sound sound); // Get volume of a sound (1.0 is max level), returns -1 if invalid RLAPI void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level) RLAPI void SetSoundPan(Sound sound, float pan); // Set pan for a sound (-1.0 left, 0.0 center, 1.0 right) RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave @@ -1729,6 +1730,7 @@ RLAPI void PauseMusicStream(Music music); // Pause m RLAPI void ResumeMusicStream(Music music); // Resume playing paused music RLAPI void SeekMusicStream(Music music, float position); // Seek music to a position (in seconds) RLAPI void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level) +RLAPI float GetMusicVolume(Music music); // Get volume of music (1.0 is max level), returns -1 if invalid RLAPI void SetMusicPitch(Music music, float pitch); // Set pitch for music (1.0 is base level) RLAPI void SetMusicPan(Music music, float pan); // Set pan for music (-1.0 left, 0.0 center, 1.0 right) RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds) @@ -1746,6 +1748,7 @@ RLAPI void ResumeAudioStream(AudioStream stream); // Resume RLAPI bool IsAudioStreamPlaying(AudioStream stream); // Check if audio stream is playing RLAPI void StopAudioStream(AudioStream stream); // Stop audio stream RLAPI void SetAudioStreamVolume(AudioStream stream, float volume); // Set volume for audio stream (1.0 is max level) +RLAPI float GetAudioStreamVolume(AudioStream stream); // Get volume of an audio stream (1.0 is max level), returns -1 if invalid RLAPI void SetAudioStreamPitch(AudioStream stream, float pitch); // Set pitch for audio stream (1.0 is base level) RLAPI void SetAudioStreamPan(AudioStream stream, float pan); // Set pan for audio stream (-1.0 left, 0.0 center, 1.0 right) RLAPI void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams