diff options
Diffstat (limited to 'klangfarb')
-rw-r--r-- | klangfarb/Main.tscn | 1 | ||||
-rwxr-xr-x | klangfarb/libklangfarbrs.so | bin | 20371272 -> 20371304 bytes | |||
-rw-r--r-- | klangfarb/main.gd | 28 |
3 files changed, 16 insertions, 13 deletions
diff --git a/klangfarb/Main.tscn b/klangfarb/Main.tscn index 0a0ad3b..1a32577 100644 --- a/klangfarb/Main.tscn +++ b/klangfarb/Main.tscn @@ -3,7 +3,6 @@ [ext_resource path="res://main.gd" type="Script" id=2] [sub_resource type="AudioStreamGenerator" id=1] -mix_rate = 8000.0 [node name="Audio" type="AudioStreamPlayer"] stream = SubResource( 1 ) diff --git a/klangfarb/libklangfarbrs.so b/klangfarb/libklangfarbrs.so Binary files differindex 75b22dc..c7b448a 100755 --- a/klangfarb/libklangfarbrs.so +++ b/klangfarb/libklangfarbrs.so diff --git a/klangfarb/main.gd b/klangfarb/main.gd index 62137bc..d88d431 100644 --- a/klangfarb/main.gd +++ b/klangfarb/main.gd @@ -1,4 +1,3 @@ -tool extends AudioStreamPlayer var playback: AudioStreamPlayback = null @@ -6,28 +5,33 @@ var MonoBuffer = preload("res://MonoBuffer.gdns") var buffer = MonoBuffer.new() var samples = buffer.frames var sample_count = samples.size() +var current_count = 0 - -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 _create_generator() -> void: +# stream = AudioStreamGenerator.new() +# stream.mix_rate = 44100.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: - var sample_index = to_fill % 512 + + while to_fill > 0 && current_count != sample_count: + var sample_index = current_count 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 + current_count += 1 -func _process(delta): - _fill_buffer() +func _process(_delta): + if current_count < sample_count: + _fill_buffer() + else: + self.stop() func _ready() -> void: - _create_generator() - print(sample_count) + self.stream.mix_rate = 44100.0 + playback = self.get_stream_playback() _fill_buffer() self.play() # _update_envelope() |