private void InitAudio() { //setup audio if there is one inside the 4ds file int audioSize = Bridge4DS.GetAudioBufferSize(_dataSource.FDVUUID); if (audioSize > 0) { GameObject audioNode; AudioSource audioSource; //check if audio node already exists Sync4DS sync = GetComponent <Sync4DS>(); if (sync._audioSources.Length > 0 && sync._audioSources[0].audioSource) { audioSource = sync._audioSources[0].audioSource; audioNode = sync._audioSources[0].audioSource.gameObject; } else { audioNode = new GameObject("Audio4DS"); audioNode.transform.parent = this.transform.parent; audioSource = audioNode.AddComponent <AudioSource>(); } int nbSamples = Bridge4DS.GetAudioNbSamples(_dataSource.FDVUUID); samples = new float[nbSamples * Bridge4DS.GetAudioNbChannels(_dataSource.FDVUUID)]; audioBufferHandle = GCHandle.Alloc(samples, GCHandleType.Pinned); Bridge4DS.GetAudioBuffer(_dataSource.FDVUUID, audioBufferHandle.AddrOfPinnedObject()); audioSource.clip = AudioClip.Create("audioInside4ds", nbSamples, Bridge4DS.GetAudioNbChannels(_dataSource.FDVUUID), Bridge4DS.GetAudioSampleRate(_dataSource.FDVUUID), false); audioSource.clip.SetData(samples, 0); Sync4DS synchro = GetComponent <Sync4DS>(); synchro._audioSources[0].audioSource = audioSource; synchro.enabled = true; } }