summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Shangreaux <grant@unabridgedsoftware.com>2021-10-27 13:07:56 -0500
committerGrant Shangreaux <grant@unabridgedsoftware.com>2021-10-27 13:07:56 -0500
commiteda6270cdc302a1cca27f70d9b65cd8aff621882 (patch)
tree8e1ad49c96a38c88f8a46add0d8a7761cf5fb241
parent12135f5a67f9d01f652786344b985ce71749ee72 (diff)
Feature: working audio from rust into godot
-rw-r--r--klangfarb/MonoBuffer.gdns (renamed from klangfarb/Main.gdns)0
-rw-r--r--klangfarb/main.gd20
2 files changed, 15 insertions, 5 deletions
diff --git a/klangfarb/Main.gdns b/klangfarb/MonoBuffer.gdns
index e551128..e551128 100644
--- a/klangfarb/Main.gdns
+++ b/klangfarb/MonoBuffer.gdns
diff --git a/klangfarb/main.gd b/klangfarb/main.gd
index 9032787..62137bc 100644
--- a/klangfarb/main.gd
+++ b/klangfarb/main.gd
@@ -1,9 +1,12 @@
tool
extends AudioStreamPlayer
-var playback: AudioStreamPlayback
+var playback: AudioStreamPlayback = null
+
+var MonoBuffer = preload("res://MonoBuffer.gdns")
+var buffer = MonoBuffer.new()
+var samples = buffer.frames
+var sample_count = samples.size()
-var Buff = preload("res://Main.gdns")
-var buff_node = Buff.new()
func _create_generator() -> void:
stream = AudioStreamGenerator.new()
@@ -13,12 +16,19 @@ func _create_generator() -> void:
func _fill_buffer() -> void:
var to_fill = playback.get_frames_available()
while to_fill > 0:
- playback.push_frame(Vector2.ONE * buff_node.frames) # Audio frames are stereo.
+ var sample_index = to_fill % 512
+ playback.push_frame(Vector2.ONE * samples[sample_index]) # Audio frames are stereo.
# _phase = fmod(_phase + frequency() / GDawConfig.sample_rate, 1.0)
# _update_state()
to_fill -= 1
+func _process(delta):
+ _fill_buffer()
func _ready() -> void:
-# _update_envelope()
_create_generator()
+ print(sample_count)
+ _fill_buffer()
+ self.play()
+# _update_envelope()
+