updates
This commit is contained in:
parent
276d43613d
commit
4298caf5cb
552 changed files with 42990 additions and 776 deletions
31
game/scripts/coop_voice.gd
Normal file
31
game/scripts/coop_voice.gd
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
class_name CoopVoice
|
||||
extends VoiceChat
|
||||
## Voice chat in co-op: GD-Sync's VoiceChat, one per player at the same path on both machines
|
||||
## (CoopSession/Voice1 for player 1, Voice2 for player 2). Each is owned by its player's GD-Sync
|
||||
## client: the owner's microphone is recorded (above GD-Sync's volume threshold) and sent, and
|
||||
## the other machine plays it on the Voice bus. This adds when the voice was last heard, for the
|
||||
## "speaking" mark on the partner HUD and the name tag.
|
||||
|
||||
## Seconds of the game clock when audio last arrived (-1000 = never).
|
||||
var last_heard: float = -1000.0
|
||||
|
||||
|
||||
static func make(slot: int) -> CoopVoice:
|
||||
var v := CoopVoice.new()
|
||||
v.name = "Voice%d" % (slot + 1)
|
||||
v.input_volume_threshold = 0.025 # above room noise (GD-Sync's default is 0.01)
|
||||
var out := AudioStreamPlayer.new()
|
||||
out.name = "Out"
|
||||
out.bus = &"Voice"
|
||||
v.add_child(out)
|
||||
v.set_output_player(out)
|
||||
return v
|
||||
|
||||
|
||||
func speaking() -> bool:
|
||||
return Time.get_ticks_msec() / 1000.0 - last_heard < 0.35
|
||||
|
||||
|
||||
func _process_audio(audio: PackedFloat32Array, mixrate: float) -> void:
|
||||
last_heard = Time.get_ticks_msec() / 1000.0
|
||||
super(audio, mixrate)
|
||||
Loading…
Add table
Add a link
Reference in a new issue