diff --git a/godot/Components/MultiDelaySlider.gd b/godot/Components/MultiDelaySlider.gd new file mode 100644 index 0000000..8d6d16b --- /dev/null +++ b/godot/Components/MultiDelaySlider.gd @@ -0,0 +1,55 @@ +extends Control + +signal delay_changed(slider,value) +var count = 0 +var sliders = [] +var values = [] +var deets = [] + +func set_count(value): + for slice in $VBoxContainer.get_children(): + slice.remove_and_skip() + sliders = [] + deets = [] + for i in range(0,value): + if len(values) < value+1: + values.append(Globals.audio_delay_seconds * 1000) + var slice = HBoxContainer.new() + var label = Label.new() + label.text = String(i+1) + label.hint_tooltip = "Vocal delay track "+String(i+1) + label.mouse_filter = Control.MOUSE_FILTER_STOP + slice.add_child(label) + var slider = HSlider.new() + slider.hint_tooltip = "Vocal delay track "+String(i+1) + slider.size_flags_horizontal = SIZE_EXPAND_FILL + print("Set track "+String(i)+" to "+String(values[i])) + slider.value = values[i] + slider.max_value = 1000 + slider.connect("value_changed",self,"on_value_changed") + slice.add_child(slider) + sliders.append(slider) + var deet = Label.new() + deet.text = String(values[i]/1000) + "s" + deet.rect_min_size = Vector2(50,0) + deet.hint_tooltip = "Vocal delay track "+String(i+1) + deet.mouse_filter = Control.MOUSE_FILTER_STOP + deets.append(deet) + slice.add_child(deet) + $VBoxContainer.add_child(slice) + +func on_value_changed(value): + for i in range(0,len(sliders)): + if values[i] != sliders[i].value: + values[i] = sliders[i].value + deets[i].text = String(values[i]/1000) + "s" + emit_signal("delay_changed",i,sliders[i].value) + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/godot/Components/MultiDelaySlider.tscn b/godot/Components/MultiDelaySlider.tscn new file mode 100644 index 0000000..d05a11b --- /dev/null +++ b/godot/Components/MultiDelaySlider.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Components/MultiDelaySlider.gd" type="Script" id=1] + +[node name="Control" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/godot/Components/MultiStreamPlayer.gd b/godot/Components/MultiStreamPlayer.gd index 424b359..72b2ac4 100644 --- a/godot/Components/MultiStreamPlayer.gd +++ b/godot/Components/MultiStreamPlayer.gd @@ -8,6 +8,7 @@ var players = [] var AudioSyncs = [] var AudioStreams = [] var AudioVolumes = [] +var playing = false export(VideoStreamWebm) var VideoStream export(bool) var paused export(int) var VideoDurationSeconds @@ -25,12 +26,14 @@ func _ready(): func play(): $VideoPlayer.play() + playing = true func stop(): $VideoPlayer.stop() for playerid in range(0,len(players)): print(">>>Stopping player"+String(playerid)) players[playerid].stop() + playing = false func set_VideoStream(new_stream): VideoStream = new_stream @@ -59,6 +62,19 @@ func set_volume_db(value): func set_audio_volume_db(which, value): players[which].set_volume_db(value) +func set_stream_delay(which, value): + if playing: + if !paused: + $VideoPlayer.paused = true + for playerid in range(0,len(players)): + players[playerid].stream_paused = true + players[which].seek($VideoPlayer.stream_position + value) + if !paused: + $VideoPlayer.paused = false + for playerid in range(0,len(players)): + players[playerid].stream_paused = false + AudioSyncs[which] = value + func get_stream_position(): return $VideoPlayer.stream_position @@ -74,6 +90,7 @@ func add_audio_stream(stream, delay): print(">>>added stream, count is now "+String(len(AudioSyncs))+","+String(len(players))+","+String(len(AudioStreams))) func play_combined(): + playing = true $VideoPlayer.play() for playerid in range(0,len(players)): print(">>>Playing player"+String(playerid)) @@ -89,4 +106,8 @@ func _process(delta): func _on_VideoPlayer_finished(): + playing = false + for playerid in range(0,len(players)): + print(">>>Stopping player"+String(playerid)) + players[playerid].stop() emit_signal("finished") diff --git a/godot/Components/MultiVolumeSlider.gd b/godot/Components/MultiVolumeSlider.gd index d99ab8c..74908ec 100644 --- a/godot/Components/MultiVolumeSlider.gd +++ b/godot/Components/MultiVolumeSlider.gd @@ -32,6 +32,7 @@ func set_count(value): label.text = String(i+1) label.hint_tooltip = "Vocal mix "+String(i+1) label.mouse_filter = Control.MOUSE_FILTER_STOP + label.align = Label.ALIGN_CENTER slice.add_child(label) $HBoxContainer.add_child(slice) @@ -39,7 +40,7 @@ func on_value_changed(value): for i in range(0,len(sliders)): if values[i] != sliders[i].value: values[i] = sliders[i].value - emit_signal("volume_changed",0,sliders[0].value) + emit_signal("volume_changed",i,sliders[i].value) # Called every frame. 'delta' is the elapsed time since the previous frame. #func _process(delta): diff --git a/godot/PlayVideoRecordAudio.gd b/godot/PlayVideoRecordAudio.gd index 213b314..1d46fc8 100644 --- a/godot/PlayVideoRecordAudio.gd +++ b/godot/PlayVideoRecordAudio.gd @@ -14,7 +14,8 @@ var playable_recording_data var playing = false var current_stream_added = false var recorded_streams = 0 - +var streams_recorded_here = [] +var stream_data = [] var position_changing_by_code # Called when the node enters the scene tree for the first time. @@ -44,8 +45,8 @@ func _ready(): recorder = AudioServer.get_bus_effect(idx, 0) spectrum_play = AudioServer.get_bus_effect_instance(0,0) spectrum_record = AudioServer.get_bus_effect_instance(1,1) - $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3/HBoxContainer/VBoxContainer/DelaySlider.value = Globals.audio_delay_seconds * 1000 position_changing_by_code = false + $MarginContainer/VBoxContainer/HBoxContainer4/SaveMode.add_item("Save separate streams") # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): @@ -61,12 +62,14 @@ func _on_RecButton_pressed(): if recorder.is_recording_active(): $MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer/MultiStreamVideoPlayer.stop() raw_recording = recorder.get_recording() + stream_data.append(raw_recording) current_stream_added = false $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/PlayButton.disabled = false recorder.set_recording_active(false) $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/RecordButton.text = "Record" $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/Status.text = "" - $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3/HBoxContainer/VBoxContainer2.set_count(recorded_streams) + $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3/HBoxContainer/MultiVolumeSlider.set_count(recorded_streams) + $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3/HBoxContainer/VBoxContainer/MultiDelaySlider.set_count(recorded_streams) else: $MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer/MultiStreamVideoPlayer.play_combined() @@ -89,7 +92,7 @@ func _on_PlayButton_pressed(): playing = false else: $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/PlayButton.text = "Stop" - $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/RecordButton.text = "Record another layer" + $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/RecordButton.text = "Record another layer (part)" $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/RecordButton.disabled = true if !current_stream_added: $MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer/MultiStreamVideoPlayer.add_audio_stream(raw_recording,$MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3/HBoxContainer/VBoxContainer/DelaySlider.value/1000) @@ -128,23 +131,35 @@ func _on_DelaySlider_value_changed(value): func _on_Quit_pressed(): get_tree().change_scene("res://main_menu.tscn") - func _on_MultiStreamVideoPlayer_finished(): if recorder.is_recording_active(): $MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer/MultiStreamVideoPlayer.stop() raw_recording = recorder.get_recording() + stream_data.append(raw_recording) current_stream_added = false $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/PlayButton.disabled = false recorder.set_recording_active(false) - $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/RecordButton.text = "Record another layer (part)" + $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/RecordButton.text = "Record" $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/Status.text = "" if playing: $MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer/MultiStreamVideoPlayer.stop() $MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/PlayButton.text = "Play" playing = false - func _on_VBoxContainer2_volume_changed(slider, value): print("Slider "+String(slider)+" changed to "+String(value)) $MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer/MultiStreamVideoPlayer.set_audio_volume_db(slider,linear2db(value/100)) pass # Replace with function body. + + +func _on_MultiDelaySlider_delay_changed(slider, value): + $MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer/MultiStreamVideoPlayer.set_stream_delay(slider,value/1000) + Globals.audio_delay_seconds = value/1000 + Globals.saveConfig() + pass # Replace with function body. + + +func _on_SaveButton_pressed(): + for streamid in range(0,len(stream_data)): + stream_data[streamid].save_to_wav("user://part"+String(streamid+1)+".wav") + pass # Replace with function body. diff --git a/godot/PlayVideoRecordAudio.tscn b/godot/PlayVideoRecordAudio.tscn index b9faf37..24839d4 100644 --- a/godot/PlayVideoRecordAudio.tscn +++ b/godot/PlayVideoRecordAudio.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://Components/MultiStreamPlayer.tscn" type="PackedScene" id=1] [ext_resource path="res://main_menu.gd" type="Script" id=2] [ext_resource path="res://PlayVideoRecordAudio.gd" type="Script" id=3] [ext_resource path="res://UI/src/meter.png" type="Texture" id=4] [ext_resource path="res://Components/MultiVolumeSlider.tscn" type="PackedScene" id=5] +[ext_resource path="res://Components/MultiDelaySlider.tscn" type="PackedScene" id=6] [sub_resource type="AudioStreamMicrophone" id=1] @@ -65,14 +66,14 @@ script = ExtResource( 2 ) [node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] margin_top = 24.0 margin_right = 1013.0 -margin_bottom = 305.0 +margin_bottom = 293.0 size_flags_horizontal = 3 size_flags_vertical = 3 alignment = 1 [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"] margin_right = 1013.0 -margin_bottom = 281.0 +margin_bottom = 269.0 size_flags_horizontal = 3 size_flags_vertical = 3 alignment = 1 @@ -81,52 +82,48 @@ alignment = 1 anchor_right = 0.0 anchor_bottom = 0.0 margin_right = 1013.0 -margin_bottom = 281.0 +margin_bottom = 269.0 size_flags_horizontal = 3 size_flags_vertical = 3 -paused = false -VideoDurationSeconds = 0 -stream_position = 0.0 -volume_db = 0.0 [node name="HBoxContainer3" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] -margin_top = 309.0 +margin_top = 297.0 margin_right = 1013.0 -margin_bottom = 590.0 +margin_bottom = 566.0 size_flags_horizontal = 3 size_flags_vertical = 3 alignment = 1 [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer3"] margin_right = 1013.0 -margin_bottom = 281.0 +margin_bottom = 269.0 size_flags_horizontal = 3 size_flags_vertical = 3 alignment = 1 [node name="RecordButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"] -margin_top = 26.0 +margin_top = 20.0 margin_right = 1013.0 -margin_bottom = 46.0 +margin_bottom = 40.0 text = "Record" [node name="PlayButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"] -margin_top = 50.0 +margin_top = 44.0 margin_right = 1013.0 -margin_bottom = 70.0 +margin_bottom = 64.0 disabled = true text = "Play" [node name="Status" type="RichTextLabel" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"] -margin_top = 74.0 +margin_top = 68.0 margin_right = 1013.0 -margin_bottom = 89.0 +margin_bottom = 83.0 fit_content_height = true [node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"] -margin_top = 93.0 +margin_top = 87.0 margin_right = 1013.0 -margin_bottom = 109.0 +margin_bottom = 103.0 [node name="Playbacklabel" type="RichTextLabel" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer"] margin_right = 110.0 @@ -149,9 +146,9 @@ texture_progress = ExtResource( 4 ) nine_patch_stretch = true [node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"] -margin_top = 113.0 +margin_top = 107.0 margin_right = 1013.0 -margin_bottom = 129.0 +margin_bottom = 123.0 [node name="Recordlabel" type="RichTextLabel" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer2"] margin_right = 110.0 @@ -171,9 +168,9 @@ texture_progress = ExtResource( 4 ) nine_patch_stretch = true [node name="HBoxContainer3" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"] -margin_top = 133.0 +margin_top = 127.0 margin_right = 1013.0 -margin_bottom = 251.0 +margin_bottom = 245.0 [node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3"] margin_right = 524.0 @@ -202,26 +199,14 @@ valign = 1 margin_left = 20.0 margin_right = 520.0 margin_bottom = 118.0 - -[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3/HBoxContainer/VBoxContainer"] -margin_right = 500.0 -margin_bottom = 14.0 -size_flags_horizontal = 3 -text = "Audio Delay : 0s" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="DelaySlider" type="HSlider" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3/HBoxContainer/VBoxContainer"] -margin_top = 18.0 -margin_right = 500.0 -margin_bottom = 34.0 rect_min_size = Vector2( 500, 0 ) -size_flags_horizontal = 3 -max_value = 1000.0 -editable = false -[node name="VBoxContainer2" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3/HBoxContainer" instance=ExtResource( 5 )] +[node name="MultiDelaySlider" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3/HBoxContainer/VBoxContainer" instance=ExtResource( 6 )] +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_right = 500.0 + +[node name="MultiVolumeSlider" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3/HBoxContainer" instance=ExtResource( 5 )] anchor_right = 0.0 anchor_bottom = 0.0 margin_left = 524.0 @@ -229,9 +214,28 @@ margin_right = 524.0 margin_bottom = 118.0 [node name="HBoxContainer4" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"] -margin_top = 255.0 +margin_top = 249.0 margin_right = 1013.0 -margin_bottom = 255.0 +margin_bottom = 249.0 + +[node name="HBoxContainer4" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +margin_top = 570.0 +margin_right = 1013.0 +margin_bottom = 590.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="SaveMode" type="OptionButton" parent="MarginContainer/VBoxContainer/HBoxContainer4"] +margin_right = 968.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 + +[node name="SaveButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer4"] +margin_left = 972.0 +margin_right = 1013.0 +margin_bottom = 20.0 +text = "Save" [node name="AudioStreamRecorder" type="AudioStreamPlayer" parent="."] stream = SubResource( 1 ) @@ -244,5 +248,6 @@ bus = "Record" [connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/RecordButton" to="." method="_on_RecButton_pressed"] [connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/PlayButton" to="." method="_on_PlayButton_pressed"] [connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3/HBoxContainer/VBoxContainer3/BackgroundaudioSlider" to="." method="_on_BackgroundaudioSlider_changed"] -[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3/HBoxContainer/VBoxContainer/DelaySlider" to="." method="_on_DelaySlider_value_changed"] -[connection signal="volume_changed" from="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3/HBoxContainer/VBoxContainer2" to="." method="_on_VBoxContainer2_volume_changed"] +[connection signal="delay_changed" from="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3/HBoxContainer/VBoxContainer/MultiDelaySlider" to="." method="_on_MultiDelaySlider_delay_changed"] +[connection signal="volume_changed" from="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer3/HBoxContainer/MultiVolumeSlider" to="." method="_on_VBoxContainer2_volume_changed"] +[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer4/SaveButton" to="." method="_on_SaveButton_pressed"]