Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="BpmDetect&lt;TSampleType, TLongSampleType&gt;"/> class.
        /// </summary>
        /// <param name="numChannels">Number of channels in sample data.</param>
        /// <param name="sampleRate">Sample rate in Hz.</param>
        protected BpmDetect(int numChannels, int sampleRate)
        {
            _sampleRate = sampleRate;
            Channels    = numChannels;

            DecimateSum   = default(TLongSampleType);
            DecimateCount = 0;

            _envelopeAccu = 0;

            // choose decimation factor so that result is approx. 1000 Hz
            DecimateBy = sampleRate / 1000;
            Debug.Assert(DecimateBy > 0);
            Debug.Assert(INPUT_BLOCK_SAMPLES < DecimateBy * DECIMATED_BLOCK_SAMPLES);

            // Calculate window length & starting item according to desired min & max bpms
            WindowLen   = (60 * sampleRate) / (DecimateBy * MIN_BPM);
            WindowStart = (60 * sampleRate) / (DecimateBy * MAX_BPM);

            Debug.Assert(WindowLen > WindowStart);

            // allocate new working objects
            Xcorr = new float[WindowLen];

            // allocate processing buffer
            Buffer = new FifoSampleBuffer <TSampleType>();
            // we do processing in mono mode
            Buffer.SetChannels(1);
            Buffer.Clear();
        }
Ejemplo n.º 2
0
        /// <summary>Sets the number of channels, 1 = mono, 2 = stereo</summary>
        public void SetChannels(int numChannels)
        {
            Debug.Assert(numChannels > 0);
            if (_channels == numChannels)
            {
                return;
            }
            Debug.Assert(numChannels == 1 || numChannels == 2);

            _channels = numChannels;
            _inputBuffer.SetChannels(_channels);
            _outputBuffer.SetChannels(_channels);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets the number of channels, 1 = mono, 2 = stereo
        /// </summary>
        public void SetChannels(int channels)
        {
            Debug.Assert(channels > 0);

            if (_transposer.channels == channels)
            {
                return;
            }
            _transposer.SetChannels(channels);

            _inputBuffer.SetChannels(channels);
            _midBuffer.SetChannels(channels);
            _outputBuffer.SetChannels(channels);
        }
Ejemplo n.º 4
0
        /// <summary>Sets the number of channels, 1 = mono, 2 = stereo</summary>
        public void SetChannels(int numChannels)
        {
            Debug.Assert(numChannels > 0);
            if (_channels == numChannels)
            {
                return;
            }
            // Debug.Assert(numChannels == 1 || numChannels == 2);

            _channels = numChannels;
            _inputBuffer.SetChannels(_channels);
            _outputBuffer.SetChannels(_channels);

            // re-init overlap/buffer
            _overlapLength = 0;
            SetParameters(_sampleRate);
        }
        /// <summary>
        /// Sets the number of channels, 1 = mono, 2 = stereo
        /// </summary>
        public void SetChannels(int channels)
        {
            Debug.Assert(channels > 0);
            if (_channels == channels)
            {
                return;
            }

            Debug.Assert((channels == 1) || (channels == 2));
            _channels = channels;

            _storeBuffer.SetChannels(_channels);
            _tempBuffer.SetChannels(_channels);
            _outputBuffer.SetChannels(_channels);

            // Inits the linear interpolation registers
            ResetRegisters();
        }