Use $TwoVoipMic.init_voip_mic() to set up the microphone input.
Parameters:
json_packets_as_binary (bool): If true, JSON headers/footers are stringified and emitted via the transmit_audio_packet signal instead of the transmit_audio_json_packet signal. This simplifies networking but prevents intercepting JSON metadata.MicOn, PTT, Vox, Denoise (optional): UI buttons to control microphone state.InputOption (OptionButton): An OptionButton populated with AudioServer.get_input_device_list().voxshader.gdshader (ShaderMaterial): A material used to render an activity waveform.
Opus Configuration:
Configure the encoder using set_opus_values(opussamplerate, opusframedurationms, channels, opusbitrate, opuscomplexity, opusoptimizeforvoice, denoiser, agc_mode):
opussamplerate: [48000, 24000, 12000, 8000]opusframedurationms: [5, 10, 20, 40, 60]channels: 1 (mono) or 2 (stereo)opusbitrate: 500 to 64000opuscomplexity: 1 to 10opusoptimizeforvoice: boolean
Vox Settings:
set_voxthreshhold(voxthreshhold): Sets the gating threshold (used by the shader).hangtime: Time the mic stays active after noise falls below threshold.leadtime: (Not implemented) Buffer time captured before threshold is reached.
# Example initialization concept
$TwoVoipMic.init_voip_mic(true, mic_on_btn, ptt_btn, vox_btn, denoise_btn, input_option_button, vox_shader_material)
$TwoVoipMic.set_opus_values(48000, 20, 1, 32000, 5, true, denoiser_mode, agc_mode)
$TwoVoipMic.set_voxthreshhold(0.5)