summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/simpl/synthesis.cpp53
-rw-r--r--src/simpl/synthesis.h23
2 files changed, 75 insertions, 1 deletions
diff --git a/src/simpl/synthesis.cpp b/src/simpl/synthesis.cpp
index 25312cc..5784522 100644
--- a/src/simpl/synthesis.cpp
+++ b/src/simpl/synthesis.cpp
@@ -254,7 +254,58 @@ void SndObjSynthesis::synth_frame(Frame* frame) {
_synth->DoProcess();
- for(int i = 0; i < _hop_size; i++) {
+ for(int i = 0; i < _frame_size; i++) {
frame->synth()[i] = _synth->Output(i);
}
}
+
+
+// ---------------------------------------------------------------------------
+// LorisSynthesis
+// ---------------------------------------------------------------------------
+LorisSynthesis::LorisSynthesis() {
+ _bandwidth = 1.0;
+ reset();
+}
+
+LorisSynthesis::~LorisSynthesis() {
+}
+
+void LorisSynthesis::reset() {
+ _oscs.clear();
+ _oscs.resize(_max_partials);
+ for(int i = 0; i < _max_partials; i++) {
+ _oscs.push_back(Loris::Oscillator());
+ }
+}
+
+void LorisSynthesis::max_partials(int new_max_partials) {
+ _max_partials = new_max_partials;
+ reset();
+}
+
+sample LorisSynthesis::bandwidth() {
+ return _bandwidth;
+}
+
+void LorisSynthesis::bandwidth(sample new_bandwidth) {
+ _bandwidth = new_bandwidth;
+}
+
+void LorisSynthesis::synth_frame(Frame* frame) {
+ int num_partials = frame->num_partials();
+ if(num_partials > _max_partials) {
+ num_partials = _max_partials;
+ }
+
+ for(int i = 0; i < num_partials; i++) {
+ Loris::Breakpoint bp = Loris::Breakpoint(
+ frame->partial(i)->frequency,
+ frame->partial(i)->amplitude,
+ frame->partial(i)->bandwidth * _bandwidth,
+ frame->partial(i)->phase
+ );
+ _oscs[i].oscillate(frame->synth(), frame->synth() + _hop_size,
+ bp, _sampling_rate);
+ }
+}
diff --git a/src/simpl/synthesis.h b/src/simpl/synthesis.h
index 456b4e4..e93669f 100644
--- a/src/simpl/synthesis.h
+++ b/src/simpl/synthesis.h
@@ -12,6 +12,9 @@ extern "C" {
#include "SinAnal.h"
#include "AdSyn.h"
+#include "Breakpoint.h"
+#include "Oscillator.h"
+
using namespace std;
namespace simpl
@@ -92,11 +95,31 @@ class SndObjSynthesis : public Synthesis {
public:
SndObjSynthesis();
~SndObjSynthesis();
+ void frame_size(int new_frame_size);
void hop_size(int new_hop_size);
void max_partials(int new_max_partials);
void synth_frame(Frame* frame);
};
+
+// ---------------------------------------------------------------------------
+// LorisSynthesis
+// ---------------------------------------------------------------------------
+class LorisSynthesis : public Synthesis {
+ private:
+ std::vector<Loris::Oscillator> _oscs;
+ sample _bandwidth;
+ void reset();
+
+ public:
+ LorisSynthesis();
+ ~LorisSynthesis();
+ void max_partials(int new_max_partials);
+ sample bandwidth();
+ void bandwidth(sample new_bandwidth);
+ void synth_frame(Frame* frame);
+};
+
} // end of namespace Simpl
#endif