From d8aadcb604f8cd695b7d0d30a8cb36196e02e410 Mon Sep 17 00:00:00 2001 From: John Glover Date: Mon, 2 Jul 2012 19:32:10 +0100 Subject: [base] Updates to Frame peak/partial getters/setters. --- src/simpl/base.cpp | 36 +++++++++++++++++++++++++++--------- src/simpl/base.h | 7 ++++++- 2 files changed, 33 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/simpl/base.cpp b/src/simpl/base.cpp index 3e822ae..3b35251 100644 --- a/src/simpl/base.cpp +++ b/src/simpl/base.cpp @@ -95,8 +95,11 @@ Frame::~Frame() { } void Frame::init() { + _num_peaks = 0; _max_peaks = 100; + _num_partials = 0; _max_partials = 100; + _peaks.resize(_max_peaks); _partials.resize(_max_partials); _audio = NULL; _synth = NULL; @@ -108,9 +111,14 @@ void Frame::init() { // ------------- int Frame::num_peaks() { - return _peaks.size(); + return _num_peaks; +} + +void Frame::num_peaks(int new_num_peaks) { + _num_peaks = new_num_peaks; } + int Frame::max_peaks() { return _max_peaks; } @@ -125,29 +133,34 @@ void Frame::max_peaks(int new_max_peaks) { } void Frame::add_peak(Peak* peak) { - _peaks.push_back(peak); -} - -void Frame::add_peaks(Peaks* peaks) { - for(Peaks::iterator i = peaks->begin(); i != peaks->end(); i++) { - add_peak(*i); - } + _peaks[_num_peaks] = peak; + _num_peaks++; } Peak* Frame::peak(int peak_number) { return _peaks[peak_number]; } +void Frame::peak(int peak_number, Peak* peak) { + _peaks[peak_number] = peak; +} + void Frame::clear() { _peaks.clear(); _partials.clear(); + _num_peaks = 0; + _num_partials = 0; } // Frame - partials // ---------------- int Frame::num_partials() { - return _partials.size(); + return _num_partials; +} + +void Frame::num_partials(int new_num_partials) { + _num_partials = new_num_partials; } int Frame::max_partials() { @@ -163,6 +176,11 @@ void Frame::max_partials(int new_max_partials) { } } +void Frame::add_partial(Peak* peak) { + _partials[_num_partials] = peak; + _num_partials++; +} + Peak* Frame::partial(int partial_number) { return _partials[partial_number]; } diff --git a/src/simpl/base.h b/src/simpl/base.h index 7589264..b82ded1 100644 --- a/src/simpl/base.h +++ b/src/simpl/base.h @@ -80,7 +80,9 @@ class Frame { private: int _size; int _max_peaks; + int _num_peaks; int _max_partials; + int _num_partials; Peaks _peaks; Peaks _partials; sample* _audio; @@ -96,17 +98,20 @@ class Frame { // peaks int num_peaks(); + void num_peaks(int new_num_peaks); int max_peaks(); void max_peaks(int new_max_peaks); void add_peak(Peak* peak); - void add_peaks(Peaks* peaks); Peak* peak(int peak_number); + void peak(int peak_number, Peak* peak); void clear(); // partials int num_partials(); + void num_partials(int new_num_partials); int max_partials(); void max_partials(int new_max_partials); + void add_partial(Peak* peak); Peak* partial(int partial_number); void partial(int partial_number, Peak* peak); -- cgit v1.2.3