I am trying to compute the pitch detection on my singing app.
here is my audio bus structure
extends Control
var effect
var recording
var buffer_index=1
func _ready() → void:
var idx = AudioServer.get_bus_index("Record")
effect = AudioServer.get_bus_effect(idx, 0)
print(effect)
print(effect.get_frames_available())
func _process(delta: float) → void:
print(effect.get_frames_available(), effect.can_get_buffer(effect.get_frames_available()))
var samples = effect.get_buffer(effect.get_frames_available())
if len(samples):
print(0x7fff * samples[0].x, "hello")
print(len(effect.get_buffer(effect.get_frames_available())))
effect.clear_buffer()
print("-----------")
the output is
AudioEffectCapture#-9223372009390471939
512 true
0 len of sample 512
-----------
512 true
0 len of sample 512
-----------
0 true
-----------
0 true
-----------
0 true
-----------
0 true
and when in try to print the sample is having a list of tuples [(0,0), (0,0), …, (0,0) 512 elements]
how to debug this, does it means that adding a Capture doesn’t start audio recording automatically? do we need to call any function to capture the audio?
in the documentation what is the meaning of the frames? its not clear from that, i am using FFT for computing the pitch, i need a buffer size of 2^14, how can i get that from this.
note 1: i tried with the “record” effect also still the same the audio is not recording, when print the get_data() it shows all zeros.
note 2: i checked the true for audio input in my project settings