diff options
Diffstat (limited to 'klangfarb')
-rw-r--r-- | klangfarb/Main.tscn | 1 | ||||
-rw-r--r-- | klangfarb/MonoSynth.gdns (renamed from klangfarb/Osc.gdns) | 4 | ||||
-rw-r--r-- | klangfarb/main.gd | 32 |
3 files changed, 26 insertions, 11 deletions
diff --git a/klangfarb/Main.tscn b/klangfarb/Main.tscn index 896aa8c..e7a1b90 100644 --- a/klangfarb/Main.tscn +++ b/klangfarb/Main.tscn @@ -8,4 +8,3 @@ stream = SubResource( 1 ) volume_db = -13.216 script = ExtResource( 2 ) -freq = 130.0 diff --git a/klangfarb/Osc.gdns b/klangfarb/MonoSynth.gdns index 65d44ef..d795047 100644 --- a/klangfarb/Osc.gdns +++ b/klangfarb/MonoSynth.gdns @@ -3,6 +3,6 @@ [ext_resource path="res://klangfarbrs.gdnlib" type="GDNativeLibrary" id=1] [resource] -resource_name = "Osc" -class_name = "Osc" +resource_name = "MonoSynth" +class_name = "MonoSynth" library = ExtResource( 1 ) 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 |