diff --git a/audio/mic_record/Node2D.gd b/audio/mic_record/MicRecord.gd similarity index 74% rename from audio/mic_record/Node2D.gd rename to audio/mic_record/MicRecord.gd index 0524a6d5..e6dddeef 100644 --- a/audio/mic_record/Node2D.gd +++ b/audio/mic_record/MicRecord.gd @@ -1,4 +1,4 @@ -extends Node2D +extends Node var effect var recording @@ -8,17 +8,19 @@ func _ready(): effect = AudioServer.get_bus_effect(idx, 0) func _on_RecordButton_pressed(): - if (effect.is_recording_active()): + if effect.is_recording_active(): recording = effect.get_recording() $PlayButton.disabled = false $SaveButton.disabled = false effect.set_recording_active(false) $RecordButton.text = "Record" + $Status.text = "" else: $PlayButton.disabled = true $SaveButton.disabled = true effect.set_recording_active(true) $RecordButton.text = "Stop" + $Status.text = "Recording..." func _on_PlayButton_pressed(): print(recording) @@ -32,7 +34,7 @@ func _on_PlayButton_pressed(): $AudioStreamPlayer.play() func _on_Play_Music_pressed(): - if ($AudioStreamPlayer2.playing): + if $AudioStreamPlayer2.playing: $AudioStreamPlayer2.stop() $PlayMusic.text = "Play Music" else: @@ -40,4 +42,6 @@ func _on_Play_Music_pressed(): $PlayMusic.text = "Stop Music" func _on_SaveButton_pressed(): - recording.save_to_wav($SaveButton/Filename.text) + var save_path = $SaveButton/Filename.text + recording.save_to_wav(save_path) + $Status.text = "Saved WAV file to: %s\n(%s)" % [save_path, ProjectSettings.globalize_path(save_path)] diff --git a/audio/mic_record/Node2D.tscn b/audio/mic_record/MicRecord.tscn similarity index 68% rename from audio/mic_record/Node2D.tscn rename to audio/mic_record/MicRecord.tscn index 0d76607e..08132d1f 100644 --- a/audio/mic_record/Node2D.tscn +++ b/audio/mic_record/MicRecord.tscn @@ -1,11 +1,11 @@ [gd_scene load_steps=4 format=2] -[ext_resource path="res://Node2D.gd" type="Script" id=1] +[ext_resource path="res://MicRecord.gd" type="Script" id=1] [ext_resource path="res://Intro.ogg" type="AudioStream" id=2] [sub_resource type="AudioStreamMicrophone" id=1] -[node name="Node2D" type="Node2D"] +[node name="MicRecord" type="Node"] script = ExtResource( 1 ) [node name="AudioStreamRecord" type="AudioStreamPlayer" parent="."] @@ -23,33 +23,45 @@ volume_db = -6.0 [node name="RecordButton" type="Button" parent="."] margin_left = 120.0 margin_top = 60.0 -margin_bottom = 78.0 +margin_right = 240.0 +margin_bottom = 100.0 text = "Record" [node name="SaveButton" type="Button" parent="."] -editor/display_folded = true margin_left = 120.0 -margin_top = 120.0 +margin_top = 140.0 +margin_right = 240.0 +margin_bottom = 180.0 disabled = true -text = "Save Wav To:" +text = "Save WAV To:" -[node name="Filename" type="Label" parent="SaveButton"] -margin_left = 120.0 -margin_right = 440.0 -margin_bottom = 20.0 +[node name="Filename" type="LineEdit" parent="SaveButton"] +margin_left = 180.0 +margin_right = 340.0 +margin_bottom = 40.0 text = "user://record.wav" [node name="PlayButton" type="Button" parent="."] -margin_left = 240.0 +margin_left = 300.0 margin_top = 60.0 +margin_right = 420.0 +margin_bottom = 100.0 disabled = true text = "Play" [node name="PlayMusic" type="Button" parent="."] margin_left = 120.0 -margin_top = 180.0 +margin_top = 220.0 +margin_right = 240.0 +margin_bottom = 260.0 text = "Play Music" +[node name="Status" type="Label" parent="."] +margin_left = 120.0 +margin_top = 300.0 +margin_right = 520.0 +margin_bottom = 340.0 + [connection signal="pressed" from="RecordButton" to="." method="_on_RecordButton_pressed"] [connection signal="pressed" from="SaveButton" to="." method="_on_SaveButton_pressed"] [connection signal="pressed" from="PlayButton" to="." method="_on_PlayButton_pressed"] diff --git a/audio/mic_record/icon.png.import b/audio/mic_record/icon.png.import index 45ee6af7..96cbf462 100644 --- a/audio/mic_record/icon.png.import +++ b/audio/mic_record/icon.png.import @@ -3,6 +3,9 @@ importer="texture" type="StreamTexture" path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} [deps] diff --git a/audio/mic_record/project.godot b/audio/mic_record/project.godot index 5bb817df..a104f991 100644 --- a/audio/mic_record/project.godot +++ b/audio/mic_record/project.godot @@ -15,8 +15,8 @@ _global_script_class_icons={ [application] -config/name="MicRecord" -run/main_scene="res://Node2D.tscn" +config/name="Mic Record Demo" +run/main_scene="res://MicRecord.tscn" config/icon="res://icon.png" [audio] @@ -27,6 +27,8 @@ enable_audio_input=true window/size/width=640 window/size/height=480 +window/stretch/mode="2d" +window/stretch/aspect="expand" [rendering]