2 SuperCollider real time audio synthesis system
3 Copyright (c) 2002 James McCartney. All rights reserved.
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #define DFFRAMELENGTH 512
24 //store last 700 to avoid problems during amortisation
28 struct BeatTrack
: Unit
{
30 //corrections for different sampling rates: support 44100 as native, and 48000, 88200, 96000 by frequency domain down sampling
31 //assumes 1024 FFT for first two, 2048 for second two
33 float m_srateconversion
;
39 //float * m_prepareFFTBuf;
42 //fftwf_plan planTime2FFT;
49 //unsigned long m_vlog2n;
61 //for peak pick scorer
62 int m_dfmemorycounter
;
66 //autocorrelation results on df
67 float m_acf
[DFFRAMELENGTH
];
74 float m_phaseweights
[LAGS
];
83 float m_prevperiodp
[3];
85 //amortisation search for best phase from 0 to m_torround-1
86 float m_bestphasescore
;
95 //phasor, trigger beat and modulo when >1.0
96 float m_phase
, m_phaseperblock
;
98 //phasor output separate so can have it lock and keep going when don't want to track
99 float m_outputphase
, m_outputtempo
, m_outputphaseperblock
;
105 //amortization - more complex structure to support different rates of work
106 int m_amortisationstate
;
109 int m_amortisationsteps
;
115 int m_storedfcounter
;
116 int m_storedfcounterend
;
125 //required interface functions
126 void BeatTrack_next(BeatTrack
*unit
, int wrongNumSamples
);
127 void BeatTrack_Ctor(BeatTrack
*unit
);
128 void BeatTrack_Dtor(BeatTrack
*unit
);