public message MakeMessageFromClip() { message sound = new message("sendSound"); audioSource.clip = aud; float[] samples = new float[audioSource.clip.samples * audioSource.clip.channels]; audioSource.clip.GetData(samples, 0); int cpt = 0; NetObject subSound = new NetObject("subSound"); subSound.addInt("", samples.Length); for (int i = 0; i < samples.Length; i++) { if (cpt == 250) { sound.addNetObject(subSound); subSound = new NetObject("subSound"); cpt = 0; } subSound.addFloat("", (Mathf.Floor(samples[i] * 1000) / 1000)); cpt++; } return(sound); }
public message MakeMessageFromClip() { message sound = new message("sendSound"); audioSource.clip = aud; float[] samples = new float[audioSource.clip.samples * audioSource.clip.channels]; audioSource.clip.GetData(samples, 0); int cpt = 0; NetObject subSound = new NetObject("subSound"); subSound.addInt("", samples.Length); for (int i = 0; i < samples.Length; i++) { if (cpt == 250) { sound.addNetObject(subSound); subSound = new NetObject("subSound"); cpt = 0; } subSound.addFloat("", (Mathf.Floor(samples[i] * 1000) / 1000)); cpt++; } return sound; }