00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 // 00029 // Last changed : $Date$ 00030 // File revision : $Revision$ 00031 // 00032 // $Id$ 00033 // 00035 // 00036 // License : 00037 // 00038 // SoundTouch audio processing library 00039 // Copyright (c) Olli Parviainen 00040 // 00041 // This library is free software; you can redistribute it and/or 00042 // modify it under the terms of the GNU Lesser General Public 00043 // License as published by the Free Software Foundation; either 00044 // version 2.1 of the License, or (at your option) any later version. 00045 // 00046 // This library is distributed in the hope that it will be useful, 00047 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00048 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00049 // Lesser General Public License for more details. 00050 // 00051 // You should have received a copy of the GNU Lesser General Public 00052 // License along with this library; if not, write to the Free Software 00053 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00054 // 00056 00057 #ifndef _BPMDetect_H_ 00058 #define _BPMDetect_H_ 00059 00060 #include "STTypes.h" 00061 #include "FIFOSampleBuffer.h" 00062 00064 #define MIN_BPM 45 00065 00067 #define MAX_BPM 230 00068 00069 00071 class BPMDetect 00072 { 00073 protected: 00075 float *xcorr; 00076 00078 float envelopeAccu; 00079 00081 float RMSVolumeAccu; 00082 00084 int decimateCount; 00085 00087 soundtouch::LONG_SAMPLETYPE decimateSum; 00088 00090 int decimateBy; 00091 00093 int windowLen; 00094 00096 int channels; 00097 00099 int sampleRate; 00100 00103 int windowStart; 00104 00106 soundtouch::FIFOSampleBuffer *buffer; 00107 00109 void init(int numChannels, int sampleRate); 00110 00114 void updateXCorr(int process_samples 00115 ); 00116 00120 int decimate(soundtouch::SAMPLETYPE *dest, 00121 const soundtouch::SAMPLETYPE *src, 00122 int numsamples 00123 ); 00124 00127 void calcEnvelope(soundtouch::SAMPLETYPE *samples, 00128 int numsamples 00129 ); 00130 00131 public: 00133 BPMDetect(int numChannels, 00134 int sampleRate 00135 ); 00136 00138 virtual ~BPMDetect(); 00139 00146 void inputSamples(soundtouch::SAMPLETYPE *samples, 00147 int numSamples 00148 ); 00149 00150 00156 float getBpm(); 00157 }; 00158 00159 #endif // _BPMDetect_H_
1.6.3