dissonance works properly now. Fixed list audio id to reset properly

handTracking
Kyle Johnsen 2022-01-03 08:29:50 -05:00
parent bbbfd7afb0
commit 6ac6bb3fc8
3 changed files with 12 additions and 120 deletions

View File

@ -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<FixedArray> toSend = new List<FixedArray>();
@ -29,12 +28,7 @@ public class NetworkPlayer : MonoBehaviour
bool isSpeaking = false;
void Start()
{
source = GetComponent<AudioSource>();
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<byte> 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)

View File

@ -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}

View File

@ -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<byte>(data), sequenceNumber);
Debug.Log(sequenceNumber);
VoicePacket vp = new VoicePacket(sender, ChannelPriority.Default, 1, false, new ArraySegment<byte>(data,0,data.Length), sequenceNumber);
VoicePacketReceived(vp);
}