summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/simpl/base.cpp327
-rw-r--r--src/simpl/base.h150
-rw-r--r--src/simpl/exceptions.cpp2
-rw-r--r--src/simpl/exceptions.h2
-rw-r--r--src/simpl/partial_tracking.cpp73
-rw-r--r--src/simpl/partial_tracking.h48
-rw-r--r--src/simpl/peak_detection.cpp156
-rw-r--r--src/simpl/peak_detection.h77
-rw-r--r--src/simpl/residual.cpp64
-rw-r--r--src/simpl/residual.h47
-rw-r--r--src/simpl/simplsms.cpp9
-rw-r--r--src/simpl/simplsms.h17
-rw-r--r--src/simpl/synthesis.cpp57
-rw-r--r--src/simpl/synthesis.h43
14 files changed, 593 insertions, 479 deletions
diff --git a/src/simpl/base.cpp b/src/simpl/base.cpp
index 9d5f7ad..3e822ae 100644
--- a/src/simpl/base.cpp
+++ b/src/simpl/base.cpp
@@ -214,330 +214,3 @@ void Frame::synth_residual(sample* new_synth_residual) {
sample* Frame::synth_residual() {
return _synth_residual;
}
-
-
-// ---------------------------------------------------------------------------
-// PeakDetection
-// ---------------------------------------------------------------------------
-
-PeakDetection::PeakDetection() {
- _sampling_rate = 44100;
- _frame_size = 2048;
- _static_frame_size = true;
- _hop_size = 512;
- _max_peaks = 100;
- _window_type = "hamming";
- _window_size = 2048;
- _min_peak_separation = 1.0; // in Hz
-}
-
-PeakDetection::~PeakDetection() {
- clear();
-}
-
-void PeakDetection::clear() {
- for(int i = 0; i < _frames.size(); i++) {
- if(_frames[i]) {
- delete _frames[i];
- }
- }
-
- _frames.clear();
-}
-
-int PeakDetection::sampling_rate() {
- return _sampling_rate;
-}
-
-void PeakDetection::sampling_rate(int new_sampling_rate) {
- _sampling_rate = new_sampling_rate;
-}
-
-int PeakDetection::frame_size() {
- return _frame_size;
-}
-
-void PeakDetection::frame_size(int new_frame_size) {
- _frame_size = new_frame_size;
-}
-
-bool PeakDetection::static_frame_size() {
- return _static_frame_size;
-}
-
-void PeakDetection::static_frame_size(bool new_static_frame_size) {
- _static_frame_size = new_static_frame_size;
-}
-
-int PeakDetection::next_frame_size() {
- return _frame_size;
-}
-
-int PeakDetection::hop_size() {
- return _hop_size;
-}
-
-void PeakDetection::hop_size(int new_hop_size) {
- _hop_size = new_hop_size;
-}
-
-int PeakDetection::max_peaks() {
- return _max_peaks;
-}
-
-void PeakDetection::max_peaks(int new_max_peaks) {
- _max_peaks = new_max_peaks;
-}
-
-std::string PeakDetection::window_type() {
- return _window_type;
-}
-
-void PeakDetection::window_type(std::string new_window_type) {
- _window_type = new_window_type;
-}
-
-int PeakDetection::window_size() {
- return _window_size;
-}
-
-void PeakDetection::window_size(int new_window_size) {
- _window_size = new_window_size;
-}
-
-sample PeakDetection::min_peak_separation() {
- return _min_peak_separation;
-}
-
-void PeakDetection::min_peak_separation(sample new_min_peak_separation) {
- _min_peak_separation = new_min_peak_separation;
-}
-
-int PeakDetection::num_frames() {
- return _frames.size();
-}
-
-Frame* PeakDetection::frame(int frame_number) {
- return _frames[frame_number];
-}
-
-Frames PeakDetection::frames() {
- return _frames;
-}
-
-// Find and return all spectral peaks in a given frame of audio
-Peaks PeakDetection::find_peaks_in_frame(Frame* frame) {
- Peaks peaks;
- return peaks;
-}
-
-// Find and return all spectral peaks in a given audio signal.
-// If the signal contains more than 1 frame worth of audio, it will be broken
-// up into separate frames, each containing a std::vector of peaks.
-// Frames* PeakDetection::find_peaks(const samples& audio)
-Frames PeakDetection::find_peaks(int audio_size, sample* audio) {
- clear();
- unsigned int pos = 0;
-
- while(pos < audio_size - _hop_size) {
- // get the next frame size
- if(!_static_frame_size) {
- _frame_size = next_frame_size();
- }
-
- // get the next frame
- Frame* f = new Frame(_frame_size);
- f->audio(&audio[pos]);
-
- // find peaks
- Peaks peaks = find_peaks_in_frame(f);
- f->add_peaks(&peaks);
-
- _frames.push_back(f);
- pos += _hop_size;
- }
-
- return _frames;
-}
-
-
-// ---------------------------------------------------------------------------
-// PartialTracking
-// ---------------------------------------------------------------------------
-PartialTracking::PartialTracking() {
- _sampling_rate = 44100;
- _max_partials = 100;
- _min_partial_length = 0;
- _max_gap = 2;
-}
-
-PartialTracking::~PartialTracking() {
- clear();
-}
-
-void PartialTracking::clear() {
- _frames.clear();
-}
-
-int PartialTracking::sampling_rate() {
- return _sampling_rate;
-}
-
-void PartialTracking::sampling_rate(int new_sampling_rate) {
- _sampling_rate = new_sampling_rate;
-}
-
-int PartialTracking::max_partials() {
- return _max_partials;
-}
-
-void PartialTracking::max_partials(int new_max_partials) {
- _max_partials = new_max_partials;
-}
-
-int PartialTracking::min_partial_length() {
- return _min_partial_length;
-}
-
-void PartialTracking::min_partial_length(int new_min_partial_length) {
- _min_partial_length = new_min_partial_length;
-}
-
-int PartialTracking::max_gap() {
- return _max_gap;
-}
-
-void PartialTracking::max_gap(int new_max_gap) {
- _max_gap = new_max_gap;
-}
-
-// Streamable (real-time) partial-tracking.
-Peaks PartialTracking::update_partials(Frame* frame) {
- Peaks peaks;
- return peaks;
-}
-
-// Find partials from the sinusoidal peaks in a list of Frames.
-Frames PartialTracking::find_partials(Frames frames) {
- for(int i = 0; i < frames.size(); i++) {
- Peaks peaks = update_partials(frames[i]);
- for(int j = 0; j < peaks.size(); j++) {
- frames[i]->partial(j, peaks[j]);
- }
- }
- _frames = frames;
- return _frames;
-}
-
-
-// ---------------------------------------------------------------------------
-// Synthesis
-// ---------------------------------------------------------------------------
-Synthesis::Synthesis() {
- _frame_size = 512;
- _hop_size = 512;
- _max_partials = 100;
- _sampling_rate = 44100;
-}
-
-int Synthesis::frame_size() {
- return _frame_size;
-}
-
-void Synthesis::frame_size(int new_frame_size) {
- _frame_size = new_frame_size;
-}
-
-int Synthesis::hop_size() {
- return _hop_size;
-}
-
-void Synthesis::hop_size(int new_hop_size) {
- _hop_size = new_hop_size;
-}
-
-int Synthesis::max_partials() {
- return _max_partials;
-}
-
-void Synthesis::max_partials(int new_max_partials) {
- _max_partials = new_max_partials;
-}
-
-int Synthesis::sampling_rate() {
- return _sampling_rate;
-}
-
-void Synthesis::sampling_rate(int new_sampling_rate) {
- _sampling_rate = new_sampling_rate;
-}
-
-void Synthesis::synth_frame(Frame* frame) {
-}
-
-Frames Synthesis::synth(Frames frames) {
- for(int i = 0; i < frames.size(); i++) {
- synth_frame(frames[i]);
- }
- return frames;
-}
-
-
-// ---------------------------------------------------------------------------
-// Residual
-// ---------------------------------------------------------------------------
-Residual::Residual() {
- _frame_size = 512;
- _hop_size = 512;
- _sampling_rate = 44100;
-}
-
-int Residual::frame_size() {
- return _frame_size;
-}
-
-void Residual::frame_size(int new_frame_size) {
- _frame_size = new_frame_size;
-}
-
-int Residual::hop_size() {
- return _hop_size;
-}
-
-void Residual::hop_size(int new_hop_size) {
- _hop_size = new_hop_size;
-}
-
-int Residual::sampling_rate() {
- return _sampling_rate;
-}
-
-void Residual::sampling_rate(int new_sampling_rate) {
- _sampling_rate = new_sampling_rate;
-}
-
-void Residual::residual_frame(int synth_size, sample* synth,
- int original_size, sample* original,
- int residual_size, sample* residual) {
-}
-
-void Residual::find_residual(int synth_size, sample* synth,
- int original_size, sample* original,
- int residual_size, sample* residual) {
- for(int i = 0; i < synth_size; i += _hop_size) {
- residual_frame(_hop_size, &synth[i],
- _hop_size, &original[i],
- _hop_size, &residual[i]);
- }
-}
-
-void Residual::synth_frame(Frame* frame) {
-}
-
-// Calculate and return a synthesised residual signal
-Frames Residual::synth(Frames frames) {
- for(int i = 0; i < frames.size(); i++) {
- synth_frame(frames[i]);
- }
- return frames;
-}
diff --git a/src/simpl/base.h b/src/simpl/base.h
index bdb0d96..7589264 100644
--- a/src/simpl/base.h
+++ b/src/simpl/base.h
@@ -3,7 +3,6 @@
#include <vector>
#include <string>
-#include "exceptions.h"
using namespace std;
@@ -126,155 +125,6 @@ class Frame {
typedef std::vector<Frame*> Frames;
-
-// ---------------------------------------------------------------------------
-// PeakDetection
-//
-// Detect spectral peaks
-// ---------------------------------------------------------------------------
-
-class PeakDetection {
- private:
- int _sampling_rate;
- int _frame_size;
- bool _static_frame_size;
- int _hop_size;
- int _max_peaks;
- std::string _window_type;
- int _window_size;
- sample _min_peak_separation;
- Frames _frames;
-
- public:
- PeakDetection();
- virtual ~PeakDetection();
- void clear();
-
- int sampling_rate();
- void sampling_rate(int new_sampling_rate);
- int frame_size();
- void frame_size(int new_frame_size);
- bool static_frame_size();
- void static_frame_size(bool new_static_frame_size);
- virtual int next_frame_size();
- int hop_size();
- void hop_size(int new_hop_size);
- int max_peaks();
- void max_peaks(int new_max_peaks);
- std::string window_type();
- void window_type(std::string new_window_type);
- int window_size();
- void window_size(int new_window_size);
- sample min_peak_separation();
- void min_peak_separation(sample new_min_peak_separation);
- int num_frames();
- Frame* frame(int frame_number);
- Frames frames();
-
- // Find and return all spectral peaks in a given frame of audio
- virtual Peaks find_peaks_in_frame(Frame* frame);
-
- // Find and return all spectral peaks in a given audio signal.
- // If the signal contains more than 1 frame worth of audio, it will be broken
- // up into separate frames, with an array of peaks returned for each frame.
- virtual Frames find_peaks(int audio_size, sample* audio);
-};
-
-
-// ---------------------------------------------------------------------------
-// PartialTracking
-//
-// Link spectral peaks from consecutive frames to form partials
-// ---------------------------------------------------------------------------
-
-class PartialTracking {
- private:
- int _sampling_rate;
- int _max_partials;
- int _min_partial_length;
- int _max_gap;
- Frames _frames;
-
- public:
- PartialTracking();
- ~PartialTracking();
-
- void clear();
-
- int sampling_rate();
- void sampling_rate(int new_sampling_rate);
- int max_partials();
- void max_partials(int new_max_partials);
- int min_partial_length();
- void min_partial_length(int new_min_partial_length);
- int max_gap();
- void max_gap(int new_max_gap);
-
- virtual Peaks update_partials(Frame* frame);
- virtual Frames find_partials(Frames frames);
-};
-
-
-// ---------------------------------------------------------------------------
-// Synthesis
-//
-// Synthesise audio from spectral analysis data
-// ---------------------------------------------------------------------------
-
-class Synthesis {
- private:
- int _frame_size;
- int _hop_size;
- int _max_partials;
- int _sampling_rate;
-
- public:
- Synthesis();
- int frame_size();
- void frame_size(int new_frame_size);
- int hop_size();
- void hop_size(int new_hop_size);
- int max_partials();
- void max_partials(int new_max_partials);
- int sampling_rate();
- void sampling_rate(int new_sampling_rate);
-
- virtual void synth_frame(Frame* frame);
- virtual Frames synth(Frames frames);
-};
-
-// ---------------------------------------------------------------------------
-// Residual
-//
-// Calculate a residual signal
-// ---------------------------------------------------------------------------
-
-class Residual {
- private:
- int _frame_size;
- int _hop_size;
- int _sampling_rate;
-
- public:
- Residual();
- int frame_size();
- void frame_size(int new_frame_size);
- int hop_size();
- void hop_size(int new_hop_size);
- int sampling_rate();
- void sampling_rate(int new_sampling_rate);
-
- virtual void residual_frame(int synth_size, sample* synth,
- int original_size, sample* original,
- int residual_size, sample* residual);
- virtual void find_residual(int synth_size, sample* synth,
- int original_size, sample* original,
- int residual_size, sample* residual);
-
- virtual void synth_frame(Frame* frame);
- virtual Frames synth(Frames frames);
-};
-
} // end of namespace Simpl
#endif
diff --git a/src/simpl/exceptions.cpp b/src/simpl/exceptions.cpp
index 92b3840..3e4ae53 100644
--- a/src/simpl/exceptions.cpp
+++ b/src/simpl/exceptions.cpp
@@ -1,7 +1,7 @@
#include "exceptions.h"
#include <string>
-namespace Simpl {
+namespace simpl {
// ---------------------------------------------------------------------------
// Exception constructor
diff --git a/src/simpl/exceptions.h b/src/simpl/exceptions.h
index 90baafa..0d247b2 100644
--- a/src/simpl/exceptions.h
+++ b/src/simpl/exceptions.h
@@ -6,7 +6,7 @@
#include <stdexcept>
#include <string>
-namespace Simpl {
+namespace simpl {
// ---------------------------------------------------------------------------
// class Exception
diff --git a/src/simpl/partial_tracking.cpp b/src/simpl/partial_tracking.cpp
new file mode 100644
index 0000000..219be72
--- /dev/null
+++ b/src/simpl/partial_tracking.cpp
@@ -0,0 +1,73 @@
+#include "partial_tracking.h"
+
+using namespace std;
+using namespace simpl;
+
+
+// ---------------------------------------------------------------------------
+// PartialTracking
+// ---------------------------------------------------------------------------
+PartialTracking::PartialTracking() {
+ _sampling_rate = 44100;
+ _max_partials = 100;
+ _min_partial_length = 0;
+ _max_gap = 2;
+}
+
+PartialTracking::~PartialTracking() {
+ clear();
+}
+
+void PartialTracking::clear() {
+ _frames.clear();
+}
+
+int PartialTracking::sampling_rate() {
+ return _sampling_rate;
+}
+
+void PartialTracking::sampling_rate(int new_sampling_rate) {
+ _sampling_rate = new_sampling_rate;
+}
+
+int PartialTracking::max_partials() {
+ return _max_partials;
+}
+
+void PartialTracking::max_partials(int new_max_partials) {
+ _max_partials = new_max_partials;
+}
+
+int PartialTracking::min_partial_length() {
+ return _min_partial_length;
+}
+
+void PartialTracking::min_partial_length(int new_min_partial_length) {
+ _min_partial_length = new_min_partial_length;
+}
+
+int PartialTracking::max_gap() {
+ return _max_gap;
+}
+
+void PartialTracking::max_gap(int new_max_gap) {
+ _max_gap = new_max_gap;
+}
+
+// Streamable (real-time) partial-tracking.
+Peaks PartialTracking::update_partials(Frame* frame) {
+ Peaks peaks;
+ return peaks;
+}
+
+// Find partials from the sinusoidal peaks in a list of Frames.
+Frames PartialTracking::find_partials(Frames frames) {
+ for(int i = 0; i < frames.size(); i++) {
+ Peaks peaks = update_partials(frames[i]);
+ for(int j = 0; j < peaks.size(); j++) {
+ frames[i]->partial(j, peaks[j]);
+ }
+ }
+ _frames = frames;
+ return _frames;
+}
diff --git a/src/simpl/partial_tracking.h b/src/simpl/partial_tracking.h
new file mode 100644
index 0000000..ade5584
--- /dev/null
+++ b/src/simpl/partial_tracking.h
@@ -0,0 +1,48 @@
+#ifndef PARTIAL_TRACKING_H
+#define PARTIAL_TRACING_H
+
+#include "base.h"
+
+using namespace std;
+
+namespace simpl
+{
+
+
+// ---------------------------------------------------------------------------
+// PartialTracking
+//
+// Link spectral peaks from consecutive frames to form partials
+// ---------------------------------------------------------------------------
+
+class PartialTracking {
+ private:
+ int _sampling_rate;
+ int _max_partials;
+ int _min_partial_length;
+ int _max_gap;
+ Frames _frames;
+
+ public:
+ PartialTracking();
+ ~PartialTracking();
+
+ void clear();
+
+ int sampling_rate();
+ void sampling_rate(int new_sampling_rate);
+ int max_partials();
+ void max_partials(int new_max_partials);
+ int min_partial_length();
+ void min_partial_length(int new_min_partial_length);
+ int max_gap();
+ void max_gap(int new_max_gap);
+
+ virtual Peaks update_partials(Frame* frame);
+ virtual Frames find_partials(Frames frames);
+};
+
+
+} // end of namespace Simpl
+
+#endif
diff --git a/src/simpl/peak_detection.cpp b/src/simpl/peak_detection.cpp
new file mode 100644
index 0000000..1d44b6f
--- /dev/null
+++ b/src/simpl/peak_detection.cpp
@@ -0,0 +1,156 @@
+#include "peak_detection.h"
+
+using namespace std;
+using namespace simpl;
+
+
+// ---------------------------------------------------------------------------
+// PeakDetection
+// ---------------------------------------------------------------------------
+
+PeakDetection::PeakDetection() {
+ _sampling_rate = 44100;
+ _frame_size = 2048;
+ _static_frame_size = true;
+ _hop_size = 512;
+ _max_peaks = 100;
+ _window_type = "hamming";
+ _window_size = 2048;
+ _min_peak_separation = 1.0; // in Hz
+}
+
+PeakDetection::~PeakDetection() {
+ clear();
+}
+
+void PeakDetection::clear() {
+ for(int i = 0; i < _frames.size(); i++) {
+ if(_frames[i]) {
+ delete _frames[i];
+ }
+ }
+
+ _frames.clear();
+}
+
+int PeakDetection::sampling_rate() {
+ return _sampling_rate;
+}
+
+void PeakDetection::sampling_rate(int new_sampling_rate) {
+ _sampling_rate = new_sampling_rate;
+}
+
+int PeakDetection::frame_size() {
+ return _frame_size;
+}
+
+void PeakDetection::frame_size(int new_frame_size) {
+ _frame_size = new_frame_size;
+}
+
+bool PeakDetection::static_frame_size() {
+ return _static_frame_size;
+}
+
+void PeakDetection::static_frame_size(bool new_static_frame_size) {
+ _static_frame_size = new_static_frame_size;
+}
+
+int PeakDetection::next_frame_size() {
+ return _frame_size;
+}
+
+int PeakDetection::hop_size() {
+ return _hop_size;
+}
+
+void PeakDetection::hop_size(int new_hop_size) {
+ _hop_size = new_hop_size;
+}
+
+int PeakDetection::max_peaks() {
+ return _max_peaks;
+}
+
+void PeakDetection::max_peaks(int new_max_peaks) {
+ _max_peaks = new_max_peaks;
+}
+
+std::string PeakDetection::window_type() {
+ return _window_type;
+}
+
+void PeakDetection::window_type(std::string new_window_type) {
+ _window_type = new_window_type;
+}
+
+int PeakDetection::window_size() {
+ return _window_size;
+}
+
+void PeakDetection::window_size(int new_window_size) {
+ _window_size = new_window_size;
+}
+
+sample PeakDetection::min_peak_separation() {
+ return _min_peak_separation;
+}
+
+void PeakDetection::min_peak_separation(sample new_min_peak_separation) {
+ _min_peak_separation = new_min_peak_separation;
+}
+
+int PeakDetection::num_frames() {
+ return _frames.size();
+}
+
+Frame* PeakDetection::frame(int frame_number) {
+ return _frames[frame_number];
+}
+
+Frames PeakDetection::frames() {
+ return _frames;
+}
+
+// Find and return all spectral peaks in a given frame of audio
+Peaks PeakDetection::find_peaks_in_frame(Frame* frame) {
+ Peaks peaks;
+ return peaks;
+}
+
+// Find and return all spectral peaks in a given audio signal.
+// If the signal contains more than 1 frame worth of audio, it will be broken
+// up into separate frames, each containing a std::vector of peaks.
+// Frames* PeakDetection::find_peaks(const samples& audio)
+Frames PeakDetection::find_peaks(int audio_size, sample* audio) {
+ clear();
+ unsigned int pos = 0;
+
+ while(pos < audio_size - _hop_size) {
+ // get the next frame size
+ if(!_static_frame_size) {
+ _frame_size = next_frame_size();
+ }
+
+ // get the next frame
+ Frame* f = new Frame(_frame_size);
+ f->audio(&audio[pos]);
+
+ // find peaks
+ Peaks peaks = find_peaks_in_frame(f);
+ f->add_peaks(&peaks);
+
+ _frames.push_back(f);
+ pos += _hop_size;
+ }
+
+ return _frames;
+}
+
+
+// ---------------------------------------------------------------------------
+// SMSPeakDetection
+// ---------------------------------------------------------------------------
+SMSPeakDetection::SMSPeakDetection() {
+}
diff --git a/src/simpl/peak_detection.h b/src/simpl/peak_detection.h
new file mode 100644
index 0000000..0045762
--- /dev/null
+++ b/src/simpl/peak_detection.h
@@ -0,0 +1,77 @@
+#ifndef PEAK_DETECTION_H
+#define PEAK_DETECTION_H
+
+#include "base.h"
+
+using namespace std;
+
+namespace simpl
+{
+
+
+// ---------------------------------------------------------------------------
+// PeakDetection
+//
+// Detect spectral peaks
+// ---------------------------------------------------------------------------
+
+class PeakDetection {
+ private:
+ int _sampling_rate;
+ int _frame_size;
+ bool _static_frame_size;
+ int _hop_size;
+ int _max_peaks;
+ std::string _window_type;
+ int _window_size;
+ sample _min_peak_separation;
+ Frames _frames;
+
+ public:
+ PeakDetection();
+ virtual ~PeakDetection();
+ void clear();
+
+ int sampling_rate();
+ void sampling_rate(int new_sampling_rate);
+ int frame_size();
+ void frame_size(int new_frame_size);
+ bool static_frame_size();
+ void static_frame_size(bool new_static_frame_size);
+ virtual int next_frame_size();
+ int hop_size();
+ void hop_size(int new_hop_size);
+ int max_peaks();
+ void max_peaks(int new_max_peaks);
+ std::string window_type();
+ void window_type(std::string new_window_type);
+ int window_size();
+ void window_size(int new_window_size);
+ sample min_peak_separation();
+ void min_peak_separation(sample new_min_peak_separation);
+ int num_frames();
+ Frame* frame(int frame_number);
+ Frames frames();
+
+ // Find and return all spectral peaks in a given frame of audio
+ virtual Peaks find_peaks_in_frame(Frame* frame);
+
+ // Find and return all spectral peaks in a given audio signal.
+ // If the signal contains more than 1 frame worth of audio, it will be broken
+ // up into separate frames, with an array of peaks returned for each frame.
+ virtual Frames find_peaks(int audio_size, sample* audio);
+};
+
+
+// ---------------------------------------------------------------------------
+// SMSPeakDetection
+// ---------------------------------------------------------------------------
+class SMSPeakDetection : public PeakDetection {
+ public:
+ SMSPeakDetection();
+};
+
+
+} // end of namespace Simpl
+
+#endif
diff --git a/src/simpl/residual.cpp b/src/simpl/residual.cpp
new file mode 100644
index 0000000..a6ed226
--- /dev/null
+++ b/src/simpl/residual.cpp
@@ -0,0 +1,64 @@
+#include "residual.h"
+
+using namespace std;
+using namespace simpl;
+
+
+// ---------------------------------------------------------------------------
+// Residual
+// ---------------------------------------------------------------------------
+Residual::Residual() {
+ _frame_size = 512;
+ _hop_size = 512;
+ _sampling_rate = 44100;
+}
+
+int Residual::frame_size() {
+ return _frame_size;
+}
+
+void Residual::frame_size(int new_frame_size) {
+ _frame_size = new_frame_size;
+}
+
+int Residual::hop_size() {
+ return _hop_size;
+}
+
+void Residual::hop_size(int new_hop_size) {
+ _hop_size = new_hop_size;
+}
+
+int Residual::sampling_rate() {
+ return _sampling_rate;
+}
+
+void Residual::sampling_rate(int new_sampling_rate) {
+ _sampling_rate = new_sampling_rate;
+}
+
+void Residual::residual_frame(int synth_size, sample* synth,
+ int original_size, sample* original,
+ int residual_size, sample* residual) {
+}
+
+void Residual::find_residual(int synth_size, sample* synth,
+ int original_size, sample* original,
+ int residual_size, sample* residual) {
+ for(int i = 0; i < synth_size; i += _hop_size) {
+ residual_frame(_hop_size, &synth[i],
+ _hop_size, &original[i],
+ _hop_size, &residual[i]);
+ }
+}
+
+void Residual::synth_frame(Frame* frame) {
+}
+
+// Calculate and return a synthesised residual signal
+Frames Residual::synth(Frames frames) {
+ for(int i = 0; i < frames.size(); i++) {
+ synth_frame(frames[i]);
+ }
+ return frames;
+}
diff --git a/src/simpl/residual.h b/src/simpl/residual.h
new file mode 100644
index 0000000..5dd53f5
--- /dev/null
+++ b/src/simpl/residual.h
@@ -0,0 +1,47 @@
+#ifndef RESIDUAL_H
+#define RESIDUAL_H
+
+#include "base.h"
+
+using namespace std;
+
+namespace simpl
+{
+
+
+// ---------------------------------------------------------------------------
+// Residual
+//
+// Calculate a residual signal
+// ---------------------------------------------------------------------------
+
+class Residual {
+ private:
+ int _frame_size;
+ int _hop_size;
+ int _sampling_rate;
+
+ public:
+ Residual();
+ int frame_size();
+ void frame_size(int new_frame_size);
+ int hop_size();
+ void hop_size(int new_hop_size);
+ int sampling_rate();
+ void sampling_rate(int new_sampling_rate);
+
+ virtual void residual_frame(int synth_size, sample* synth,
+ int original_size, sample* original,
+ int residual_size, sample* residual);
+ virtual void find_residual(int synth_size, sample* synth,
+ int original_size, sample* original,
+ int residual_size, sample* residual);
+
+ virtual void synth_frame(Frame* frame);
+ virtual Frames synth(Frames frames);
+};
+
+
+} // end of namespace Simpl
+
+#endif
diff --git a/src/simpl/simplsms.cpp b/src/simpl/simplsms.cpp
new file mode 100644
index 0000000..108a828
--- /dev/null
+++ b/src/simpl/simplsms.cpp
@@ -0,0 +1,9 @@
+#include "simplsms.h"
+
+using namespace simpl;
+
+// ---------------------------------------------------------------------------
+// SMSPeakDetection
+// ---------------------------------------------------------------------------
+SMSPeakDetection::SMSPeakDetection() {
+}
diff --git a/src/simpl/simplsms.h b/src/simpl/simplsms.h
new file mode 100644
index 0000000..f7d6c27
--- /dev/null
+++ b/src/simpl/simplsms.h
@@ -0,0 +1,17 @@
+#ifndef SIMPLSMS_H
+#define SIMPLSMS_H
+
+#include <vector>
+#include "base.h"
+
+namespace simpl
+{
+
+class SMSPeakDetection : public PeakDetection {
+ public:
+ SMSPeakDetection();
+};
+
+} // end of namespace Simpl
+
+#endif
diff --git a/src/simpl/synthesis.cpp b/src/simpl/synthesis.cpp
new file mode 100644
index 0000000..168749b
--- /dev/null
+++ b/src/simpl/synthesis.cpp
@@ -0,0 +1,57 @@
+#include "synthesis.h"
+
+using namespace std;
+using namespace simpl;
+
+
+// ---------------------------------------------------------------------------
+// Synthesis
+// ---------------------------------------------------------------------------
+Synthesis::Synthesis() {
+ _frame_size = 512;
+ _hop_size = 512;
+ _max_partials = 100;
+ _sampling_rate = 44100;
+}
+
+int Synthesis::frame_size() {
+ return _frame_size;
+}
+
+void Synthesis::frame_size(int new_frame_size) {
+ _frame_size = new_frame_size;
+}
+
+int Synthesis::hop_size() {
+ return _hop_size;
+}
+
+void Synthesis::hop_size(int new_hop_size) {
+ _hop_size = new_hop_size;
+}
+
+int Synthesis::max_partials() {
+ return _max_partials;
+}
+
+void Synthesis::max_partials(int new_max_partials) {
+ _max_partials = new_max_partials;
+}
+
+int Synthesis::sampling_rate() {
+ return _sampling_rate;
+}
+
+void Synthesis::sampling_rate(int new_sampling_rate) {
+ _sampling_rate = new_sampling_rate;
+}
+
+void Synthesis::synth_frame(Frame* frame) {
+}
+
+Frames Synthesis::synth(Frames frames) {
+ for(int i = 0; i < frames.size(); i++) {
+ synth_frame(frames[i]);
+ }
+ return frames;
+}
diff --git a/src/simpl/synthesis.h b/src/simpl/synthesis.h
new file mode 100644
index 0000000..43b45d0
--- /dev/null
+++ b/src/simpl/synthesis.h
@@ -0,0 +1,43 @@
+#ifndef SYNTHESIS_H
+#define SYNTHESIS_H
+
+#include "base.h"
+
+using namespace std;
+
+namespace simpl
+{
+
+
+// ---------------------------------------------------------------------------
+// Synthesis
+//
+// Synthesise audio from spectral analysis data
+// ---------------------------------------------------------------------------
+
+class Synthesis {
+ private:
+ int _frame_size;
+ int _hop_size;
+ int _max_partials;
+ int _sampling_rate;
+
+ public:
+ Synthesis();
+ int frame_size();
+ void frame_size(int new_frame_size);
+ int hop_size();
+ void hop_size(int new_hop_size);
+ int max_partials();
+ void max_partials(int new_max_partials);
+ int sampling_rate();
+ void sampling_rate(int new_sampling_rate);
+
+ virtual void synth_frame(Frame* frame);
+ virtual Frames synth(Frames frames);
+};
+
+
+} // end of namespace Simpl
+
+#endif