From c7e88b7d605fd19d9ff54681a42fd69d079d92b1 Mon Sep 17 00:00:00 2001 From: Grant Shangreaux Date: Sat, 13 Nov 2021 19:55:09 -0600 Subject: Add: Envelope Iterator implementation and click to trigger note --- klangfarb/main.gd | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'klangfarb') diff --git a/klangfarb/main.gd b/klangfarb/main.gd index 268934f..751527a 100644 --- a/klangfarb/main.gd +++ b/klangfarb/main.gd @@ -57,19 +57,19 @@ func _check_waveform(): func _process(_delta): if self.is_playing(): - synth.apply_bend(apply_bend) - synth.frequency(freq) - synth.phasor_bend(phasor_bend) +# synth.apply_bend(apply_bend) +# synth.frequency(freq) +# synth.phasor_bend(phasor_bend) synth.frequency_modulation(frequency_modulation) - synth.fm_frequency(fm_multiplier * freq) +# synth.fm_frequency(fm_multiplier * freq) synth.fm_depth(fm_index) synth.continuous(continuous) _check_waveform() _fill_buffer() func _ready() -> void: - # buffer length of 100ms gives us ~realtime response to input changes - self.stream.buffer_length = 0.1 + # buffer length of 10ms gives us ~realtime response to input changes + self.stream.buffer_length = 0.05 # ensure Godot/Sine have the same sample rate synth.set_sample_rate(self.stream.mix_rate) # get our AudioStreamPlayback object @@ -80,10 +80,13 @@ func _ready() -> void: func _input(event): # Mouse in viewport coordinates. - if event is InputEventMouseButton: + if event is InputEventMouseButton && event.is_pressed(): print("Mouse Click/Unclick at: ", event.position) + synth.trigger() elif event is InputEventMouseMotion: freq = event.position.x + synth.frequency(freq) # phasor_bend.x = event.position.x / 1024 # phasor_bend.y = event.position.y / 600 fm_multiplier = 600 / (event.position.y + 1) + synth.fm_frequency(fm_multiplier * freq) -- cgit v1.2.3