From 6ac6bb3fc8930dfd37f011b771ef930702a37488 Mon Sep 17 00:00:00 2001 From: Kyle Johnsen Date: Mon, 3 Jan 2022 08:29:50 -0500 Subject: [PATCH] dissonance works properly now. Fixed list audio id to reset properly --- TestVelGameServer/Assets/NetworkPlayer.cs | 30 ++---- .../Assets/Plugins/PlayerPrefab.prefab | 99 +------------------ TestVelGameServer/Assets/VelCommsNetwork.cs | 3 +- 3 files changed, 12 insertions(+), 120 deletions(-) diff --git a/TestVelGameServer/Assets/NetworkPlayer.cs b/TestVelGameServer/Assets/NetworkPlayer.cs index d8500a4..0301211 100644 --- a/TestVelGameServer/Assets/NetworkPlayer.cs +++ b/TestVelGameServer/Assets/NetworkPlayer.cs @@ -12,9 +12,8 @@ public class NetworkPlayer : MonoBehaviour public string room; public NetworkManager manager; Vector3 networkPosition; - velmicrophone mic; - AudioClip speechClip; - AudioSource source; + + bool buffering = false; public List toSend = new List(); @@ -29,12 +28,7 @@ public class NetworkPlayer : MonoBehaviour bool isSpeaking = false; void Start() { - source = GetComponent(); - speechClip = AudioClip.Create("speechclip", 160000, 1, 16000, false); - source.clip = speechClip; - source.Stop(); - source.loop = true; - source.spatialBlend = 0; + if (manager.userid == userid) //this is me, I send updates { StartCoroutine(syncTransformCoroutine()); @@ -64,6 +58,10 @@ public class NetworkPlayer : MonoBehaviour { isSpeaking = !isSpeaking; manager.sendTo(0, "4," + (isSpeaking?1:0) + ";"); + if (!isSpeaking) + { + lastAudioId = 0; + } } } @@ -128,13 +126,11 @@ public class NetworkPlayer : MonoBehaviour if(sections[1] == "0") { commsNetwork.playerStoppedSpeaking(dissonanceID); - lastAudioId = 0; isSpeaking = false; } else { commsNetwork.playerStartedSpeaking(dissonanceID); - lastAudioId = 0; isSpeaking = true; } break; @@ -146,20 +142,10 @@ public class NetworkPlayer : MonoBehaviour - IEnumerator startSoundIn(int frames) - { - buffering = true; - for(int i = 0; i < frames; i++) - { - yield return null; - } - source.Play(); - buffering = false; - } public void sendAudioData(ArraySegment data) { string b64_data = Convert.ToBase64String(data.Array,data.Offset,data.Count); - manager.sendTo(0, "2,"+b64_data + ","+lastAudioId++ +";"); + manager.sendTo(0, "2,"+b64_data + ","+ (lastAudioId++) +";"); } public void setDissonanceID(string id) diff --git a/TestVelGameServer/Assets/Plugins/PlayerPrefab.prefab b/TestVelGameServer/Assets/Plugins/PlayerPrefab.prefab index 763a90b..9c236d9 100644 --- a/TestVelGameServer/Assets/Plugins/PlayerPrefab.prefab +++ b/TestVelGameServer/Assets/Plugins/PlayerPrefab.prefab @@ -13,7 +13,6 @@ GameObject: - component: {fileID: 6854617867369839} - component: {fileID: 5845716565458182149} - component: {fileID: 5713671764962751473} - - component: {fileID: 419667223} m_Layer: 0 m_Name: PlayerPrefab m_TagString: Untagged @@ -111,102 +110,8 @@ MonoBehaviour: m_EditorClassIdentifier: userid: 0 username: + dissonanceID: room: manager: {fileID: 0} isLocal: 0 ---- !u!82 &419667223 -AudioSource: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6139051692386484099} - m_Enabled: 1 - serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 0} - m_PlayOnAwake: 1 - m_Volume: 1 - m_Pitch: 1 - Loop: 0 - Mute: 0 - Spatialize: 0 - SpatializePostEffects: 0 - Priority: 128 - DopplerLevel: 1 - MinDistance: 1 - MaxDistance: 500 - Pan2D: 0 - rolloffMode: 0 - BypassEffects: 0 - BypassListenerEffects: 0 - BypassReverbZones: 0 - rolloffCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - - serializedVersion: 3 - time: 1 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - panLevelCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - spreadCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - reverbZoneMixCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 + commsNetwork: {fileID: 0} diff --git a/TestVelGameServer/Assets/VelCommsNetwork.cs b/TestVelGameServer/Assets/VelCommsNetwork.cs index ec33476..a270ec5 100644 --- a/TestVelGameServer/Assets/VelCommsNetwork.cs +++ b/TestVelGameServer/Assets/VelCommsNetwork.cs @@ -70,7 +70,8 @@ namespace Dissonance public void voiceReceived(string sender,byte[] data,uint sequenceNumber) { - VoicePacket vp = new VoicePacket(sender, ChannelPriority.Default, 1, false, new ArraySegment(data), sequenceNumber); + Debug.Log(sequenceNumber); + VoicePacket vp = new VoicePacket(sender, ChannelPriority.Default, 1, false, new ArraySegment(data,0,data.Length), sequenceNumber); VoicePacketReceived(vp); }