summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Glover <j@johnglover.net>2012-08-12 17:26:56 +0100
committerJohn Glover <j@johnglover.net>2012-08-12 17:26:56 +0100
commit5d003fd462ad8de027730bc406d8a81ff33e2531 (patch)
tree628641e8bcbb7cbc9e4f0db62c7d487d67d7d6aa
parentc8b25884550c66ea00f32b9ab9ee75b4f158742f (diff)
downloadsimpl-5d003fd462ad8de027730bc406d8a81ff33e2531.tar.gz
simpl-5d003fd462ad8de027730bc406d8a81ff33e2531.tar.bz2
simpl-5d003fd462ad8de027730bc406d8a81ff33e2531.zip
[partial_tracking] Recreate SndObjs when changing
parameters instead of using Set<param> functions.
-rw-r--r--src/simpl/partial_tracking.cpp41
-rw-r--r--src/simpl/partial_tracking.h2
2 files changed, 29 insertions, 14 deletions
diff --git a/src/simpl/partial_tracking.cpp b/src/simpl/partial_tracking.cpp
index 27b7e12..fdafb84 100644
--- a/src/simpl/partial_tracking.cpp
+++ b/src/simpl/partial_tracking.cpp
@@ -202,32 +202,45 @@ Peaks SMSPartialTracking::update_partials(Frame* frame) {
SndObjPartialTracking::SndObjPartialTracking() {
_threshold = 0.003;
_num_bins = 1025;
- _input = new SndObj();
- _analysis = new SinAnal(_input, _num_bins, _threshold, _max_partials);
-
+ _input = NULL;
+ _analysis = NULL;
_peak_amplitude = NULL;
_peak_frequency = NULL;;
_peak_phase = NULL;
- init_peaks();
+ reset();
}
SndObjPartialTracking::~SndObjPartialTracking() {
- delete _input;
- delete _analysis;
+ if(_input) {
+ delete _input;
+ }
+ if(_analysis){
+ delete _analysis;
+ }
+ if(_peak_amplitude) {
+ delete [] _peak_amplitude;
+ }
+ if(_peak_frequency) {
+ delete [] _peak_frequency;
+ }
+ if(_peak_phase) {
+ delete [] _peak_phase;
+ }
_input = NULL;
_analysis = NULL;
-
- delete [] _peak_amplitude;
- delete [] _peak_frequency;
- delete [] _peak_phase;
-
_peak_amplitude = NULL;
_peak_frequency = NULL;;
_peak_phase = NULL;
}
-void SndObjPartialTracking::init_peaks() {
+void SndObjPartialTracking::reset() {
+ if(_input) {
+ delete _input;
+ }
+ if(_analysis){
+ delete _analysis;
+ }
if(_peak_amplitude) {
delete [] _peak_amplitude;
}
@@ -238,6 +251,8 @@ void SndObjPartialTracking::init_peaks() {
delete [] _peak_phase;
}
+ _input = new SndObj();
+ _analysis = new SinAnal(_input, _num_bins, _threshold, _max_partials);
_peak_amplitude = new sample[_max_partials];
_peak_frequency = new sample[_max_partials];
_peak_phase = new sample[_max_partials];
@@ -249,7 +264,7 @@ void SndObjPartialTracking::init_peaks() {
void SndObjPartialTracking::max_partials(int new_max_partials) {
_max_partials = new_max_partials;
- _analysis->Set("max tracks", new_max_partials);
+ reset();
}
Peaks SndObjPartialTracking::update_partials(Frame* frame) {
diff --git a/src/simpl/partial_tracking.h b/src/simpl/partial_tracking.h
index f94886e..4491b42 100644
--- a/src/simpl/partial_tracking.h
+++ b/src/simpl/partial_tracking.h
@@ -84,7 +84,7 @@ class SndObjPartialTracking : public PartialTracking {
sample* _peak_amplitude;
sample* _peak_frequency;
sample* _peak_phase;
- void init_peaks();
+ void reset();
public:
SndObjPartialTracking();