summaryrefslogtreecommitdiffhomepage
path: root/src/raudio.c
diff options
context:
space:
mode:
authorRay <[email protected]>2020-12-12 13:01:31 +0100
committerRay <[email protected]>2020-12-12 13:01:31 +0100
commit459c4754dc2fc51848d7245f0301d8ed1f5121bc (patch)
treed3d68901ed97fa879900245a23d5f57a37809c0f /src/raudio.c
parent039503e7c2f74806a20b220696bde67a6fb1e627 (diff)
downloadraylib-459c4754dc2fc51848d7245f0301d8ed1f5121bc.tar.gz
raylib-459c4754dc2fc51848d7245f0301d8ed1f5121bc.zip
Reviewed SetAudioBufferPitch() #1450
Diffstat (limited to 'src/raudio.c')
-rw-r--r--src/raudio.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/raudio.c b/src/raudio.c
index ec24a1ee..8859547e 100644
--- a/src/raudio.c
+++ b/src/raudio.c
@@ -634,16 +634,14 @@ void SetAudioBufferPitch(AudioBuffer *buffer, float pitch)
{
if (buffer != NULL)
{
- float pitchMul = pitch/buffer->pitch;
-
// Pitching is just an adjustment of the sample rate.
// Note that this changes the duration of the sound:
// - higher pitches will make the sound faster
// - lower pitches make it slower
- ma_uint32 newOutputSampleRate = (ma_uint32)((float)buffer->converter.config.sampleRateOut/pitchMul);
- buffer->pitch *= (float)buffer->converter.config.sampleRateOut/newOutputSampleRate;
-
- ma_data_converter_set_rate(&buffer->converter, buffer->converter.config.sampleRateIn, newOutputSampleRate);
+ ma_uint32 outputSampleRate = (ma_uint32)((float)buffer->converter.config.sampleRateOut/pitch);
+ ma_data_converter_set_rate(&buffer->converter, buffer->converter.config.sampleRateIn, outputSampleRate);
+
+ buffer->pitch = pitch;
}
}
@@ -1477,7 +1475,7 @@ void SetMusicVolume(Music music, float volume)
// Set pitch for music
void SetMusicPitch(Music music, float pitch)
{
- SetAudioStreamPitch(music.stream, pitch);
+ SetAudioBufferPitch(music.stream.buffer, pitch);
}
// Get music time length (in seconds)