/// <summary> /// Generate a new <see cref="DelayCommand"/>. /// </summary> /// <param name="bufferOffset">The target buffer offset.</param> /// <param name="parameter">The delay parameter.</param> /// <param name="state">The delay state.</param> /// <param name="isEnabled">Set to true if the effect should be active.</param> /// <param name="workBuffer">The work buffer to use for processing.</param> /// <param name="nodeId">The node id associated to this command.</param> /// <param name="newEffectChannelMappingSupported">If set to true, the new effect channel mapping for 5.1 is supported.</param> public void GenerateDelayEffect(uint bufferOffset, DelayParameter parameter, Memory <DelayState> state, bool isEnabled, CpuAddress workBuffer, int nodeId, bool newEffectChannelMappingSupported) { if (parameter.IsChannelCountValid()) { DelayCommand command = new DelayCommand(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported); command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command); AddCommand(command); } }
public DelayState(ref DelayParameter parameter, ulong workBuffer) { DelayLines = new DelayLine[parameter.ChannelCount]; LowPassZ = new float[parameter.ChannelCount]; uint sampleRate = (uint)FixedPointHelper.ToInt(parameter.SampleRate, FixedPointPrecision) / 1000; for (int i = 0; i < DelayLines.Length; i++) { DelayLines[i] = new DelayLine(sampleRate, parameter.DelayTimeMax); DelayLines[i].SetDelay(parameter.DelayTime); } UpdateParameter(ref parameter); }
public DelayCommand(uint bufferOffset, DelayParameter parameter, Memory <DelayState> state, bool isEnabled, ulong workBuffer, int nodeId) { Enabled = true; NodeId = nodeId; _parameter = parameter; State = state; WorkBuffer = workBuffer; IsEffectEnabled = isEnabled; InputBufferIndices = new ushort[Constants.VoiceChannelCountMax]; OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax]; for (int i = 0; i < Parameter.ChannelCount; i++) { InputBufferIndices[i] = (ushort)(bufferOffset + Parameter.Input[i]); OutputBufferIndices[i] = (ushort)(bufferOffset + Parameter.Output[i]); } }
public void UpdateParameter(ref DelayParameter parameter) { FeedbackGain = FixedPointHelper.ToFloat(parameter.FeedbackGain, FixedPointPrecision) * 0.98f; float channelSpread = FixedPointHelper.ToFloat(parameter.ChannelSpread, FixedPointPrecision); DelayFeedbackBaseGain = (1.0f - channelSpread) * FeedbackGain; if (parameter.ChannelCount == 4 || parameter.ChannelCount == 6) { DelayFeedbackCrossGain = channelSpread * 0.5f * FeedbackGain; } else { DelayFeedbackCrossGain = channelSpread * FeedbackGain; } LowPassFeedbackGain = 0.95f * FixedPointHelper.ToFloat(parameter.LowPassAmount, FixedPointPrecision); LowPassBaseGain = 1.0f - LowPassFeedbackGain; }
public DelayCommand(uint bufferOffset, DelayParameter parameter, Memory <DelayState> state, bool isEnabled, ulong workBuffer, int nodeId, bool newEffectChannelMappingSupported) { Enabled = true; NodeId = nodeId; _parameter = parameter; State = state; WorkBuffer = workBuffer; IsEffectEnabled = isEnabled; InputBufferIndices = new ushort[Constants.VoiceChannelCountMax]; OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax]; for (int i = 0; i < Parameter.ChannelCount; i++) { InputBufferIndices[i] = (ushort)(bufferOffset + Parameter.Input[i]); OutputBufferIndices[i] = (ushort)(bufferOffset + Parameter.Output[i]); } // NOTE: We do the opposite as Nintendo here for now to restore previous behaviour // TODO: Update delay processing and remove this to use RemapLegacyChannelEffectMappingToChannelResourceMapping. DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, InputBufferIndices); DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, OutputBufferIndices); }