From 1023eb542bb7b43fb49fdfbff59c88e75b81415f Mon Sep 17 00:00:00 2001 From: John Glover Date: Wed, 24 Oct 2012 17:31:53 +0200 Subject: [mq] Tidy up C++ MQ implementation. --- src/mq/mq.h | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'src/mq/mq.h') diff --git a/src/mq/mq.h b/src/mq/mq.h index 611203d..d2f24cc 100644 --- a/src/mq/mq.h +++ b/src/mq/mq.h @@ -1,50 +1,58 @@ -#ifndef _MQ_H -#define _MQ_H +#ifndef _SIMPL_MQ_H +#define _SIMPL_MQ_H + +#include #include #include +#include + +namespace simpl +{ + typedef double sample; -typedef struct Peak -{ +typedef struct MQPeak { float amplitude; float frequency; float phase; int bin; - struct Peak* next; - struct Peak* prev; -} Peak; + struct MQPeak* next; + struct MQPeak* prev; +} MQPeak; -typedef struct PeakList -{ - struct PeakList* next; - struct PeakList* prev; - struct Peak* peak; -} PeakList; +typedef struct MQPeakList { + struct MQPeakList* next; + struct MQPeakList* prev; + struct MQPeak* peak; +} MQPeakList; -typedef struct MQParameters -{ +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; - PeakList* prev_peaks; + MQPeakList* prev_peaks; } MQParameters; int init_mq(MQParameters* params); void reset_mq(MQParameters* params); int destroy_mq(MQParameters* params); -void delete_peak_list(PeakList* peak_list); +void delete_peak_list(MQPeakList* peak_list); + +MQPeakList* mq_sort_peaks_by_frequency(MQPeakList* peak_list, int num_peaks); +MQPeakList* mq_find_peaks(int signal_size, sample* signal, + MQParameters* params); +MQPeakList* mq_track_peaks(MQPeakList* peak_list, MQParameters* params); + +} // end of namespace simpl -PeakList* sort_peaks_by_frequency(PeakList* peak_list, int num_peaks); -PeakList* find_peaks(int signal_size, sample* signal, MQParameters* params); -PeakList* track_peaks(PeakList* peak_list, MQParameters* params); - #endif -- cgit v1.2.3