How to record Audio on godot

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Saxe

Hello,

I’m trying to make audio recordings using busses and AudioStreamPlayer.
I tried to do the tutorial: https://github.com/godotengine/godot-demo-projects/tree/master/audio/mic_record

I tried on Linux and on Android it doesn’t work, I think I set something wrong.

Did anyone manage to make any recordings with this tutorial?`

extends Control

var effect
var recording

func _ready():

# We get the index of the "Record" bus.
var idx = AudioServer.get_bus_index("Record")
# And use it to retrieve its first effect, which has been defined
# as an "AudioEffectRecord" resource.
effect = AudioServer.get_bus_effect(idx, 0)

func _on_Listen_pressed():

find_node("ListenAudio").play()

func _on_Record_pressed():

if effect.is_recording_active():
	endRecording()
	print("end recording")

else:
	effect.set_recording_active(true)
	print("recording")
	find_node("Timer").start()
	

func _on_ListenRecord_pressed():

find_node("ListenRecordAudio").play()

func _on_Timer_timeout():

endRecording()
find_node("Timer").stop()
print("end recording timer")

func endRecording():

find_node("ListenRecord").modulate.a = 1
effect.set_recording_active(false)
recording = effect.get_recording()
print(recording)
print(recording.format)
print(recording.mix_rate)
print(recording.stereo)
var data = recording.get_data()
for i in range(0, data.size()):
	print(data[i])
print(data)
print(data.size())
find_node("ListenRecordAudio").stream = recording

`

Thank’s all

:bust_in_silhouette: Reply From: Calinou

There are known issues with audio recording on Linux, see #33184.

:bust_in_silhouette: Reply From: Gazi Safin

I tried but, got error at effect.set_recording_active(true). It says null function.
So, I downloaded the demo which, worked.
I also narrowed down the problem by comparing and eventually found only one.
When I clicked record bus, I saw the path value set to something in the resource while Mine wasn’t. But copy-pasting didn’t solve it.

Image