Skip to content

Commit

Permalink
ability to record the uncompressed recording
Browse files Browse the repository at this point in the history
  • Loading branch information
goatchurchprime committed Oct 22, 2024
1 parent 6d2d4e0 commit f60a06a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
22 changes: 21 additions & 1 deletion example/radiomqtt/radiomqtt.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
26 changes: 22 additions & 4 deletions example/radiomqtt/radiomqtt.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"]
Expand Down
1 change: 0 additions & 1 deletion godot-cpp
Submodule godot-cpp deleted from a4f9d2

0 comments on commit f60a06a

Please sign in to comment.