-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathanalyse.h
91 lines (81 loc) · 3.25 KB
/
analyse.h
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
/* header file for analyse.c --
* routines to analyse power spectrum and output notes
* Copyright (C) 1998-2013 Kengo Ichiki <[email protected]>
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _ANALYSE_H_
#define _ANALYSE_H_
/* global variables */
extern int abs_flg; /* flag for absolute/relative cutoff */
extern int patch_flg; /* flag for using patch file */
extern double *pat; /* work area for patch */
extern int npat; /* # of data in pat[] */
extern double p0; /* maximum power */
extern double if0; /* freq point of maximum */
/** for stage 2 : note selection process **/
/* get intensity of notes from power spectrum
* INPUT
* p[] : power spectrum
* fp[] : frequencies for each bin
* if NULL, we use the center frequencies
* cut_ratio : log10 of cutoff ratio to scale velocity
* rel_cut_ratio : log10 of cutoff ratio relative to average
* 0 means cutoff is equal to average
* (global)abs_flg : 0 for relative, 1 for absolute
* i0, i1 : considering frequency range
* (global)patch_flg: whether patch is used or not.
* OUTPUT
* intens[128] : intensity [0,128) for each midi note
*/
void
note_intensity (double *p, double *fp,
double cut_ratio, double rel_cut_ratio,
int i0, int i1,
double t0, char *intens);
/*
* INPUT
* amp2 [(len/2)+1] : power spectrum (amp^2)
* dphi [(len/2)+1] : PV freq correction factor defined by
* (1/2pi hop)principal(phi - phi0 - Omega),
* therefore, the corrected freq is
* (k/len + dphi[k])*samplerate [Hz].
* give NULL for plain FFT power spectrum.
* OUTPUT
* ave2 [128] : averaged amp2 for each midi note
*/
void
average_FFT_into_midi (int len, double samplerate,
const double *amp2, const double *dphi,
double *ave2);
/* pickup notes and its power from a table of power for each midi note
* INPUT
* amp2midi [128] : amp^2 for each midi note
* cut_ratio : log10 of cutoff ratio to scale velocity
* rel_cut_ratio : log10 of cutoff ratio relative to average
* 0 means cutoff is equal to average
* i0, i1 : considering midi note range (NOT FREQUENCY INDEX!!)
* (global)abs_flg : 0 for relative, 1 for absolute
* OUTPUT
* intens[] : with 127 elements (# of notes)
*/
void
pickup_notes (double *amp2midi,
double cut_ratio, double rel_cut_ratio,
int i0, int i1,
char *intens);
double patch_power (double freq_ratio);
void init_patch (char *file_patch, int plen, int nwin);
#endif /* !_ANALYSE_H_ */