summaryrefslogtreecommitdiff
path: root/src/mq/mq.h
diff options
context:
space:
mode:
authorJohn Glover <j@johnglover.net>2012-10-24 17:31:53 +0200
committerJohn Glover <j@johnglover.net>2012-10-24 17:31:53 +0200
commit1023eb542bb7b43fb49fdfbff59c88e75b81415f (patch)
treedc59bc3f664e9154a72fb2565c9978ccaee2e2ac /src/mq/mq.h
parent03d7fafff27767d0d5707cb17166963d652cb953 (diff)
downloadsimpl-1023eb542bb7b43fb49fdfbff59c88e75b81415f.tar.gz
simpl-1023eb542bb7b43fb49fdfbff59c88e75b81415f.tar.bz2
simpl-1023eb542bb7b43fb49fdfbff59c88e75b81415f.zip
[mq] Tidy up C++ MQ implementation.
Diffstat (limited to 'src/mq/mq.h')
-rw-r--r--src/mq/mq.h50
1 files changed, 29 insertions, 21 deletions
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 <cstdlib>
#include <fftw3.h>
#include <math.h>
+#include <string.h>
+
+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