diff options
author | Jamie Bullock <jamie@jamiebullock.com> | 2014-03-11 18:14:45 +0000 |
---|---|---|
committer | Jamie Bullock <jamie@jamiebullock.com> | 2014-03-11 18:14:45 +0000 |
commit | c7e8efcbea13ca27f1b6f5619f05e1f79d36ba55 (patch) | |
tree | 71f8135a795027a386f4e91f4c773346a0d09d5c /src/scalar.c | |
parent | 14c4d07be16ce3ba36d28eeef507afdc1afed8f6 (diff) | |
download | LibXtract-c7e8efcbea13ca27f1b6f5619f05e1f79d36ba55.tar.gz LibXtract-c7e8efcbea13ca27f1b6f5619f05e1f79d36ba55.tar.bz2 LibXtract-c7e8efcbea13ca27f1b6f5619f05e1f79d36ba55.zip |
Add xtract_midicent() convenience function to convert from frequency to MIDI cent
Diffstat (limited to 'src/scalar.c')
-rw-r--r-- | src/scalar.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/scalar.c b/src/scalar.c index 2e93934..4ae3f16 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -983,4 +983,15 @@ int xtract_wavelet_f0(const double *data, const int N, const void *argv, double return XTRACT_SUCCESS; } +int xtract_midicent(const double *data, const int N, const void *argv, double *result) +{ + double f0 = *(double *)argv; + double note = 0.0; + + note = 69 + log(f0 / 440.f) * 17.31234; + note *= 100; + note = round(note); + + return XTRACT_SUCCESS; +} |