Skip to content

Commit 0ec99cd

Browse files
make work with unfixed AudioStreamPlaybackMicrophone, and add uids
1 parent 93c2933 commit 0ec99cd

12 files changed

+33
-9
lines changed

Main.tscn

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ layout_mode = 2
8989
text = "New Card"
9090

9191
[node name="Physics" type="Button" parent="QuickOptions"]
92+
visible = false
9293
layout_mode = 2
9394
toggle_mode = true
9495
text = "Physics"

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ is done using a light-weight MQTT server, of which public versions are available
1616

1717
## Installation
1818

19-
This should run in Godot 4.3 or higher. The reusable component is in `addons/player-networking`
19+
This is targeting Godot 4.4 (now in beta release) due to a PR for a microphone bug.
20+
The reusable component is in `addons/player-networking`
2021
The system logic is embedded in a control panel that you can make invisible and operate externally with a
2122
restricted set of options tuned to your application, but it is exposed for the purpose of
2223
experimentation and debugging.

addons/player-networking/NetworkGateway.tscn

+2
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,8 @@ script = ExtResource("16_hf3ik")
573573
[node name="AudioStreamPlayerMicrophone" type="AudioStreamPlayer" parent="VBox/PlayerConnections/VBox/RecordingFeature"]
574574
stream = SubResource("2")
575575
volume_db = 10.0
576+
autoplay = true
577+
bus = &"MicrophoneBus"
576578

577579
[node name="MicStreamPlayerNotice" type="ColorRect" parent="VBox/PlayerConnections/VBox/RecordingFeature"]
578580
visible = false
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[gd_scene load_steps=2 format=3 uid="uid://dk0qrqaedfjm7"]
22

3-
[ext_resource type="Script" path="res://addons/player-networking/PlayerFrameRemote.gd" id="1_d7ino"]
3+
[ext_resource type="Script" uid="uid://getm81aitdl" path="res://addons/player-networking/PlayerFrameRemote.gd" id="1_d7ino"]
44

55
[node name="PlayerFrame" type="Node"]
66
script = ExtResource("1_d7ino")

addons/player-networking/RecordingFeature.gd

+20-5
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ func startmicafterpermissions(permission: String, granted: bool):
190190
printerr("Unknown permissions ", permission)
191191

192192
func _ready():
193-
if ClassDB.can_instantiate("AudioStreamPlaybackMicrophone"):
194-
print("Using AudioStreamPlaybackMicrophone")
193+
if ClassDB.class_has_method("AudioStreamPlaybackMicrophone", "start_microphone", true):
195194
audiostreamplaybackmicrophone = ClassDB.instantiate("AudioStreamPlaybackMicrophone")
195+
print("Using AudioStreamPlaybackMicrophone post PR#100508") # https://github.com/godotengine/godot/pull/100508
196196
$VoxThreshold.material.set_shader_parameter("voxthreshhold", voxthreshhold)
197197

198198
if audiostreamplaybackmicrophone != null:
@@ -221,11 +221,21 @@ func _ready():
221221

222222
else:
223223
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
227235
assert ($AudioStreamPlayerMicrophone.stream.is_class("AudioStreamMicrophone"))
228236
var microphonebusidx = AudioServer.get_bus_index($AudioStreamPlayerMicrophone.bus)
237+
if not AudioServer.is_bus_mute(microphonebusidx):
238+
printerr("Warning: MicrophoneBus not mute")
229239
for i in range(AudioServer.get_bus_effect_count(microphonebusidx)):
230240
if AudioServer.get_bus_effect(microphonebusidx, i).is_class("AudioEffectOpusChunked"):
231241
audioopuschunkedeffect = AudioServer.get_bus_effect(microphonebusidx, i)
@@ -239,6 +249,11 @@ func _ready():
239249
printerr("Unabled to find or instantiate AudioEffectOpusChunked on MicrophoneBus")
240250
$OpusWarningLabel.visible = true
241251

252+
await get_tree().create_timer(2.0).timeout
253+
print("Setting AudioStreamPlayerMicrophone to play")
254+
$AudioStreamPlayerMicrophone.play()
255+
256+
242257
func _on_vox_toggled(toggled_on):
243258
$PTT.toggle_mode = toggled_on
244259

controlplayer.gd.uid

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://bsetsw3b7qvrk

default_bus_layout.tres

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ volume_db = -30.0
1313

1414
[resource]
1515
bus/0/effect/0/effect = SubResource("AudioEffectReverb_mpj3y")
16-
bus/0/effect/0/enabled = true
16+
bus/0/effect/0/enabled = false
1717
bus/1/name = &"MicrophoneBus"
1818
bus/1/solo = false
1919
bus/1/mute = true

mulitplayerspawntoy.gd.uid

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://2kod4qi57vkj

mulitplayerspawntoy.tscn

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[gd_scene load_steps=6 format=3 uid="uid://bngiijug5ydb4"]
22

3-
[ext_resource type="Script" uid="uid://b7gs84tw3eul1" path="res://mulitplayerspawntoy.gd" id="1_idxh0"]
3+
[ext_resource type="Script" uid="uid://2kod4qi57vkj" path="res://mulitplayerspawntoy.gd" id="1_idxh0"]
44

55
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_5t88t"]
66
properties/0/path = NodePath(".:position")

multiplayerspawner.gd.uid

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://c18eodmk2sy7g

quickoptionsmenu.gd.uid

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://djl37ucyvmcxl

syncobjects.gd.uid

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://bm1kgq8280lgs

0 commit comments

Comments
 (0)