From f60a06a9ea19a2ab7dd31985337ed39ed5da2bb8 Mon Sep 17 00:00:00 2001 From: Julian Todd Date: Tue, 22 Oct 2024 19:41:25 +0100 Subject: [PATCH] ability to record the uncompressed recording --- example/radiomqtt/radiomqtt.gd | 22 +++++++++++++++++++++- example/radiomqtt/radiomqtt.tscn | 26 ++++++++++++++++++++++---- godot-cpp | 1 - 3 files changed, 43 insertions(+), 6 deletions(-) delete mode 160000 godot-cpp diff --git a/example/radiomqtt/radiomqtt.gd b/example/radiomqtt/radiomqtt.gd index 7758bf0..17aa27f 100644 --- a/example/radiomqtt/radiomqtt.gd +++ b/example/radiomqtt/radiomqtt.gd @@ -363,7 +363,7 @@ func endtalking(): func _on_play_pressed(): if audioeffectpitchshift != null: - var speedup = $HBoxPlaycount/StreamSpeedup.value + var speedup = $HBoxPlaycount/VBoxExpt/StreamSpeedup.value AudioServer.set_bus_effect_enabled(speechbusidx, audioeffectpitchshiftidx, (speedup != 1.0)) SelfMember.get_node("AudioStreamPlayer").pitch_scale = speedup #audioeffectpitchshift.pitch_scale = 1.0/speedup @@ -387,6 +387,26 @@ func _on_play_pressed(): assert (SelfMember.resampledpacketsbuffer == null) SelfMember.audiopacketsbuffer = lrecordedsamples +var saveplaybackfile = "user://savedplayback.dat" +func _on_sav_options_item_selected(index): + pass # Replace with function body. + if index == 1: + var f = FileAccess.open(saveplaybackfile, FileAccess.WRITE) + print("Saving to file", f.get_path_absolute()) + f.store_var({"audiosamplerate":audiosamplerate, + "recordedsamples":recordedsamples}) + f.close() + elif index == 2: + var f = FileAccess.open(saveplaybackfile, FileAccess.READ) + print("Loading from file", f.get_path_absolute()) + var dat = f.get_var() + if audiosamplerate != dat["audiosamplerate"]: + prints(" sample rates disagree!!", dat["audiosamplerate"], audiosamplerate) + recordedsamples = dat["recordedsamples"] + f.close() + $HBoxPlaycount/VBoxExpt/SavOptions.select(0) + + func _on_frame_duration_item_selected(_index): updatesamplerates() diff --git a/example/radiomqtt/radiomqtt.tscn b/example/radiomqtt/radiomqtt.tscn index c714952..3140842 100644 --- a/example/radiomqtt/radiomqtt.tscn +++ b/example/radiomqtt/radiomqtt.tscn @@ -299,15 +299,32 @@ theme_override_styles/normal = SubResource("StyleBoxFlat_icid5") text = "Play " -[node name="StreamSpeedup" type="SpinBox" parent="HBoxPlaycount"] -custom_minimum_size = Vector2(30, 60) +[node name="VBoxExpt" type="VBoxContainer" parent="HBoxPlaycount"] layout_mode = 2 -tooltip_text = "Playback speed" +size_flags_horizontal = 0 +size_flags_vertical = 0 + +[node name="StreamSpeedup" type="SpinBox" parent="HBoxPlaycount/VBoxExpt"] +layout_mode = 2 +size_flags_horizontal = 0 +tooltip_text = "Playback speed +(experimental)" min_value = 0.1 max_value = 3.0 step = 0.1 value = 1.0 -alignment = 1 + +[node name="SavOptions" type="OptionButton" parent="HBoxPlaycount/VBoxExpt"] +layout_mode = 2 +selected = 0 +item_count = 4 +popup/item_0/text = "(actions)" +popup/item_1/text = "Save" +popup/item_1/id = 1 +popup/item_2/text = "Load" +popup/item_2/id = 2 +popup/item_3/text = "Transmit" +popup/item_3/id = 3 [node name="VSeparator" type="VSeparator" parent="HBoxPlaycount"] custom_minimum_size = Vector2(20, 0) @@ -654,6 +671,7 @@ text = "sil" [connection signal="toggled" from="HBoxMicTalk/MicWorking" to="." method="_on_mic_working_toggled"] [connection signal="value_changed" from="HBoxMicTalk/HSliderVox" to="HBoxMicTalk" method="_on_h_slider_vox_value_changed"] [connection signal="pressed" from="HBoxPlaycount/Play" to="." method="_on_play_pressed"] +[connection signal="item_selected" from="HBoxPlaycount/VBoxExpt/SavOptions" to="." method="_on_sav_options_item_selected"] [connection signal="item_selected" from="VBoxFrameLength/HBoxOpusFrame/FrameDuration" to="." method="_on_frame_duration_item_selected"] [connection signal="item_selected" from="VBoxFrameLength/HBoxOpusFrame/SampleRate" to="." method="_on_sample_rate_item_selected"] [connection signal="item_selected" from="VBoxFrameLength/HBoxAudioFrame/ResampleState" to="." method="_on_resample_state_item_selected"] diff --git a/godot-cpp b/godot-cpp deleted file mode 160000 index a4f9d22..0000000 --- a/godot-cpp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a4f9d22ac54e05ca6a41d54a59afd7555cb7d292