@@ -190,9 +190,9 @@ func startmicafterpermissions(permission: String, granted: bool):
190
190
printerr ("Unknown permissions " , permission )
191
191
192
192
func _ready ():
193
- if ClassDB .can_instantiate ("AudioStreamPlaybackMicrophone" ):
194
- print ("Using AudioStreamPlaybackMicrophone" )
193
+ if ClassDB .class_has_method ("AudioStreamPlaybackMicrophone" , "start_microphone" , true ):
195
194
audiostreamplaybackmicrophone = ClassDB .instantiate ("AudioStreamPlaybackMicrophone" )
195
+ print ("Using AudioStreamPlaybackMicrophone post PR#100508" ) # https://github.com/godotengine/godot/pull/100508
196
196
$ VoxThreshold .material .set_shader_parameter ("voxthreshhold" , voxthreshhold )
197
197
198
198
if audiostreamplaybackmicrophone != null :
@@ -221,11 +221,21 @@ func _ready():
221
221
222
222
else :
223
223
if $ AudioStreamPlayerMicrophone .bus != "MicrophoneBus" :
224
- printerr ("AudioStreamPlayerMicrophone doesn't use bus called MicrophoneBus, disabling" )
225
- $ AudioStreamPlayerMicrophone .stop ()
226
- return
224
+ var lmicrophonebusidx = AudioServer .get_bus_index ("MicrophoneBus" )
225
+ if lmicrophonebusidx == - 1 :
226
+ print ("Warning: Adding a MicrophoneBus" )
227
+ lmicrophonebusidx = AudioServer .get_bus_count () - 1
228
+ AudioServer .set_bus_name (lmicrophonebusidx , "MicrophoneBus" )
229
+ AudioServer .set_bus_mute (lmicrophonebusidx , true )
230
+ print ("Warning: Setting AudioStreamPlayerMicrophone to the MicrophoneBus" )
231
+ $ AudioStreamPlayerMicrophone .bus = "MicrophoneBus"
232
+ # printerr("AudioStreamPlayerMicrophone doesn't use bus called MicrophoneBus, disabling")
233
+ # $AudioStreamPlayerMicrophone.stop()
234
+ # return
227
235
assert ($ AudioStreamPlayerMicrophone .stream .is_class ("AudioStreamMicrophone" ))
228
236
var microphonebusidx = AudioServer .get_bus_index ($ AudioStreamPlayerMicrophone .bus )
237
+ if not AudioServer .is_bus_mute (microphonebusidx ):
238
+ printerr ("Warning: MicrophoneBus not mute" )
229
239
for i in range (AudioServer .get_bus_effect_count (microphonebusidx )):
230
240
if AudioServer .get_bus_effect (microphonebusidx , i ).is_class ("AudioEffectOpusChunked" ):
231
241
audioopuschunkedeffect = AudioServer .get_bus_effect (microphonebusidx , i )
@@ -239,6 +249,11 @@ func _ready():
239
249
printerr ("Unabled to find or instantiate AudioEffectOpusChunked on MicrophoneBus" )
240
250
$ OpusWarningLabel .visible = true
241
251
252
+ await get_tree ().create_timer (2.0 ).timeout
253
+ print ("Setting AudioStreamPlayerMicrophone to play" )
254
+ $ AudioStreamPlayerMicrophone .play ()
255
+
256
+
242
257
func _on_vox_toggled (toggled_on ):
243
258
$ PTT .toggle_mode = toggled_on
244
259
0 commit comments