/// <summary> /// Write the status of the voice to the given user output. /// </summary> /// <param name="outStatus">The given user output.</param> /// <param name="parameter">The user parameter.</param> /// <param name="voiceUpdateStates">The voice states associated to the <see cref="VoiceState"/>.</param> public void WriteOutStatus(ref VoiceOutStatus outStatus, ref VoiceInParameter parameter, Memory <VoiceUpdateState>[] voiceUpdateStates) { #if DEBUG // Sanity check in debug mode of the internal state if (!parameter.IsNew && !IsNew) { for (int i = 1; i < ChannelsCount; i++) { ref VoiceUpdateState stateA = ref voiceUpdateStates[i - 1].Span[0]; ref VoiceUpdateState stateB = ref voiceUpdateStates[i].Span[0]; Debug.Assert(stateA.WaveBufferConsumed == stateB.WaveBufferConsumed); Debug.Assert(stateA.PlayedSampleCount == stateB.PlayedSampleCount); Debug.Assert(stateA.Offset == stateB.Offset); Debug.Assert(stateA.WaveBufferIndex == stateB.WaveBufferIndex); Debug.Assert(stateA.Fraction == stateB.Fraction); Debug.Assert(stateA.IsWaveBufferValid.SequenceEqual(stateB.IsWaveBufferValid)); }
public void Process(CommandList context) { for (int i = 0; i < MixBufferCount; i++) { ReadOnlySpan <float> inputBuffer = context.GetBuffer(InputBufferIndices[i]); Span <float> outputBuffer = context.GetBuffer(OutputBufferIndices[i]); float volume0 = Volume0[i]; float volume1 = Volume1[i]; ref VoiceUpdateState state = ref State.Span[0]; if (volume0 != 0 || volume1 != 0) { state.LastSamples[i] = ProcessMixRampGrouped(outputBuffer, inputBuffer, volume0, volume1, (int)context.SampleCount); } else { state.LastSamples[i] = 0; } }