CopyGainTo() 공개 메소드

Copies and multuplies by gain data from one GATData instance to another.
public CopyGainTo ( GATData destinationData, int sourceIndex, int destinationIndex, int length, float gain ) : void
destinationData GATData
sourceIndex int
destinationIndex int
length int
gain float
리턴 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
파일: GATTrack.cs 프로젝트: gregzo/G-Audio
        /// <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;
        }