GAudio.GATData.GainMixTo C# (CSharp) Method

GainMixTo() public method

Additive copy and gain to another GATData instance
public GainMixTo ( GATData destinationData, int sourceIndex, int destinationIndex, int length, float gain ) : void
destinationData GATData
sourceIndex int
destinationIndex int
length int
gain float
return void
        public void GainMixTo( GATData destinationData, int sourceIndex, int destinationIndex, int length, float gain )
        {
            sourceIndex += _offset;
            length 		+= sourceIndex;

            float[] destinationArray = destinationData.ParentArray;

            destinationIndex += destinationData._offset;

            while( sourceIndex < length )
            {
                destinationArray[ destinationIndex ] += _parentArray[ sourceIndex ] * gain;
                sourceIndex++;
                destinationIndex++;
            }
        }

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Called by GATPlayer.
        /// Needed when overriding default mixing:
        /// If a sample is routed through a track,
        /// it should be mixed to it.
        /// </summary>
        public void MixFrom(GATData data, int index, int offsetInBuffer, int length, float gain = 1f)
        {
            if (!_active)
            {
                return;
            }

            if (_bufferIsDirty)              //Contains old data
            {
                int lastIndex = offsetInBuffer + length;

                if (lastIndex < GATInfo.AudioBufferSizePerChannel || offsetInBuffer > 0)                  //if what we want to add to the buffer doesn't fill it, let's clear it first
                {
                    _trackBuffer.Clear();
                }

                if (gain == 1f)
                {
                    data.CopyTo(_trackBuffer, offsetInBuffer, index, length);                       // no need to mix on dirty or empty data, simply copy
                }
                else
                {
                    data.CopyGainTo(_trackBuffer, index, offsetInBuffer, length, gain);
                }

                _bufferIsDirty = false;
            }
            else
            {
                if (gain == 1f)
                {
                    data.MixTo(_trackBuffer, offsetInBuffer, index, length);
                }
                else
                {
                    data.GainMixTo(_trackBuffer, index, offsetInBuffer, length, gain);
                }
            }

            NbOfMixedSamples++;
            _hasData = true;
        }
All Usage Examples Of GAudio.GATData::GainMixTo