summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Glover <j@johnglover.net>2012-08-11 15:47:18 +0100
committerJohn Glover <j@johnglover.net>2012-08-11 15:47:18 +0100
commit8a164a8b45c7c974b9abe98036f92aa76096c186 (patch)
treeb0ffda3b435b2358688cdc425996747cff262bdb /src
parent56f9ee6640baea33f2f2faf5aa844a55950429f9 (diff)
downloadsimpl-8a164a8b45c7c974b9abe98036f92aa76096c186.tar.gz
simpl-8a164a8b45c7c974b9abe98036f92aa76096c186.tar.bz2
simpl-8a164a8b45c7c974b9abe98036f92aa76096c186.zip
[base, synthesis] Allow synth size to be independent from frame size. Call synth_frame from Cython Synthesis.synth
so that derived classes synth_frame methods are called.
Diffstat (limited to 'src')
-rw-r--r--src/simpl/base.cpp27
-rw-r--r--src/simpl/base.h3
2 files changed, 24 insertions, 6 deletions
diff --git a/src/simpl/base.cpp b/src/simpl/base.cpp
index e3da251..c3c8ea5 100644
--- a/src/simpl/base.cpp
+++ b/src/simpl/base.cpp
@@ -81,12 +81,14 @@ Peak* Partial::peak(int peak_number) {
// ---------------------------------------------------------------------------
Frame::Frame() {
_size = 512;
+ _synth_size = 512;
_alloc_memory = false;
init();
}
Frame::Frame(int frame_size, bool alloc_memory) {
_size = frame_size;
+ _synth_size = 512;
_alloc_memory = alloc_memory;
init();
@@ -119,14 +121,14 @@ void Frame::init() {
void Frame::create_arrays() {
_audio = new sample[_size];
- _synth = new sample[_size];
+ _synth = new sample[_synth_size];
_residual = new sample[_size];
- _synth_residual = new sample[_size];
+ _synth_residual = new sample[_synth_size];
memset(_audio, 0.0, sizeof(sample) * _size);
- memset(_synth, 0.0, sizeof(sample) * _size);
+ memset(_synth, 0.0, sizeof(sample) * _synth_size);
memset(_residual, 0.0, sizeof(sample) * _size);
- memset(_synth_residual, 0.0, sizeof(sample) * _size);
+ memset(_synth_residual, 0.0, sizeof(sample) * _synth_size);
}
void Frame::destroy_arrays() {
@@ -235,6 +237,19 @@ void Frame::size(int new_size) {
}
}
+int Frame::synth_size() {
+ return _synth_size;
+}
+
+void Frame::synth_size(int new_size) {
+ _synth_size = new_size;
+
+ if(_alloc_memory) {
+ destroy_arrays();
+ create_arrays();
+ }
+}
+
void Frame::audio(sample* new_audio) {
if(_alloc_memory) {
memcpy(_audio, new_audio, sizeof(sample) * _size);
@@ -250,7 +265,7 @@ sample* Frame::audio() {
void Frame::synth(sample* new_synth) {
if(_alloc_memory) {
- memcpy(_synth, new_synth, sizeof(sample) * _size);
+ memcpy(_synth, new_synth, sizeof(sample) * _synth_size);
}
else {
_synth = new_synth;
@@ -276,7 +291,7 @@ sample* Frame::residual() {
void Frame::synth_residual(sample* new_synth_residual) {
if(_alloc_memory) {
- memcpy(_synth_residual, new_synth_residual, sizeof(sample) * _size);
+ memcpy(_synth_residual, new_synth_residual, sizeof(sample) * _synth_size);
}
else {
_synth_residual = new_synth_residual;
diff --git a/src/simpl/base.h b/src/simpl/base.h
index 7c19f77..bedd7e2 100644
--- a/src/simpl/base.h
+++ b/src/simpl/base.h
@@ -79,6 +79,7 @@ typedef std::vector<Partial*> Partials;
class Frame {
private:
int _size;
+ int _synth_size;
int _max_peaks;
int _num_peaks;
int _max_partials;
@@ -121,6 +122,8 @@ class Frame {
// audio buffers
int size();
void size(int new_size);
+ int synth_size();
+ void synth_size(int new_size);
void audio(sample* new_audio);
sample* audio();
void synth(sample* new_synth);