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 /xtract | |
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 'xtract')
-rw-r--r-- | xtract/libxtract.h | 6 | ||||
-rw-r--r-- | xtract/xtract_scalar.h | 13 |
2 files changed, 17 insertions, 2 deletions
diff --git a/xtract/libxtract.h b/xtract/libxtract.h index ce12e14..1f4a787 100644 --- a/xtract/libxtract.h +++ b/xtract/libxtract.h @@ -71,7 +71,7 @@ extern "C" { * @{ */ -#define XTRACT_FEATURES 60 +#define XTRACT_FEATURES 61 /** \brief Enumeration of features, elements are used as indixes to an array of pointers to feature extracton functions */ enum xtract_features_ { @@ -117,6 +117,7 @@ enum xtract_features_ { XTRACT_F0, XTRACT_FAILSAFE_F0, XTRACT_WAVELET_F0, + XTRACT_MIDICENT, XTRACT_LNORM, XTRACT_FLUX, XTRACT_ATTACK_TIME, @@ -208,7 +209,8 @@ typedef enum unit_ { XTRACT_DBFS_HERTZ, XTRACT_PERCENT, XTRACT_BINS, - XTRACT_SONE + XTRACT_SONE, + XTRACT_MIDI_CENT } xtract_unit_t; /** \brief Boolean */ diff --git a/xtract/xtract_scalar.h b/xtract/xtract_scalar.h index e18aea6..4e39fd9 100644 --- a/xtract/xtract_scalar.h +++ b/xtract/xtract_scalar.h @@ -434,6 +434,19 @@ int xtract_failsafe_f0(const double *data, const int N, const void *argv, double */ int xtract_wavelet_f0(const double *data, const int N, const void *argv, double *result); + +/** \brief Convenience function to convert a frequency in Hertz to a "pitch" value in MIDI cents + * + * \param *data: not used + * \param N: not used + * \param *argv: a pointer to a double-precision floating point value representing a frequency in Hertz + * \param *result: a pointer to a double-precision floating point value representing a "pitch" in MIDI cents + * \return if *argv value causes a *result within the range 0..127, XTRACT_SUCCESS will be returned, otherwise XTRACT_ARGUMENT_ERROR + * + */ +int xtract_midicent(const double *data, const int N, const void *argv, double *result); + + /** \brief Extract the number of non-zero elements in an input vector * * \param *data: a pointer to the first element in an array of doubles |