From ca12f870270ecc3f26533a2657b96b08961e60a5 Mon Sep 17 00:00:00 2001 From: Tim Krief Date: Mon, 29 Nov 2021 10:35:47 +0000 Subject: [PATCH] Limit minimum pitch scale --- README.md | 6 +++++- .../randomAudioStreamPlayer/random_audio_stream_player.gd | 4 +++- .../random_audio_stream_player_2D.gd | 4 +++- .../random_audio_stream_player_3D.gd | 4 +++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5b0a8c7..88ba004 100644 --- a/README.md +++ b/README.md @@ -40,4 +40,8 @@ Icons are derived from the [AudioStreamPlayer](https://github.com/godotengine/go # Support Development -Via [PayPal](https://www.paypal.com/donate/?hosted_button_id=4NUJG3D667BU6) - Via [liberapay](https://liberapay.com/timkrief/donate) +**Support me and get to vote on what I should work on!** +- Choose your tier on [Patreon](https://patreon.com/timkrief) and get some perks +- Or just make a one-time support on [Ko-fi](https://ko-fi.com/timkrief) + +*More info: [support.timkrief.com](https://support.timkrief.com)* diff --git a/addons/randomAudioStreamPlayer/random_audio_stream_player.gd b/addons/randomAudioStreamPlayer/random_audio_stream_player.gd index 5d990f6..6d9b662 100644 --- a/addons/randomAudioStreamPlayer/random_audio_stream_player.gd +++ b/addons/randomAudioStreamPlayer/random_audio_stream_player.gd @@ -40,14 +40,16 @@ func play(from_position=0.0, playing_sample_nb=-1): if random_volume_range != 0: .set_volume_db(base_volume + (randf() - .5) * random_volume_range) if random_pitch_range != 0: - .set_pitch_scale(base_pitch + (randf() - .5) * random_pitch_range) + .set_pitch_scale(max(0.0001, base_pitch + (randf() - .5) * random_pitch_range)) set_stream(samples[playing_sample_nb]) .play(from_position) func set_volume_db(new_volume_db): + .set_volume_db(new_volume_db) base_volume = new_volume_db func set_pitch_scale(new_pitch): + .set_pitch_scale(max(0.0001, new_pitch)) base_pitch = new_pitch func load_samples_from_folder(path): diff --git a/addons/randomAudioStreamPlayer/random_audio_stream_player_2D.gd b/addons/randomAudioStreamPlayer/random_audio_stream_player_2D.gd index 70b2d4b..6331676 100644 --- a/addons/randomAudioStreamPlayer/random_audio_stream_player_2D.gd +++ b/addons/randomAudioStreamPlayer/random_audio_stream_player_2D.gd @@ -40,14 +40,16 @@ func play(from_position=0.0, playing_sample_nb=-1): if random_volume_range != 0: .set_volume_db(base_volume + (randf() - .5) * random_volume_range) if random_pitch_range != 0: - .set_pitch_scale(base_pitch + (randf() - .5) * random_pitch_range) + .set_pitch_scale(max(0.0001, base_pitch + (randf() - .5) * random_pitch_range)) set_stream(samples[playing_sample_nb]) .play(from_position) func set_volume_db(new_volume_db): + .set_volume_db(new_volume_db) base_volume = new_volume_db func set_pitch_scale(new_pitch): + .set_pitch_scale(max(0.0001, new_pitch)) base_pitch = new_pitch func load_samples_from_folder(path): diff --git a/addons/randomAudioStreamPlayer/random_audio_stream_player_3D.gd b/addons/randomAudioStreamPlayer/random_audio_stream_player_3D.gd index 17dc5ea..eca6e66 100644 --- a/addons/randomAudioStreamPlayer/random_audio_stream_player_3D.gd +++ b/addons/randomAudioStreamPlayer/random_audio_stream_player_3D.gd @@ -40,14 +40,16 @@ func play(from_position=0.0, playing_sample_nb=-1): if random_volume_range != 0: .set_unit_db(base_volume + (randf() - .5) * random_volume_range) if random_pitch_range != 0: - .set_pitch_scale(base_pitch + (randf() - .5) * random_pitch_range) + .set_pitch_scale(max(0.0001, base_pitch + (randf() - .5) * random_pitch_range)) set_stream(samples[playing_sample_nb]) .play(from_position) func set_unit_db(new_unit_db): + .set_unit_db(new_unit_db) base_volume = new_unit_db func set_pitch_scale(new_pitch): + .set_pitch_scale(max(0.0001, new_pitch)) base_pitch = new_pitch func load_samples_from_folder(path):