Esempio n. 1
0
        private void Update3DCuePosition(IMy3DSoundEmitter source)
        {
            MySoundData cue = m_cueBank.GetCue(source.SoundId);

            if (cue == null && source.Sound == null && !source.Sound.IsBuffered)
            {
                return;
            }

            var sourceVoice = source.Sound as MySourceVoice;

            if (sourceVoice == null)
            {
                return;
            }

            if (!sourceVoice.IsBuffered)
            {
                m_helperEmitter.UpdateValuesOmni(source.SourcePosition, source.Velocity, cue, m_deviceDetails.OutputFormat.Channels, source.CustomMaxDistance);
                float maxDistance = source.CustomMaxDistance.HasValue ? source.CustomMaxDistance.Value : cue.MaxDistance;
                m_x3dAudio.Apply3D(sourceVoice.Voice, m_listener, m_helperEmitter, source.SourceChannels, m_deviceDetails.OutputFormat.Channels, m_calculateFlags, maxDistance, source.Sound.FrequencyRatio);
            }
            else
            {
                float maxDistance = source.CustomMaxDistance.Value;
                m_helperEmitter.UpdateValuesOmni(source.SourcePosition, source.Velocity, maxDistance, m_deviceDetails.OutputFormat.Channels, MyCurveType.Linear);
                m_x3dAudio.Apply3D(sourceVoice.Voice, m_listener, m_helperEmitter, source.SourceChannels, m_deviceDetails.OutputFormat.Channels, m_calculateFlags, maxDistance, sourceVoice.FrequencyRatio);
            }
        }
Esempio n. 2
0
        private void Update3DCuePosition(IMy3DSoundEmitter source)
        {
            if (m_cueBank == null)
            {
                return;
            }

            MySoundData cue = m_cueBank.GetCue(source.SoundId);

            if (cue == null || source.Sound == null)// || !source.Sound.IsBuffered)
            {
                return;
            }

            var sourceVoice = source.Sound as MySourceVoice;

            if (sourceVoice == null)
            {
                return;
            }

            if (!sourceVoice.IsBuffered)
            {
                m_helperEmitter.UpdateValuesOmni(source.SourcePosition, source.Velocity, cue, m_deviceDetails.OutputFormat.Channels, source.CustomMaxDistance);
                float maxDistance = source.CustomMaxDistance.HasValue ? source.CustomMaxDistance.Value : cue.MaxDistance;
                sourceVoice.distanceToListener = m_x3dAudio.Apply3D(sourceVoice.Voice, m_listener, m_helperEmitter, source.SourceChannels, m_deviceDetails.OutputFormat.Channels, m_calculateFlags, maxDistance, source.Sound.FrequencyRatio, sourceVoice.Silent, !source.Realistic);
            }
            else
            {
                float maxDistance = source.CustomMaxDistance.Value;
                m_helperEmitter.UpdateValuesOmni(source.SourcePosition, source.Velocity, maxDistance, m_deviceDetails.OutputFormat.Channels, cue.VolumeCurve);
                sourceVoice.distanceToListener = m_x3dAudio.Apply3D(sourceVoice.Voice, m_listener, m_helperEmitter, source.SourceChannels, m_deviceDetails.OutputFormat.Channels, m_calculateFlags, maxDistance, sourceVoice.FrequencyRatio, sourceVoice.Silent, !source.Realistic);
            }
        }