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 //N feature stream inputs, cross correlation with template on each channel
24 //templates- search 120 tempi * 2 groove types (really just /2 and /3 subdivision) and no metrical discernment * a different numbers of phases depending on tempo
26 //assume 4 features * 120 tempi * 2 groove * 20 phase = 19200 per calculation time; say you calculate each 0.5 sec, amortise over (44100/64*0.5 >344.5) control blocks;
27 //calculate over 240 blocks
29 #include "SC_PlugIn.h"
31 struct BeatTrack2
: Unit
{
33 //adjust for any sampling rate by calculating factors; runs off of k rate inputs
35 float m_phaseaccuracy
; //probably 8 control blocks!
36 int m_numtempi
; //= 120;
42 float * m_features
; //pointer to control bus, assumes contiguous busnum for each consecutive feature
45 float m_temporalwindowsize
; //typically small, 2 seconds for fast reactions compared to 6 secs for BeatTrack
46 float m_fullwindowsize
;
48 int m_buffersize
; //in control blocks
50 float ** m_pastfeatures
; //for each feature, a trail of last m_workingmemorysize values
52 int m_counter
, m_startcounter
;
55 float m_calculationschedule
;
56 float m_calculationperiod
;
66 //phasor, trigger beat and modulo when >1.0
67 float m_phase
, m_phaseperblock
;
69 //phasor output separate so can have it lock and keep going when don't want to track
70 float m_outputphase
, m_outputtempo
, m_outputgroove
, m_outputphaseperblock
;
72 float m_predictphase
, m_predictperiod
;
74 //amortization - more complex structure to support different rates of work
75 int m_amortisationstate
;
78 int m_amortisationsteps
;
83 //tracking best results for each feature
84 //also storing second best and previous best and second best?
85 //thus keep best from previous round too for additional vote/consistency check
91 //or store all scores and resolve later?
97 SndBuf
* m_tempoweights
;
98 int m_weightingscheme
;
105 //required interface functions
106 void BeatTrack2_next(BeatTrack2
*unit
, int wrongNumSamples
);
107 void BeatTrack2_Ctor(BeatTrack2
*unit
);
108 void BeatTrack2_Dtor(BeatTrack2
*unit
);