Esempio n. 1
0
        void DisplayProgressBarAndCancel()
        {
            SteamAudioSource bakedSource = serializedObject.targetObject as SteamAudioSource;

            bakedSource.baker.DrawProgressBar();
            Repaint();
        }
Esempio n. 2
0
        public override void GetParameters(SteamAudioSource steamAudioSource)
        {
            // todo: can we copy the curve only if it's changed?
            m_curAudioSourceData.rolloffMode = audioSource.rolloffMode;
            m_curAudioSourceData.minDistance = audioSource.minDistance;
            m_curAudioSourceData.maxDistance = audioSource.maxDistance;
            m_curAudioSourceData.distanceAttenuationCurve = audioSource.GetCustomCurve(AudioSourceCurveType.CustomRolloff);

            // todo: ideally, we would check if the curve has been edited by the user, and set the dirty flag accordingly.
            // however, since we would need to know when the c api has consumed the distance attenuation model struct
            // internally, which would require information to be passed across several layers of code, we opt to instead
            // always treat the distance attenuation model as dirty when running in the editor, and never when running
            // in a player. once the indirect calculation is moved to the unity side, it will be easier to do this the
            // right way.
            bool audioSourceDataChanged = (Application.isEditor);

            m_prevAudioSourceData = m_curAudioSourceData;

            if (steamAudioSource.physicsBasedAttenuation)
            {
                steamAudioSource.distanceAttenuationModel.type = DistanceAttenuationModelType.Default;
            }
            else
            {
                steamAudioSource.distanceAttenuationModel.type     = DistanceAttenuationModelType.Callback;
                steamAudioSource.distanceAttenuationModel.callback = DistanceAttenuationCallback;
                steamAudioSource.distanceAttenuationModel.userData = GCHandle.ToIntPtr(thisObject);
                steamAudioSource.distanceAttenuationModel.dirty    = (audioSourceDataChanged) ? Bool.True : Bool.False;
            }

            steamAudioSource.airAbsorptionModel.type = AirAbsorptionModelType.Default;
        }
Esempio n. 3
0
        public override void UpdateParameters(SteamAudioSource steamAudioSource)
        {
            if (!audioSource || !audioSource.isPlaying)
            {
                return;
            }

            var directBinauralValue      = (steamAudioSource.directBinaural) ? 1.0f : 0.0f;
            var hrtfInterpolationValue   = (float)steamAudioSource.interpolation;
            var distanceAttenuationValue = (steamAudioSource.physicsBasedAttenuation) ? 1.0f : 0.0f;
            var airAbsorptionValue       = (steamAudioSource.airAbsorption) ? 1.0f : 0.0f;
            var dipoleWeightValue        = steamAudioSource.dipoleWeight;
            var dipolePowerValue         = steamAudioSource.dipolePower;
            var occlusionModeValue       = (float)steamAudioSource.occlusionMode;
            var occlusionMethodValue     = (float)steamAudioSource.occlusionMethod;
            var sourceRadiusValue        = steamAudioSource.sourceRadius;
            var directMixLevelValue      = steamAudioSource.directMixLevel;
            var reflectionsValue         = (steamAudioSource.reflections) ? 1.0f : 0.0f;
            var indirectBinauralValue    = (steamAudioSource.indirectBinaural) ? 1.0f : 0.0f;
            var indirectMixLevelValue    = steamAudioSource.indirectMixLevel;
            var simulationTypeValue      = (steamAudioSource.simulationType == SourceSimulationType.Realtime) ? 0.0f : 1.0f;
            var usesStaticListenerValue  = (steamAudioSource.simulationType == SourceSimulationType.BakedStaticListener) ? 1.0f : 0.0f;
            var bypassDuringInitValue    = (steamAudioSource.avoidSilenceDuringInit) ? 1.0f : 0.0f;
            var hrtfIndexValue           = (float)steamAudioSource.hrtfIndex;
            var overrideHRTFIndexValue   = (steamAudioSource.overrideHRTFIndex) ? 1.0f : 0.0f;

            audioSource.SetSpatializerFloat(0, directBinauralValue);
            audioSource.SetSpatializerFloat(1, hrtfInterpolationValue);
            audioSource.SetSpatializerFloat(2, distanceAttenuationValue);
            audioSource.SetSpatializerFloat(3, airAbsorptionValue);
            audioSource.SetSpatializerFloat(4, occlusionModeValue);
            audioSource.SetSpatializerFloat(5, occlusionMethodValue);
            audioSource.SetSpatializerFloat(6, sourceRadiusValue);
            audioSource.SetSpatializerFloat(7, directMixLevelValue);
            audioSource.SetSpatializerFloat(8, reflectionsValue);
            audioSource.SetSpatializerFloat(9, indirectBinauralValue);
            audioSource.SetSpatializerFloat(10, indirectMixLevelValue);
            audioSource.SetSpatializerFloat(11, simulationTypeValue);
            audioSource.SetSpatializerFloat(12, usesStaticListenerValue);
            audioSource.SetSpatializerFloat(14, bypassDuringInitValue);
            audioSource.SetSpatializerFloat(15, dipoleWeightValue);
            audioSource.SetSpatializerFloat(16, dipolePowerValue);
            audioSource.SetSpatializerFloat(17, hrtfIndexValue);
            audioSource.SetSpatializerFloat(18, overrideHRTFIndexValue);

            var index = 19;

            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.distanceAttenuation);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.airAbsorptionLow);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.airAbsorptionMid);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.airAbsorptionHigh);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.propagationDelay);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.occlusionFactor);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.transmissionFactorLow);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.transmissionFactorMid);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.transmissionFactorHigh);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.directivityFactor);
        }
Esempio n. 4
0
        public override void SendIdentifier(SteamAudioSource steamAudioSource, int identifier)
        {
            FindDSP(steamAudioSource.gameObject);
            if (!foundDSP)
            {
                return;
            }

            FMOD_DSP_setParameterData.Invoke(dsp, new object[] { 13, BitConverter.GetBytes(identifier) });
        }
Esempio n. 5
0
        public void BakedSourceStatsGUI()
        {
            SteamAudioSource bakedSource = serializedObject.targetObject as SteamAudioSource;

            GUI.enabled = !Baker.IsBakeActive() && !EditorApplication.isPlayingOrWillChangePlaymode;
            bakedSource.UpdateBakedDataStatistics();
            for (int i = 0; i < bakedSource.bakedProbeNames.Count; ++i)
            {
                EditorGUILayout.LabelField(bakedSource.bakedProbeNames[i], (bakedSource.bakedProbeDataSizes[i] / 1000.0f).ToString("0.0") + " KB");
            }
            EditorGUILayout.LabelField("Total Size", (bakedSource.bakedDataSize / 1000.0f).ToString("0.0") + " KB");
            GUI.enabled = true;
        }
Esempio n. 6
0
        public override bool UsesBakedStaticListener(SteamAudioSource steamAudioSource)
        {
            FindDSP(steamAudioSource.gameObject);
            if (!foundDSP)
            {
                return(false);
            }

            var usesBakedStaticListener = false;

            FMOD_DSP_getParameterBool.Invoke(dsp, new object[] { 12, usesBakedStaticListener });
            return(usesBakedStaticListener);
        }
Esempio n. 7
0
        public void BakedSourceGUI()
        {
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Baked Static Source Settings", EditorStyles.boldLabel);

            SteamAudioSource bakedSource = serializedObject.targetObject as SteamAudioSource;

            GUI.enabled = !Baker.IsBakeActive() && !EditorApplication.isPlayingOrWillChangePlaymode;

            EditorGUILayout.PropertyField(serializedObject.FindProperty("uniqueIdentifier"));
            bakedSource.uniqueIdentifier = bakedSource.uniqueIdentifier.Trim();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("bakingRadius"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("useAllProbeBoxes"));

            if (!serializedObject.FindProperty("useAllProbeBoxes").boolValue)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("probeBoxes"), true);
            }

            if (bakedSource.uniqueIdentifier.Length == 0)
            {
                EditorGUILayout.HelpBox("You must specify a unique identifier name.", MessageType.Warning);
            }

            if (bakedSource.dipoleWeight > 0.0f)
            {
                EditorGUILayout.HelpBox("A baked static source should not rotate at run-time, " +
                                        "otherwise indirect sound rendered using baked data may not be accurate.", MessageType.Warning);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(" ");
            if (GUILayout.Button("Bake Effect"))
            {
                if (bakedSource.uniqueIdentifier.Length == 0)
                {
                    Debug.LogError("You must specify a unique identifier name.");
                }
                else
                {
                    bakedSource.BeginBake();
                }
            }
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;

            DisplayProgressBarAndCancel();
        }
Esempio n. 8
0
        public override bool UsesBakedStaticListener(SteamAudioSource steamAudioSource)
        {
            FindDSP(steamAudioSource.gameObject);
            if (!foundDSP)
            {
                return(false);
            }

            var usesBakedStaticListener = false;

            var getParameterBoolArgs = new object[] { k_useBakedStaticListenerIndex, usesBakedStaticListener };

            FMOD_DSP_getParameterBool.Invoke(dsp, getParameterBoolArgs);
            usesBakedStaticListener = (bool)getParameterBoolArgs[1];

            return(usesBakedStaticListener);
        }
Esempio n. 9
0
        public override void UpdateParameters(SteamAudioSource source)
        {
            if (!mAudioSource)
            {
                return;
            }

            var index = 0;

            mAudioSource.SetSpatializerFloat(index++, (source.distanceAttenuation) ? 1.0f : 0.0f);
            mAudioSource.SetSpatializerFloat(index++, (source.airAbsorption) ? 1.0f : 0.0f);
            mAudioSource.SetSpatializerFloat(index++, (source.directivity) ? 1.0f : 0.0f);
            mAudioSource.SetSpatializerFloat(index++, (source.occlusion) ? 1.0f : 0.0f);
            mAudioSource.SetSpatializerFloat(index++, (source.transmission) ? 1.0f : 0.0f);
            mAudioSource.SetSpatializerFloat(index++, (source.reflections) ? 1.0f : 0.0f);
            mAudioSource.SetSpatializerFloat(index++, (source.pathing) ? 1.0f : 0.0f);
            mAudioSource.SetSpatializerFloat(index++, (float)source.interpolation);
            mAudioSource.SetSpatializerFloat(index++, source.distanceAttenuationValue);
            mAudioSource.SetSpatializerFloat(index++, (source.distanceAttenuationInput == DistanceAttenuationInput.CurveDriven) ? 1.0f : 0.0f);
            mAudioSource.SetSpatializerFloat(index++, source.airAbsorptionLow);
            mAudioSource.SetSpatializerFloat(index++, source.airAbsorptionMid);
            mAudioSource.SetSpatializerFloat(index++, source.airAbsorptionHigh);
            mAudioSource.SetSpatializerFloat(index++, (source.airAbsorptionInput == AirAbsorptionInput.UserDefined) ? 1.0f : 0.0f);
            mAudioSource.SetSpatializerFloat(index++, source.directivityValue);
            mAudioSource.SetSpatializerFloat(index++, source.dipoleWeight);
            mAudioSource.SetSpatializerFloat(index++, source.dipolePower);
            mAudioSource.SetSpatializerFloat(index++, (source.directivityInput == DirectivityInput.UserDefined) ? 1.0f : 0.0f);
            mAudioSource.SetSpatializerFloat(index++, source.occlusionValue);
            mAudioSource.SetSpatializerFloat(index++, (float)source.transmissionType);
            mAudioSource.SetSpatializerFloat(index++, source.transmissionLow);
            mAudioSource.SetSpatializerFloat(index++, source.transmissionMid);
            mAudioSource.SetSpatializerFloat(index++, source.transmissionHigh);
            mAudioSource.SetSpatializerFloat(index++, source.directMixLevel);
            mAudioSource.SetSpatializerFloat(index++, (source.applyHRTFToReflections) ? 1.0f : 0.0f);
            mAudioSource.SetSpatializerFloat(index++, source.reflectionsMixLevel);
            mAudioSource.SetSpatializerFloat(index++, (source.applyHRTFToPathing) ? 1.0f : 0.0f);
            mAudioSource.SetSpatializerFloat(index++, source.pathingMixLevel);
            SetSpatializerIntPtr(source.GetSource().Get(), ref index);
            mAudioSource.SetSpatializerFloat(index++, (source.directBinaural) ? 1.0f : 0.0f);
        }
Esempio n. 10
0
        public override void UpdateParameters(SteamAudioSource steamAudioSource)
        {
            FindDSP(steamAudioSource.gameObject);
            if (!foundDSP)
            {
                return;
            }

            // update the values of the directPath in Fmod
            var index = k_directPathIndexStart; // this is where the directPath settings begin

            FMOD_DSP_setParameterFloat.Invoke(dsp, new object[] { index++, steamAudioSource.directPath.distanceAttenuation });
            FMOD_DSP_setParameterFloat.Invoke(dsp, new object[] { index++, steamAudioSource.directPath.airAbsorptionLow });
            FMOD_DSP_setParameterFloat.Invoke(dsp, new object[] { index++, steamAudioSource.directPath.airAbsorptionMid });
            FMOD_DSP_setParameterFloat.Invoke(dsp, new object[] { index++, steamAudioSource.directPath.airAbsorptionHigh });
            FMOD_DSP_setParameterFloat.Invoke(dsp, new object[] { index++, steamAudioSource.directPath.propagationDelay });
            FMOD_DSP_setParameterFloat.Invoke(dsp, new object[] { index++, steamAudioSource.directPath.occlusionFactor });
            FMOD_DSP_setParameterFloat.Invoke(dsp, new object[] { index++, steamAudioSource.directPath.transmissionFactorLow });
            FMOD_DSP_setParameterFloat.Invoke(dsp, new object[] { index++, steamAudioSource.directPath.transmissionFactorMid });
            FMOD_DSP_setParameterFloat.Invoke(dsp, new object[] { index++, steamAudioSource.directPath.transmissionFactorHigh });
            FMOD_DSP_setParameterFloat.Invoke(dsp, new object[] { index++, steamAudioSource.directPath.directivityFactor });
        }
Esempio n. 11
0
        public override void GetParameters(SteamAudioSource steamAudioSource)
        {
            FindDSP(steamAudioSource.gameObject);
            if (!foundDSP)
            {
                return;
            }

            // get values set in Fmod and pass to AudioEngineSource so it can do the audibility checks
            {
                var getParameterFloatArgs = new object[] { k_dipoleWeightIndex, 0.0f };
                FMOD_DSP_getParameterFloat.Invoke(dsp, getParameterFloatArgs);
                steamAudioSource.dipoleWeight = (float)getParameterFloatArgs[1];

                getParameterFloatArgs[0] = k_dipolePowerIndex;
                FMOD_DSP_getParameterFloat.Invoke(dsp, getParameterFloatArgs);
                steamAudioSource.dipolePower = (float)getParameterFloatArgs[1];

                getParameterFloatArgs[0] = k_sourceRadiusIndex;
                FMOD_DSP_getParameterFloat.Invoke(dsp, getParameterFloatArgs);
                steamAudioSource.sourceRadius = (float)getParameterFloatArgs[1];
            }

            {
                var getParameterIntArgs = new object[] { k_occlusionModeIndex, 0 };
                FMOD_DSP_getParameterInt.Invoke(dsp, getParameterIntArgs);
                steamAudioSource.occlusionMode = (OcclusionMode)getParameterIntArgs[1];

                getParameterIntArgs[0] = k_occlusionMethodIndex;
                FMOD_DSP_getParameterInt.Invoke(dsp, getParameterIntArgs);
                steamAudioSource.occlusionMethod = (OcclusionMethod)getParameterIntArgs[1];
            }

            {
                var getParameterBoolArgs = new object[] { k_enableIndirectIndex, false };
                FMOD_DSP_getParameterBool.Invoke(dsp, getParameterBoolArgs);
                steamAudioSource.reflections = (bool)getParameterBoolArgs[1];
            }
        }
Esempio n. 12
0
        public override void UpdateParameters(SteamAudioSource steamAudioSource)
        {
            if (!audioSource || !audioSource.isPlaying)
            {
                return;
            }

            var directBinauralValue      = (steamAudioSource.directBinaural) ? 1.0f : 0.0f;
            var hrtfInterpolationValue   = (float)steamAudioSource.interpolation;
            var distanceAttenuationValue = (steamAudioSource.physicsBasedAttenuation) ? 1.0f : 0.0f;
            var airAbsorptionValue       = (steamAudioSource.airAbsorption) ? 1.0f : 0.0f;
            var occlusionModeValue       = (float)steamAudioSource.occlusionMode;
            var occlusionMethodValue     = (float)steamAudioSource.occlusionMethod;
            var sourceRadiusValue        = steamAudioSource.sourceRadius;
            var directMixLevelValue      = steamAudioSource.directMixLevel;
            var reflectionsValue         = (steamAudioSource.reflections) ? 1.0f : 0.0f;
            var indirectBinauralValue    = (steamAudioSource.indirectBinaural) ? 1.0f : 0.0f;
            var indirectMixLevelValue    = steamAudioSource.indirectMixLevel;
            var simulationTypeValue      = (steamAudioSource.simulationType == SourceSimulationType.Realtime) ? 0.0f : 1.0f;
            var usesStaticListenerValue  = (steamAudioSource.simulationType == SourceSimulationType.BakedStaticListener) ? 1.0f : 0.0f;
            var bypassDuringInitValue    = (steamAudioSource.avoidSilenceDuringInit) ? 1.0f : 0.0f;

            audioSource.SetSpatializerFloat(0, directBinauralValue);
            audioSource.SetSpatializerFloat(1, hrtfInterpolationValue);
            audioSource.SetSpatializerFloat(2, distanceAttenuationValue);
            audioSource.SetSpatializerFloat(3, airAbsorptionValue);
            audioSource.SetSpatializerFloat(4, occlusionModeValue);
            audioSource.SetSpatializerFloat(5, occlusionMethodValue);
            audioSource.SetSpatializerFloat(6, sourceRadiusValue);
            audioSource.SetSpatializerFloat(7, directMixLevelValue);
            audioSource.SetSpatializerFloat(8, reflectionsValue);
            audioSource.SetSpatializerFloat(9, indirectBinauralValue);
            audioSource.SetSpatializerFloat(10, indirectMixLevelValue);
            audioSource.SetSpatializerFloat(11, simulationTypeValue);
            audioSource.SetSpatializerFloat(12, usesStaticListenerValue);
            audioSource.SetSpatializerFloat(14, bypassDuringInitValue);
        }
Esempio n. 13
0
        public override void UpdateParameters(SteamAudioSource source)
        {
            FindDSP(source.gameObject);
            if (!mFoundDSP)
            {
                return;
            }

            var ptr = source.GetSource().Get();

            if (IntPtr.Size == sizeof(Int64))
            {
                var ptrValue = ptr.ToInt64();

                mSimulationOutputs[0] = (byte)(ptrValue >> 0);
                mSimulationOutputs[1] = (byte)(ptrValue >> 8);
                mSimulationOutputs[2] = (byte)(ptrValue >> 16);
                mSimulationOutputs[3] = (byte)(ptrValue >> 24);
                mSimulationOutputs[4] = (byte)(ptrValue >> 32);
                mSimulationOutputs[5] = (byte)(ptrValue >> 40);
                mSimulationOutputs[6] = (byte)(ptrValue >> 48);
                mSimulationOutputs[7] = (byte)(ptrValue >> 56);
            }
            else
            {
                var ptrValue = ptr.ToInt32();

                mSimulationOutputs[0] = (byte)(ptrValue >> 0);
                mSimulationOutputs[1] = (byte)(ptrValue >> 8);
                mSimulationOutputs[2] = (byte)(ptrValue >> 16);
                mSimulationOutputs[3] = (byte)(ptrValue >> 24);
            }

            var index = kSimulationOutputsParamIndex;

            FMOD_DSP_setParameterData.Invoke(mDSP, new object[] { index++, mSimulationOutputs });
        }
Esempio n. 14
0
        public override void UpdateParameters(SteamAudioSource steamAudioSource)
        {
            if (!audioSource)
            {
                return;
            }

            var directBinauralValue      = (steamAudioSource.directBinaural) ? 1.0f : 0.0f;
            var hrtfInterpolationValue   = (float)steamAudioSource.interpolation;
            var distanceAttenuationValue = (steamAudioSource.physicsBasedAttenuation) ? 1.0f : 0.0f;
            var airAbsorptionValue       = (steamAudioSource.airAbsorption) ? 1.0f : 0.0f;
            var dipoleWeightValue        = steamAudioSource.dipoleWeight;
            var dipolePowerValue         = steamAudioSource.dipolePower;
            var occlusionModeValue       = (float)steamAudioSource.occlusionMode;
            var occlusionMethodValue     = (float)steamAudioSource.occlusionMethod;
            var sourceRadiusValue        = steamAudioSource.sourceRadius;
            var directMixLevelValue      = steamAudioSource.directMixLevel;
            var reflectionsValue         = (steamAudioSource.reflections) ? 1.0f : 0.0f;
            var indirectBinauralValue    = (steamAudioSource.indirectBinaural) ? 1.0f : 0.0f;
            var indirectMixLevelValue    = steamAudioSource.indirectMixLevel;
            var simulationTypeValue      = (steamAudioSource.simulationType == SourceSimulationType.Realtime) ? 0.0f : 1.0f;
            var usesStaticListenerValue  = (steamAudioSource.simulationType == SourceSimulationType.BakedStaticListener) ? 1.0f : 0.0f;
            var bypassDuringInitValue    = (steamAudioSource.avoidSilenceDuringInit) ? 1.0f : 0.0f;
            var hrtfIndexValue           = (float)steamAudioSource.hrtfIndex;
            var overrideHRTFIndexValue   = (steamAudioSource.overrideHRTFIndex) ? 1.0f : 0.0f;

            audioSource.SetSpatializerFloat(0, directBinauralValue);
            audioSource.SetSpatializerFloat(1, hrtfInterpolationValue);
            audioSource.SetSpatializerFloat(2, distanceAttenuationValue);
            audioSource.SetSpatializerFloat(3, airAbsorptionValue);
            audioSource.SetSpatializerFloat(4, occlusionModeValue);
            audioSource.SetSpatializerFloat(5, occlusionMethodValue);
            audioSource.SetSpatializerFloat(6, sourceRadiusValue);
            audioSource.SetSpatializerFloat(7, directMixLevelValue);
            audioSource.SetSpatializerFloat(8, reflectionsValue);
            audioSource.SetSpatializerFloat(9, indirectBinauralValue);
            audioSource.SetSpatializerFloat(10, indirectMixLevelValue);
            audioSource.SetSpatializerFloat(11, simulationTypeValue);
            audioSource.SetSpatializerFloat(12, usesStaticListenerValue);
            audioSource.SetSpatializerFloat(14, bypassDuringInitValue);
            audioSource.SetSpatializerFloat(15, dipoleWeightValue);
            audioSource.SetSpatializerFloat(16, dipolePowerValue);
            audioSource.SetSpatializerFloat(17, hrtfIndexValue);
            audioSource.SetSpatializerFloat(18, overrideHRTFIndexValue);

            var index = 19;

            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.distanceAttenuation);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.airAbsorptionLow);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.airAbsorptionMid);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.airAbsorptionHigh);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.propagationDelay);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.occlusionFactor);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.transmissionFactorLow);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.transmissionFactorMid);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.transmissionFactorHigh);
            audioSource.SetSpatializerFloat(index++, steamAudioSource.directPath.directivityFactor);

            var distanceAttenuationCallback = IntPtr.Zero;

            if (steamAudioSource.distanceAttenuationModel.callback != null)
            {
                distanceAttenuationCallback = Marshal.GetFunctionPointerForDelegate(steamAudioSource.distanceAttenuationModel.callback);
            }
            var distanceAttenuationUserData = steamAudioSource.distanceAttenuationModel.userData;

            if (steamAudioSource.physicsBasedAttenuationForIndirect)
            {
                audioSource.SetSpatializerFloat(index++, (float)DistanceAttenuationModelType.Default);
            }
            else
            {
                audioSource.SetSpatializerFloat(index++, (float)steamAudioSource.distanceAttenuationModel.type);
            }

            audioSource.SetSpatializerFloat(index++, steamAudioSource.distanceAttenuationModel.minDistance);

            SetSpatializerIntPtr(distanceAttenuationCallback, ref index);
            SetSpatializerIntPtr(distanceAttenuationUserData, ref index);

            audioSource.SetSpatializerFloat(index++, (steamAudioSource.distanceAttenuationModel.dirty == Bool.True) ? 1.0f : 0.0f);
        }
Esempio n. 15
0
 public virtual void GetParameters(SteamAudioSource steamAudioSource)
 {
 }
 public override bool UsesBakedStaticListener(SteamAudioSource steamAudioSource)
 {
     return(steamAudioSource.simulationType == SourceSimulationType.BakedStaticListener);
 }
        public override void SendIdentifier(SteamAudioSource steamAudioSource, int identifier)
        {
            var identifierFloat = BitConverter.ToSingle(BitConverter.GetBytes(identifier), 0);

            audioSource.SetSpatializerFloat(13, identifierFloat);
        }
 public override bool ShouldSendIdentifier(SteamAudioSource steamAudioSource)
 {
     return(steamAudioSource.simulationType == SourceSimulationType.BakedStaticSource ||
            steamAudioSource.simulationType == SourceSimulationType.BakedStaticListener);
 }
Esempio n. 19
0
 public abstract void SendIdentifier(SteamAudioSource steamAudioSource, int identifier);
Esempio n. 20
0
 public abstract bool UsesBakedStaticListener(SteamAudioSource steamAudioSource);
Esempio n. 21
0
 public virtual bool ShouldSendIdentifier(SteamAudioSource steamAudioSource)
 {
     return(true);
 }
Esempio n. 22
0
        //
        // Draws the inspector.
        //
        public override void OnInspectorGUI()
        {
            var steamAudioManager = GameObject.FindObjectOfType <SteamAudioManager>();

            if (steamAudioManager == null)
            {
                EditorGUILayout.HelpBox("A Steam Audio Manager does not exist in the scene. Click Window > Steam" +
                                        " Audio.", MessageType.Error);
                return;
            }

            serializedObject.Update();

            if (steamAudioManager.audioEngine == AudioEngine.UnityNative)
            {
                // Direct Sound UX
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Direct Sound", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("directBinaural"));
                if (serializedObject.FindProperty("directBinaural").boolValue)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("interpolation"),
                                                  new GUIContent("HRTF Interpolation"));
                }

                serializedObject.FindProperty("occlusionMode").enumValueIndex =
                    EditorGUILayout.Popup("Direct Sound Occlusion",
                                          serializedObject.FindProperty("occlusionMode").enumValueIndex, optionsOcclusion);

                if (serializedObject.FindProperty("occlusionMode").enumValueIndex
                    != (int)OcclusionMode.NoOcclusion)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("occlusionMethod"));

                    if (serializedObject.FindProperty("occlusionMethod").enumValueIndex ==
                        (int)OcclusionMethod.Partial)
                    {
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("sourceRadius"),
                                                      new GUIContent("Source Radius (meters)"));
                    }
                }

                EditorGUILayout.PropertyField(serializedObject.FindProperty("physicsBasedAttenuation"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("airAbsorption"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("directMixLevel"));

                // Indirect Sound UX
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Indirect Sound", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("reflections"));

                if (serializedObject.FindProperty("reflections").boolValue)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("simulationType"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("indirectMixLevel"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("indirectBinaural"));

                    EditorGUILayout.HelpBox("Go to Window > Phonon > Simulation to update the global simulation " +
                                            "settings.", MessageType.Info);

                    if (serializedObject.FindProperty("indirectBinaural").boolValue)
                    {
                        EditorGUILayout.HelpBox("The binaural setting is ignored if Phonon Listener component is " +
                                                "attached with mixing enabled.", MessageType.Info);
                    }
                }
            }

            SteamAudioSource phononEffect = serializedObject.targetObject as SteamAudioSource;

            if (steamAudioManager.audioEngine != AudioEngine.UnityNative ||
                phononEffect.simulationType == SourceSimulationType.BakedStaticSource)
            {
                BakedSourceGUI();
                serializedObject.FindProperty("bakedStatsFoldout").boolValue =
                    EditorGUILayout.Foldout(serializedObject.FindProperty("bakedStatsFoldout").boolValue,
                                            "Baked Static Source Statistics");

                if (phononEffect.bakedStatsFoldout)
                {
                    BakedSourceStatsGUI();
                }
            }

            // Save changes.
            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 23
0
        //
        // Draws the inspector.
        //
        public override void OnInspectorGUI()
        {
            var steamAudioManager = GameObject.FindObjectOfType <SteamAudioManager>();

            if (steamAudioManager == null)
            {
                EditorGUILayout.HelpBox("A Steam Audio Manager does not exist in the scene. Click Window > Steam" +
                                        " Audio.", MessageType.Error);
                return;
            }

            serializedObject.Update();

            var directBinauralProp = serializedObject.FindProperty("directBinaural");
            var interpolationProp  = serializedObject.FindProperty("interpolation");

            //var hrtfIndexProp = serializedObject.FindProperty("hrtfIndex");
            //var overrideHRTFIndexProp = serializedObject.FindProperty("overrideHRTFIndex");

            if (steamAudioManager.audioEngine == AudioEngine.UnityNative)
            {
                // Direct Sound UX
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Direct Sound", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(directBinauralProp);
                if (directBinauralProp.boolValue)
                {
                    EditorGUILayout.PropertyField(interpolationProp, new GUIContent("HRTF Interpolation"));
                    //EditorGUILayout.PropertyField(overrideHRTFIndexProp, new GUIContent("Override HRTF Index"));
                    //EditorGUILayout.PropertyField(hrtfIndexProp, new GUIContent("HRTF Index"));
                }

                serializedObject.FindProperty("occlusionMode").enumValueIndex =
                    EditorGUILayout.Popup("Direct Sound Occlusion",
                                          serializedObject.FindProperty("occlusionMode").enumValueIndex, optionsOcclusion);

                if (serializedObject.FindProperty("occlusionMode").enumValueIndex
                    != (int)OcclusionMode.NoOcclusion)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("occlusionMethod"));

                    if (serializedObject.FindProperty("occlusionMethod").enumValueIndex ==
                        (int)OcclusionMethod.Partial)
                    {
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("sourceRadius"),
                                                      new GUIContent("Source Radius (meters)"));
                    }
                }

                EditorGUILayout.PropertyField(serializedObject.FindProperty("physicsBasedAttenuation"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("airAbsorption"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("directMixLevel"));
                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Directivity", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("dipoleWeight"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("dipolePower"));
                EditorGUILayout.PrefixLabel("Preview");
                EditorGUILayout.Space();
                var rect   = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect());
                var center = rect.center;
                center.x   += 4;
                rect.center = center;
                rect.width  = 65;
                rect.height = 65;

                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.Space();

                DrawDirectivity(serializedObject.FindProperty("dipoleWeight").floatValue, serializedObject.FindProperty("dipolePower").floatValue);
                EditorGUI.DrawPreviewTexture(rect, directivityPreview);

                // Indirect Sound UX
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Indirect Sound", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("reflections"));

                if (serializedObject.FindProperty("reflections").boolValue)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("simulationType"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("indirectMixLevel"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("indirectBinaural"));

                    EditorGUILayout.HelpBox("Go to Window > Phonon > Simulation to update the global simulation " +
                                            "settings.", MessageType.Info);

                    if (serializedObject.FindProperty("indirectBinaural").boolValue)
                    {
                        EditorGUILayout.HelpBox("The binaural setting is ignored if Phonon Listener component is " +
                                                "attached with mixing enabled.", MessageType.Info);
                    }
                }
            }

            SteamAudioSource phononEffect = serializedObject.targetObject as SteamAudioSource;

            if (phononEffect.simulationType == SourceSimulationType.BakedStaticSource ||
                steamAudioManager.audioEngine != AudioEngine.UnityNative)
            {
                BakedSourceGUI();
                serializedObject.FindProperty("bakedStatsFoldout").boolValue =
                    EditorGUILayout.Foldout(serializedObject.FindProperty("bakedStatsFoldout").boolValue,
                                            "Baked Static Source Statistics");

                if (phononEffect.bakedStatsFoldout)
                {
                    BakedSourceStatsGUI();
                }
            }

            if (steamAudioManager.audioEngine == AudioEngine.UnityNative)
            {
                EditorGUILayout.Space();
                if (showAdvancedOptions = EditorGUILayout.Foldout(showAdvancedOptions, "Advanced Options"))
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("avoidSilenceDuringInit"));
                }
            }

            // Save changes.
            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 24
0
 public virtual void UpdateParameters(SteamAudioSource steamAudioSource)
 {
 }