File: ML.h

package info (click to toggle)
supercollider 1%3A3.13.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,292 kB
  • sloc: cpp: 476,363; lisp: 84,680; ansic: 77,685; sh: 25,509; python: 7,909; makefile: 3,440; perl: 1,964; javascript: 974; xml: 826; java: 677; yacc: 314; lex: 175; objc: 152; ruby: 136
file content (150 lines) | stat: -rw-r--r-- 3,791 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
    SuperCollider real time audio synthesis system
 Copyright (c) 2002 James McCartney. All rights reserved.
    http://www.audiosynth.com

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

#include "SC_PlugIn.h"

// global data

// helpful constants
//#define PI 3.1415926535898f
//#define TWOPI 6.28318530717952646f

extern InterfaceTable* ft;

// shared data
extern int eqlbandbins[43];
extern int eqlbandsizes[42];
extern float contours[42][11];
extern double phons[11];

//#include "KeyTrack.h"
#include "BeatTrack.h"
//#include "Loudness.h"
#include "Onsets.h"
//#include "MFCC.h"
#include "BeatTrack2.h"

struct Loudness : Unit {
    // FFT data
    int m_numbands;
    float* m_ERBbands;

    // float m_phontotal;
    // final output
    float m_sones;
};


struct KeyTrack : Unit {
    // FFT data
    float* m_FFTBuf;

    // coping with different sampling rates
    float m_srate; // use as a flag to check sample rate is correct
    float* m_weights; // will point to the sample rate specific data
    int* m_bins;
    float m_frameperiod;

    // counter
    // uint32 m_frame;

    // experimental transient avoidance
    // float m_prevphase[720]; //60*12
    // float m_leaknote[60];

    float m_chroma[12];
    float m_key[24];

    float m_histogram[24]; // key histogram
                           // float m_keyleak; //fade parameter for histogram
    // int m_triggerid;

    int m_currentKey;
};


struct MFCC : Unit {
    // MFCC
    int m_numcoefficients;
    float* m_mfcc;
    // ERB
    int m_numbands;
    float* m_bands;

    // sampling rate specific data
    float m_srate;
    int* m_startbin;
    int* m_endbin;
    int* m_cumulindex;
    float* m_bandweights;
};

//////////////////////////////////////////////////////////////////////////////////////////////////

struct FFTAnalyser_Unit : Unit {
    float outval;

    // Not always used: multipliers which convert from bin indices to freq vals, and vice versa.
    // See also the macros for deriving these.
    float m_bintofreq /* , m_freqtobin */;
    float m_halfnyq_over_numbinsp2;
};

struct FFTAnalyser_OutOfPlace : FFTAnalyser_Unit {
    int m_numbins;
    float* m_tempbuf;
};

struct SpecFlatness : FFTAnalyser_Unit {
    double m_oneovern;
};

struct SpecPcile : FFTAnalyser_OutOfPlace {
    bool m_interpolate;
    bool m_binout;
};

struct SpecCentroid : FFTAnalyser_Unit {};


extern "C" {
// required interface functions
void Loudness_next(Loudness* unit, int wrongNumSamples);
void Loudness_Ctor(Loudness* unit);
void Loudness_Dtor(Loudness* unit);

void KeyTrack_next(KeyTrack* unit, int wrongNumSamples);
void KeyTrack_Ctor(KeyTrack* unit);
void KeyTrack_Dtor(KeyTrack* unit);

void MFCC_next(MFCC* unit, int wrongNumSamples);
void MFCC_Ctor(MFCC* unit);
void MFCC_Dtor(MFCC* unit);

void SpecFlatness_Ctor(SpecFlatness* unit);
void SpecFlatness_next(SpecFlatness* unit, int inNumSamples);
//
void SpecPcile_Ctor(SpecPcile* unit);
void SpecPcile_next(SpecPcile* unit, int inNumSamples);
void SpecPcile_Dtor(SpecPcile* unit);
//
void SpecCentroid_Ctor(SpecCentroid* unit);
void SpecCentroid_next(SpecCentroid* unit, int inNumSamples);
}