Beispiel #1
0
        public void OnStkInitialized(SoundToolKitManager soundToolKitManager)
        {
            if (!Initialized)
            {
                SoundToolKitDebug.Assert(soundToolKitManager.StkAudioEngine != null, "Audio engine is not initialized. Logical error.");

                m_acousticMesh      = soundToolKitManager.StkAudioEngine.ResourcesFactory.CreateMesh();
                m_acousticMesh.Name = gameObject.name;

                UpdateProperties();

                var mesh = GetComponent <MeshFilter>().mesh;
                if (mesh != null)
                {
                    Mesh = mesh;
                }
                else
                {
                    SoundToolKitDebug.LogWarning("UnityEngine.Mesh not present in this component. Cannot AutoRegister.");
                }

                soundToolKitManager.ResourceContainer.Add(acousticMesh: this);

                if (soundToolKitManager.ResourceContainer.Geometry != null && MeshCluster == null)
                {
                    MeshCluster = soundToolKitManager.ResourceContainer.Geometry.GetTemporaryMeshCluster();
                }

                Initialized = true;
            }
        }
Beispiel #2
0
 private void CheckMeshClusterSynchronization()
 {
     if (MeshCluster != null && !MeshCluster.AcousticMeshNames.Contains(CombinedName()))
     {
         SoundToolKitDebug.LogWarning("Mesh: " + name + " was assigned to MeshCluster: " +
                                      MeshCluster.name + " but was not found on that Cluster's MeshList.\n" +
                                      "Probably a desynchronization occured due to deleting Meshes from the scene.\n" +
                                      "Please make sure everything is assigned correctly for the scene geometry to work as intended.");
     }
 }
 public override void Stop()
 {
     if (m_streamingSample != null)
     {
         Playback.Stop();
     }
     else
     {
         SoundToolKitDebug.LogWarning("StkStreamingSource is not initialized in: " + gameObject.name);
     }
 }
Beispiel #4
0
 private bool PlaybackListNotEmpty(List <SoundToolKitPlayback> playbacks)
 {
     if (playbacks.Any())
     {
         return(true);
     }
     else
     {
         SoundToolKitDebug.LogWarning("Playback List for SoundToolKitspatialSource is empty. No Playback to Play.");
         return(false);
     }
 }
        private void ReInitialize()
        {
            SoundToolKitDebug.LogWarning("Manager became unusable. Trying to re-initialize.");

            //TODO: [Not Tested]: This should be tested when AudioEngine is not Good.
            m_audioBridge.Dispose();
            StkAudioEngine.Dispose();

            //Re-Initialize
            Initialize();

            m_reinitializeCounter++;
        }
Beispiel #6
0
        public void Add(SoundToolKitMaterial acousticMaterial)
        {
            SoundToolKitDebug.Assert(acousticMaterial != null, "Material is null");

            if (!AcousticMaterials.Contains(acousticMaterial))
            {
                m_acousticMaterials.Add(acousticMaterial);
            }
            else
            {
                SoundToolKitDebug.LogWarning("Material already registered.");
            }
        }
Beispiel #7
0
        public void Remove(SoundToolKitMaterial acousticMaterial)
        {
            SoundToolKitDebug.Assert(acousticMaterial != null, "Material is null");

            if (AcousticMaterials.Contains(acousticMaterial))
            {
                m_acousticMaterials.Remove(acousticMaterial);
            }
            else
            {
                SoundToolKitDebug.LogWarning("Material wasn't registered.");
            }
        }
Beispiel #8
0
        public void Remove(SoundToolKitPlayback playback)
        {
            SoundToolKitDebug.Assert(playback != null, "Playback is null");

            if (Playbacks.Contains(playback))
            {
                m_playbacks.Remove(playback);
            }
            else
            {
                SoundToolKitDebug.LogWarning("Playback wasn't registered.");
            }
        }
Beispiel #9
0
        public void Remove(SourceComponent audioSource)
        {
            SoundToolKitDebug.Assert(audioSource != null, "Source component is null");

            if (AudioSources.Contains(audioSource))
            {
                m_audioSources.Remove(audioSource);
            }
            else
            {
                SoundToolKitDebug.LogWarning("Source component wasn't registered.");
            }
        }
Beispiel #10
0
        public void Remove(SoundToolKitMesh acousticMesh)
        {
            SoundToolKitDebug.Assert(acousticMesh != null, "Mesh is null");

            if (AcousticMeshes.Contains(acousticMesh))
            {
                m_acousticMeshes.Remove(acousticMesh);
            }
            else
            {
                SoundToolKitDebug.LogWarning("Mesh wasn't registered.");
            }
        }
Beispiel #11
0
        public void Add(SoundToolKitMesh acousticMesh)
        {
            SoundToolKitDebug.Assert(acousticMesh != null, "Mesh is null");

            if (!AcousticMeshes.Contains(acousticMesh))
            {
                m_acousticMeshes.Add(acousticMesh);
                RaiseMeshesChanged();
            }
            else
            {
                SoundToolKitDebug.LogWarning("Mesh already registered.");
            }
        }
Beispiel #12
0
        private int ClampIndex(int playbackIndex, int playbacksCount)
        {
            if (playbackIndex >= playbacksCount)
            {
                playbackIndex = playbacksCount - 1;
                SoundToolKitDebug.LogWarning("Index of the chosen Playback is too large. Clamping to the last element on the list.");
            }
            else if (playbackIndex < 0)
            {
                playbackIndex = 0;
                SoundToolKitDebug.LogWarning("Index of the chosen Playback is too small. Clamping to the first element on the list.");
            }

            return(playbackIndex);
        }
        private void Start()
        {
            if (ResourceContainer.Geometry == null)
            {
                SoundToolKitDebug.LogWarning("No SoundToolKitGeometry component on the scene. Acoustic Meshes will not be loaded. " +
                                             "Default component prefab available in Assets/SoundToolKit/Plugins/AudioEngine/Prefabs. " +
                                             "You can also use menu Tools/SoundToolKit/Geometry/SynchronizeDefaultGeometry.");
            }

            if (ResourceContainer.AudioListener == null)
            {
                SoundToolKitDebug.LogWarning("Missing SoundToolKitListener on the scene.");
            }

            if (!m_audioBridge.ProcessCallbackActive)
            {
                SoundToolKitDebug.LogWarning("Audio bridge is not processing. Missing audio mixer on scene.");
            }
        }
Beispiel #14
0
        internal void Add(string meshName)
        {
            if (!AcousticMeshNames.Contains(meshName))
            {
                AcousticMeshNames.Add(meshName);
                RaiseModified();
                ClearSerializedData();
            }
            else
            {
#if UNITY_EDITOR
                if (UnityEditor.EditorApplication.isPlaying)
                {
                    SoundToolKitDebug.LogWarning("Attempted to add a StkMesh " + meshName + " to MeshCluster "
                                                 + name + " but a mesh with that name is already present in that cluster. Aborting.\n" +
                                                 "You can use the menu Tools/SoundToolKit/Geometry/MakeMeshNamesUnique to remedy this automatically.");
                }
#endif
            }
        }
Beispiel #15
0
        public void Add(SoundToolKitPlayback playback)
        {
            // <STK.LITE> - What's the point of it all?
            if (Playbacks.Count >= StkLite.AvailableSources())
            {
                return;
            }
            // </STK.LITE>

            SoundToolKitDebug.Assert(playback != null, "Playback is null");

            if (!Playbacks.Contains(playback))
            {
                m_playbacks.Add(playback);
            }
            else
            {
                SoundToolKitDebug.LogWarning("Playback already registered.");
            }
        }
Beispiel #16
0
        public void Add(SourceComponent audioSource)
        {
            // <STK.LITE> - Why are we even here?
            if (AudioSources.Count >= StkLite.AvailableSources())
            {
                return;
            }
            // </STK.LITE>

            SoundToolKitDebug.Assert(audioSource != null, "Source component is null");

            if (!AudioSources.Contains(audioSource))
            {
                m_audioSources.Add(audioSource);
            }
            else
            {
                SoundToolKitDebug.LogWarning("Source component already registered.");
            }
        }
Beispiel #17
0
        internal void Serialize()
        {
#if UNITY_EDITOR
            if (Model == null)
            {
                SoundToolKitDebug.LogWarning("Cannot serialize MeshCluster: " + name + "'s geometry data." +
                                             " No internal SoundToolKitModel exists for that Cluster.");
                return;
            }

            ClearSerializedData();
            m_serializedGeometry = MeshClusterUtility.CreateSerializedGeometry(name + "_SerializedGeometry");
            Model.SaveGeometry(data => m_serializedGeometry.WriteData(name, data));
            SoundToolKitManager.Instance.Finish();

            m_playSessionGeometry = m_serializedGeometry;

            UnityEditor.EditorUtility.SetDirty(this);
            UnityEditor.AssetDatabase.SaveAssets();
            UnityEditor.AssetDatabase.Refresh();
#endif
        }
        /// <summary>
        /// Load a given MeshCluster into the scene. Only MeshClusters that are loaded take part in acoustic processing.
        /// </summary>
        public void LoadMeshCluster(SoundToolKitMeshCluster meshCluster)
        {
            if (meshCluster == null)
            {
                MeshClusters.Remove(meshCluster);
                return;
            }

            if (!meshCluster.AcousticMeshNames.Any())
            {
                SoundToolKitDebug.LogWarning("Cannot load a MeshCluster that contains no SoundToolKitMeshes. " +
                                             "Please assign SoundToolKitMeshes to a cluster prior to loading it. (Trying to load " +
                                             meshCluster.name + " MeshCluster)");
                return;
            }

            if (meshCluster.Model == null)
            {
                meshCluster.CreateInternalModel();
            }

            SoundToolKitManager.Instance.StkAudioEngine.Scene.AddModel(meshCluster.Model);
            meshCluster.OnMeshesModified += ReloadMeshCluster;
        }
Beispiel #19
0
 private void WarnSampleInvalid()
 {
     SoundToolKitDebug.LogWarning("Attempted to play invalid VolumeControlledSample in " +
                                  gameObject.name + " GameObject's SourceSpawner. Check it's Samples List.");
 }