Limit minimum pitch scale

This commit is contained in:
Tim Krief 2021-11-29 10:35:47 +00:00
parent 34227b20a8
commit ca12f87027
4 changed files with 14 additions and 4 deletions

View File

@ -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)*

View File

@ -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):

View File

@ -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):

View File

@ -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):