summaryrefslogtreecommitdiff
path: root/klangfarb/main.gd
diff options
context:
space:
mode:
Diffstat (limited to 'klangfarb/main.gd')
-rw-r--r--klangfarb/main.gd32
1 files changed, 24 insertions, 8 deletions
diff --git a/klangfarb/main.gd b/klangfarb/main.gd
index 439bb50..95c0f8f 100644
--- a/klangfarb/main.gd
+++ b/klangfarb/main.gd
@@ -1,16 +1,28 @@
extends AudioStreamPlayer
-# controllable frequency interface
-export(float, 20, 8000, 5) var freq = 440.0
-export(float, 0, 1, 0.1) var bend = 0.5
# control wave form
export(String, "sine", "square", "triangle", "sawtooth") var waveform = "sine"
+# controllable frequency interface
+export(float, 20, 8000, 5) var freq = 440.0
+# bending the waveform
+export(bool) var apply_bend = false
+export(Vector2) var phasor_bend = Vector2(0.5, 0.5)
+# duration related
+export(bool) var continuous = true
+export(int, 0, 5000, 100) var duration = 3000
+#Attack/Decay/Release/Sustain
+export(int, 0, 5000, 100) var attack = 100
+export(int, 0, 5000, 100) var decay = 100
+export(int, 0, 5000, 100) var release = 100
+export(float, 0.0, 1.0, 0.1) var sustain = 0.5
+#Cutoff
+export(float, 20, 8000, 5) var cutoff = 6000
# load the GDNative script connected to the rust lib
-var Osc = preload("res://Osc.gdns")
+var MonoSynth = preload("res://MonoSynth.gdns")
# make an instance of our one "class" in rust lib
-var wave = Osc.new()
+var wave = MonoSynth.new()
# initialize the Godot stream we fill up with samples
var playback: AudioStreamPlayback = null
@@ -22,7 +34,7 @@ func _fill_buffer() -> void:
# ask Rust to generate N frames at freq
# Array<Vector2> gets pushed to the
# playback stream buffer
- playback.push_buffer(wave.frames(freq, to_fill, bend))
+ playback.push_buffer(wave.frames(to_fill))
func _check_waveform():
if waveform == "square":
@@ -36,6 +48,9 @@ func _check_waveform():
func _process(_delta):
if self.is_playing():
+ wave.apply_bend(apply_bend)
+ wave.frequency(freq)
+ wave.phasor_bend(phasor_bend)
_check_waveform()
_fill_buffer()
@@ -55,5 +70,6 @@ func _input(event):
if event is InputEventMouseButton:
print("Mouse Click/Unclick at: ", event.position)
elif event is InputEventMouseMotion:
- freq = event.position.x
- print("Mouse Motion at: ", event.position)
+# freq = event.position.x
+ phasor_bend.x = event.position.x / 1024
+ phasor_bend.y = event.position.y / 600