mirror of
https://github.com/thegatesbrowser/godot-multiplayer.git
synced 2025-09-22 11:26:56 -04:00
enable denoiser
This commit is contained in:
parent
8addd2966f
commit
daeb19b69f
1 changed files with 18 additions and 0 deletions
|
@ -2,9 +2,12 @@ extends Node
|
|||
|
||||
@export var user_scn: PackedScene
|
||||
@export var player_spawner: PlayerSpawner
|
||||
@export var denoise_mic_input: bool = true
|
||||
|
||||
var opuschunked: AudioEffectOpusChunked
|
||||
var denoiser_available: bool
|
||||
var prepend: PackedByteArray = PackedByteArray()
|
||||
|
||||
var users = {} # {Peer ID: VoipUser}
|
||||
|
||||
|
||||
|
@ -17,6 +20,9 @@ func _ready() -> void:
|
|||
|
||||
var mic_bus = AudioServer.get_bus_index("Record")
|
||||
opuschunked = AudioServer.get_bus_effect(mic_bus, 0)
|
||||
denoiser_available = opuschunked.denoiser_available()
|
||||
print("Denoiser available: ", denoiser_available)
|
||||
print_audio_server_info()
|
||||
|
||||
|
||||
func peer_connected(id: int) -> void:
|
||||
|
@ -54,6 +60,9 @@ func _process(_delta: float) -> void:
|
|||
opuschunked.drop_chunk()
|
||||
continue
|
||||
|
||||
if denoiser_available and denoise_mic_input:
|
||||
opuschunked.denoise_resampled_chunk()
|
||||
|
||||
var opusdata: PackedByteArray = opuschunked.read_opus_packet(prepend)
|
||||
opuschunked.drop_chunk()
|
||||
accumulated_opusdata.append(opusdata)
|
||||
|
@ -68,3 +77,12 @@ func opus_data_received(opusdata_array: Array[PackedByteArray]) -> void:
|
|||
|
||||
var sender_id = multiplayer.get_remote_sender_id()
|
||||
users[sender_id].opuspacketsbuffer.append_array(opusdata_array)
|
||||
|
||||
|
||||
func print_audio_server_info() -> void:
|
||||
# For debugging sample rate issues
|
||||
print("AudioServer:")
|
||||
print("Input device list: ", AudioServer.get_input_device_list())
|
||||
print("Output device list: ", AudioServer.get_output_device_list())
|
||||
print("Input mix rate: only available in Godot 4.4+")
|
||||
print("Output mix rate: ", AudioServer.get_mix_rate())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue