diff options
author | John Glover <j@johnglover.net> | 2012-10-24 22:48:34 +0200 |
---|---|---|
committer | John Glover <j@johnglover.net> | 2012-10-24 22:48:34 +0200 |
commit | 22648d5210892739f0eabe68afc34839b2bebb2c (patch) | |
tree | b482be4d5abb0b596deaf0151283d2d3d7420b86 /src/mq/mq.h | |
parent | 4c9d241754b134d7704bdea04ec90be758eb47c1 (diff) | |
download | simpl-22648d5210892739f0eabe68afc34839b2bebb2c.tar.gz simpl-22648d5210892739f0eabe68afc34839b2bebb2c.tar.bz2 simpl-22648d5210892739f0eabe68afc34839b2bebb2c.zip |
[mq] Add C++ MQPartialTracking class
Diffstat (limited to 'src/mq/mq.h')
-rw-r--r-- | src/mq/mq.h | 107 |
1 files changed, 77 insertions, 30 deletions
diff --git a/src/mq/mq.h b/src/mq/mq.h index d2f24cc..0c6a11c 100644 --- a/src/mq/mq.h +++ b/src/mq/mq.h @@ -7,44 +7,91 @@ #include <math.h> #include <string.h> +#include "base.h" + namespace simpl { -typedef double sample; - -typedef struct MQPeak { - float amplitude; - float frequency; - float phase; - int bin; - struct MQPeak* next; - struct MQPeak* prev; -} MQPeak; - -typedef struct MQPeakList { - struct MQPeakList* next; - struct MQPeakList* prev; - struct MQPeak* peak; -} MQPeakList; - -typedef struct MQParameters { - int frame_size; - int max_peaks; - int num_bins; - sample peak_threshold; - sample fundamental; - sample matching_interval; - sample* window; - sample* fft_in; - fftw_complex* fft_out; - fftw_plan fft_plan; - MQPeakList* prev_peaks; -} MQParameters; +// --------------------------------------------------------------------------- +// MQPeak +// --------------------------------------------------------------------------- +class MQPeak { + public: + float amplitude; + float frequency; + float phase; + int bin; + MQPeak* next; + MQPeak* prev; + + MQPeak() { + amplitude = 0.f; + frequency = 0.f; + phase = 0.f; + bin = 0; + next = NULL; + prev = NULL; + } +}; + + +// --------------------------------------------------------------------------- +// MQPeakList +// --------------------------------------------------------------------------- +class MQPeakList { + public: + MQPeakList* next; + MQPeakList* prev; + MQPeak* peak; + + MQPeakList() { + next = NULL; + prev = NULL; + peak = NULL; + } +}; + + +// --------------------------------------------------------------------------- +// MQParameters +// --------------------------------------------------------------------------- +class MQParameters { + public: + int frame_size; + int max_peaks; + int num_bins; + sample peak_threshold; + sample fundamental; + sample matching_interval; + sample* window; + sample* fft_in; + fftw_complex* fft_out; + fftw_plan fft_plan; + MQPeakList* prev_peaks; + + MQParameters() { + frame_size = 0; + max_peaks = 0; + num_bins = 0; + peak_threshold = 0.f; + fundamental = 0.f; + matching_interval = 0.f; + window = NULL; + fft_in = NULL; + fft_out = NULL; + prev_peaks = NULL; + } +}; + +// --------------------------------------------------------------------------- +// MQ functions +// --------------------------------------------------------------------------- int init_mq(MQParameters* params); void reset_mq(MQParameters* params); int destroy_mq(MQParameters* params); +void mq_add_peak(MQPeak* new_peak, MQPeakList* peak_list); void delete_peak_list(MQPeakList* peak_list); MQPeakList* mq_sort_peaks_by_frequency(MQPeakList* peak_list, int num_peaks); |