MixTo() публичный Метод

Additive copy to another GATData instance
public MixTo ( GATData destination, int destinationIndex, int sourceIndex, int length ) : void
destination GATData
destinationIndex int
sourceIndex int
length int
Результат void
Пример #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;
        }
Пример #2
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;
        }