/// <summary> /// Sets gain for specified channel. /// If the gain delta is too large, /// gain will be smoothed over the /// length of the audio buffer to /// prevent crackling. /// Does nothing if the specified channel does not exist. /// </summary> public void SetGainForChannel(float gain, int channel) { if (channel >= _indexedChannelGains.Length) { return; } GATDynamicChannelGain channelGain = _indexedChannelGains[channel]; if (channelGain == null) { _indexedChannelGains[channel] = new GATDynamicChannelGain(channel, gain); channelGains.Add(_indexedChannelGains[channel]); } else { channelGain.NextGain = gain; } _needsUpdate = true; }
/// <summary> /// Copy and interpolated gain to an interleaved float[] /// </summary> public void SmoothedGainCopyToInterlaced(float[] destinationArray, int destinationOffset, int sourceIndex, int length, GATDynamicChannelGain channelGain) { float gain; float interpolationDelta; gain = channelGain.PrevGain; interpolationDelta = channelGain.InterpolationDelta; sourceIndex = sourceIndex + _offset; length = sourceIndex + length; destinationOffset += channelGain.ChannelNumber; while (sourceIndex < length) { destinationArray[destinationOffset] = _parentArray[sourceIndex] * gain; destinationOffset += GATInfo.NbOfChannels; gain += interpolationDelta; sourceIndex++; } }
/// <summary> /// Additive copy and interpolated gain to an interleaved float[] with extra gain parameter /// </summary> public void SmoothedGainMixToInterlaced( float[] destinationArray, int destinationOffset, int sourceIndex, int length, GATDynamicChannelGain channelGain, float igain ) { float gain; float interpolationDelta; gain = channelGain.PrevGain; interpolationDelta = channelGain.InterpolationDelta; sourceIndex = sourceIndex + _offset; length = sourceIndex + length; destinationOffset += channelGain.ChannelNumber; while( sourceIndex < length ) { destinationArray[ destinationOffset ] += _parentArray[sourceIndex] * gain * igain; destinationOffset += GATInfo.NbOfChannels; gain += interpolationDelta; sourceIndex++; } }