File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -799,10 +799,13 @@ AudioStreamRandomizer::AudioStreamRandomizer() {
799799void AudioStreamPlaybackRandomizer::start (double p_from_pos) {
800800 playing = playback;
801801 {
802- float range_from = 1.0 / randomizer->random_pitch_scale ;
803- float range_to = randomizer->random_pitch_scale ;
802+ // GH-10238 : Pitch_scale is multiplicative, so picking a random number for it without log
803+ // conversion will bias it towards higher pitches (0.5 is down one octave, 2.0 is up one octave).
804+ // See: https://pressbooks.pub/sound/chapter/pitch-and-frequency-in-music/
805+ float range_from = Math::log (1 .0f / randomizer->random_pitch_scale );
806+ float range_to = Math::log (randomizer->random_pitch_scale );
804807
805- pitch_scale = range_from + Math::randf () * (range_to - range_from);
808+ pitch_scale = Math::exp ( range_from + Math::randf () * (range_to - range_from) );
806809 }
807810 {
808811 float range_from = -randomizer->random_volume_offset_db ;
You can’t perform that action at this time.
0 commit comments