diff options
author | Grant Shangreaux <grant@unabridgedsoftware.com> | 2021-10-27 10:03:37 -0500 |
---|---|---|
committer | Grant Shangreaux <grant@unabridgedsoftware.com> | 2021-10-27 10:03:37 -0500 |
commit | 12135f5a67f9d01f652786344b985ce71749ee72 (patch) | |
tree | dc8db8035e03af80063d76661790a163f83a4fa7 | |
parent | 90b491bb0d4ca6ae88495e7fb3f9b936598d83e1 (diff) |
Add: main.gd script that loads the MonoBuffer gdns
-rw-r--r-- | klangfarb/Main.tscn | 8 | ||||
-rw-r--r-- | klangfarb/main.gd | 31 |
2 files changed, 23 insertions, 16 deletions
diff --git a/klangfarb/Main.tscn b/klangfarb/Main.tscn index 9c58bfd..0a0ad3b 100644 --- a/klangfarb/Main.tscn +++ b/klangfarb/Main.tscn @@ -1,10 +1,10 @@ [gd_scene load_steps=3 format=2] -[ext_resource path="res://Main.gdns" type="Script" id=1] [ext_resource path="res://main.gd" type="Script" id=2] -[node name="Node" type="Node"] -script = ExtResource( 1 ) +[sub_resource type="AudioStreamGenerator" id=1] +mix_rate = 8000.0 -[node name="Node" type="Node" parent="."] +[node name="Audio" type="AudioStreamPlayer"] +stream = SubResource( 1 ) script = ExtResource( 2 ) diff --git a/klangfarb/main.gd b/klangfarb/main.gd index 96d8cb5..9032787 100644 --- a/klangfarb/main.gd +++ b/klangfarb/main.gd @@ -1,17 +1,24 @@ -extends Node +tool +extends AudioStreamPlayer +var playback: AudioStreamPlayback -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" -onready var data = preload("res://klangfarbrs.gdnlib") -# var buffer = MonoBuffer.new() +var Buff = preload("res://Main.gdns") +var buff_node = Buff.new() -# Called when the node enters the scene tree for the first time. -func _ready(): - print("Poop", data.frames()); +func _create_generator() -> void: + stream = AudioStreamGenerator.new() + stream.mix_rate = 8000.0 # Setting mix rate is only possible before play(). + playback = get_stream_playback() +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. +# _phase = fmod(_phase + frequency() / GDawConfig.sample_rate, 1.0) +# _update_state() + to_fill -= 1 -# Called every frame. 'delta' is the elapsed time since the previous frame. -#func _process(delta): -# pass +func _ready() -> void: +# _update_envelope() + _create_generator() |