From 5fb34d7d5451cefd88bb9d7a0d9c442d67caf143 Mon Sep 17 00:00:00 2001 From: John Glover Date: Wed, 22 Aug 2012 14:29:33 +0100 Subject: [loris] LorisPeakDetection updates and fixes (save bandwidth to simpl Peak objects). --- src/simpl/base.cpp | 1 + src/simpl/base.h | 1 + src/simpl/peak_detection.cpp | 14 ++++++-------- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/simpl/base.cpp b/src/simpl/base.cpp index c3c8ea5..2377c01 100644 --- a/src/simpl/base.cpp +++ b/src/simpl/base.cpp @@ -11,6 +11,7 @@ Peak::Peak() { amplitude = 0.0; frequency = 0.0; phase = 0.0; + bandwidth = 0.0; next_peak = NULL; previous_peak = NULL; partial_id = 0; diff --git a/src/simpl/base.h b/src/simpl/base.h index cbd1fbf..040e199 100644 --- a/src/simpl/base.h +++ b/src/simpl/base.h @@ -22,6 +22,7 @@ class Peak { sample amplitude; sample frequency; sample phase; + sample bandwidth; Peak* next_peak; Peak* previous_peak; int partial_id; diff --git a/src/simpl/peak_detection.cpp b/src/simpl/peak_detection.cpp index 09ce788..ff66278 100644 --- a/src/simpl/peak_detection.cpp +++ b/src/simpl/peak_detection.cpp @@ -144,7 +144,7 @@ Frames PeakDetection::find_peaks(int audio_size, sample* audio) { // get the next frame Frame* f = new Frame(_frame_size); - f->audio(&audio[pos]); + f->audio(&(audio[pos])); f->max_peaks(_max_peaks); // find peaks @@ -414,12 +414,10 @@ void SimplLorisAnalyzer::analyze(int audio_size, sample* audio) { _spectrum->transform(audio, audio + (audio_size / 2), audio + audio_size); peaks = _peak_selector->selectPeaks(*_spectrum, m_freqFloor); - // Loris::Peaks::iterator rejected = thinPeaks(peaks, 0); - // fixBandwidth(peaks); - // if(m_bwAssocParam > 0) { - // _bw_associator->associateBandwidth(peaks.begin(), rejected, peaks.end()); - // } - // peaks.erase(rejected, peaks.end()); + fixBandwidth(peaks); + if(m_bwAssocParam > 0) { + _bw_associator->associateBandwidth(peaks.begin(), peaks.end(), peaks.end()); + } } // --------------------------------------------------------------------------- @@ -474,7 +472,7 @@ Peaks LorisPeakDetection::find_peaks_in_frame(Frame* frame) { Peak* p = new Peak(); p->amplitude = _analyzer->peaks[i].amplitude(); p->frequency = _analyzer->peaks[i].frequency(); - p->phase = 0.f; + p->bandwidth = _analyzer->peaks[i].bandwidth(); peaks.push_back(p); frame->add_peak(p); } -- cgit v1.2.3