diff options
author | John Glover <j@johnglover.net> | 2013-06-22 18:39:17 +0200 |
---|---|---|
committer | John Glover <j@johnglover.net> | 2013-06-22 18:39:17 +0200 |
commit | 142eb92a7669debb3748d85e56daa0e83d39464d (patch) | |
tree | a411cb183ab7b2dd80a605d8e6d699df708b51ca /src | |
parent | f10e69931e1eb9d484bc7431645529d756e19861 (diff) | |
download | simpl-142eb92a7669debb3748d85e56daa0e83d39464d.tar.gz simpl-142eb92a7669debb3748d85e56daa0e83d39464d.tar.bz2 simpl-142eb92a7669debb3748d85e56daa0e83d39464d.zip |
[residual] Add basic test for SMSResidual
Diffstat (limited to 'src')
-rw-r--r-- | src/simpl/residual.cpp | 30 | ||||
-rw-r--r-- | src/simpl/residual.h | 6 |
2 files changed, 32 insertions, 4 deletions
diff --git a/src/simpl/residual.cpp b/src/simpl/residual.cpp index d7d3181..38448ea 100644 --- a/src/simpl/residual.cpp +++ b/src/simpl/residual.cpp @@ -13,6 +13,24 @@ Residual::Residual() { _sampling_rate = 44100; } +Residual::~Residual() { + clear(); +} + +void Residual::clear() { + for(int i = 0; i < _frames.size(); i++) { + if(_frames[i]) { + delete _frames[i]; + _frames[i] = NULL; + } + } + + _frames.clear(); +} + +void Residual::reset() { +} + int Residual::frame_size() { return _frame_size; } @@ -64,11 +82,12 @@ Frames Residual::synth(Frames& frames) { } Frames Residual::synth(int original_size, sample* original) { - Frames frames; + clear(); unsigned int pos = 0; + bool alloc_memory_in_frame = true; while(pos <= original_size - _hop_size) { - Frame* f = new Frame(_frame_size, true); + Frame* f = new Frame(_frame_size, alloc_memory_in_frame); if((int)pos <= (original_size - _frame_size)) { f->audio(&(original[pos]), _frame_size); @@ -78,12 +97,12 @@ Frames Residual::synth(int original_size, sample* original) { } synth_frame(f); - frames.push_back(f); + _frames.push_back(f); pos += _hop_size; } - return frames; + return _frames; } @@ -109,6 +128,9 @@ SMSResidual::~SMSResidual() { sms_free(); } +void SMSResidual::reset() { +} + void SMSResidual::frame_size(int new_frame_size) { _frame_size = new_frame_size; _pd.frame_size(_frame_size); diff --git a/src/simpl/residual.h b/src/simpl/residual.h index e611fce..c162f84 100644 --- a/src/simpl/residual.h +++ b/src/simpl/residual.h @@ -27,9 +27,14 @@ class Residual { int _frame_size; int _hop_size; int _sampling_rate; + Frames _frames; + + void clear(); public: Residual(); + ~Residual(); + virtual void reset(); int frame_size(); virtual void frame_size(int new_frame_size); int hop_size(); @@ -62,6 +67,7 @@ class SMSResidual : public Residual { public: SMSResidual(); ~SMSResidual(); + void reset(); void frame_size(int new_frame_size); void hop_size(int new_hop_size); int num_stochastic_coeffs(); |