Ejemplo n.º 1
0
        /// <summary>
        /// Adds <paramref name="numSamples"/> pieces of samples from the
        /// <paramref name="samples"/> memory position into the input of the
        /// object. Notice that sample rate _has_to_ be set before calling this
        /// function, otherwise throws a runtime_error exception.
        /// </summary>
        /// <param name="samples">Pointer to sample buffer.</param>
        /// <param name="numSamples">Number of samples in buffer. Notice that in
        /// case of stereo-sound a single sample contains data for both
        /// channels.</param>
        /// <exception cref="InvalidOperationException">Sample rate or number of
        /// channels not defined</exception>
        public override void PutSamples(ArrayPtr <TSampletype> samples, int numSamples)
        {
            if (!_isSampleRateSet)
            {
                throw new InvalidOperationException("SoundTouch : Sample rate not defined");
            }
            if (_channels == 0)
            {
                throw new InvalidOperationException("SoundTouch : Number of channels not defined");
            }

            // accumulate how many samples are expected out from processing, given the current
            // processing setting
            _samplesExpectedOut += (double)numSamples / ((double)_rate * (double)_tempo);

#if !SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER
            if (_rate <= 1.0)
            {
                // transpose the rate down, output the transposed sound to tempo changer buffer
                Debug.Assert(Output == _stretch);
                _rateTransposer.PutSamples(samples, numSamples);
                _stretch.MoveSamples(_rateTransposer);
            }
            else
#endif
            {
                // evaluate the tempo changer, then transpose the rate up,
                Debug.Assert(Output == _rateTransposer);
                _stretch.PutSamples(samples, numSamples);
                _rateTransposer.MoveSamples(_stretch);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds <paramref name="numSamples"/> pieces of samples from the
        /// <paramref name="samples"/> memory position into the input of the
        /// object. Notice that sample rate _has_to_ be set before calling this
        /// function, otherwise throws a runtime_error exception.
        /// </summary>
        /// <param name="samples">Pointer to sample buffer.</param>
        /// <param name="numSamples">Number of samples in buffer. Notice that in
        /// case of stereo-sound a single sample contains data for both
        /// channels.</param>
        /// <exception cref="InvalidOperationException">Sample rate or number of
        /// channels not defined</exception>
        public override void PutSamples(ArrayPtr <TSampletype> samples, int numSamples)
        {
            if (!_isSampleRateSet)
            {
                throw new InvalidOperationException("SoundTouch : Sample rate not defined");
            }
            if (_channels == 0)
            {
                throw new InvalidOperationException("SoundTouch : Number of channels not defined");
            }

#if !SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER
            if (_rate <= 1.0)
            {
                // transpose the rate down, output the transposed sound to tempo changer buffer
                Debug.Assert(Output == _stretch);
                _rateTransposer.PutSamples(samples, numSamples);
                _stretch.MoveSamples(_rateTransposer);
            }
            else
#endif
            {
                // evaluate the tempo changer, then transpose the rate up,
                Debug.Assert(Output == _rateTransposer);
                _stretch.PutSamples(samples, numSamples);
                _rateTransposer.MoveSamples(_stretch);
            }
        }