Mercurial > hg > libxtract
comparison src/scalar.c @ 208:d85e4b9aeb82
Set *result to note value in xtract_midicent(). Fixes bug.
author | Jamie Bullock <jamie@jamiebullock.com> |
---|---|
date | Tue, 11 Mar 2014 19:27:30 +0000 |
parents | c6488df9e5c0 |
children | 2bd416a4a0de |
comparison
equal
deleted
inserted
replaced
207:5357a64124f1 | 208:d85e4b9aeb82 |
---|---|
985 | 985 |
986 int xtract_midicent(const double *data, const int N, const void *argv, double *result) | 986 int xtract_midicent(const double *data, const int N, const void *argv, double *result) |
987 { | 987 { |
988 double f0 = *(double *)argv; | 988 double f0 = *(double *)argv; |
989 double note = 0.0; | 989 double note = 0.0; |
990 | 990 |
991 note = 69 + log(f0 / 440.f) * 17.31234; | 991 note = 69 + log(f0 / 440.f) * 17.31234; |
992 note *= 100; | 992 note *= 100; |
993 note = round(note); | 993 note = round(note); |
994 | 994 |
995 if (note > 12700 || note < 0) | 995 if (note > 12700 || note < 0) |
996 { | 996 { |
997 return XTRACT_ARGUMENT_ERROR; | 997 return XTRACT_ARGUMENT_ERROR; |
998 } | 998 } |
999 | 999 |
1000 return XTRACT_SUCCESS; | 1000 *result = note; |
1001 } | 1001 |
1002 | 1002 return XTRACT_SUCCESS; |
1003 } | |
1004 |