summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@thinkpad.(none)>2010-12-29 18:22:32 +0100
committerFlorian Jung <flo@thinkpad.(none)>2010-12-29 18:31:58 +0100
commitcc5d2c7475004c67a709ade241d86f9951749174 (patch)
tree1fa9116303bda2c79e297a6dd5a387b721c98503
parent7113f02ae87482211aec5046f9ac46c3cc9ad017 (diff)
Define an interface and a skeleton for class Note
-rw-r--r--synth/TODO1
-rw-r--r--synth/note_skel.cpp82
-rw-r--r--synth/note_skel.h54
3 files changed, 137 insertions, 0 deletions
diff --git a/synth/TODO b/synth/TODO
index d507df0..d5f5534 100644
--- a/synth/TODO
+++ b/synth/TODO
@@ -1,5 +1,6 @@
TODO für den synth
o notes compilieren und als .so-datei laden
+ o programme on-the-fly (um)laden
o RAM aufräumen?
diff --git a/synth/note_skel.cpp b/synth/note_skel.cpp
new file mode 100644
index 0000000..acc580f
--- /dev/null
+++ b/synth/note_skel.cpp
@@ -0,0 +1,82 @@
+#include <cmath>
+
+#include "note_skel.h"
+#include "globals.h"
+#include "defines.h"
+
+using namespace std;
+
+Note::Note(int n, float v, program_t &prg, jack_nframes_t pf, fixed_t pb, int prg_no)
+{
+ curr_prg=&prg;
+
+ portamento_frames=0;
+ set_portamento_frames(pf);
+
+ set_note(n);
+ freq=dest_freq;
+ set_vel(v);
+ do_ksl();
+
+ pitchbend=pb;
+
+ program=prg_no;
+}
+
+void NoteSkel::set_pitchbend(fixed_t pb)
+{
+ pitchbend=pb;
+}
+
+void NoteSkel::set_freq(float f)
+{
+ old_freq=freq;
+ dest_freq=f*ONE;
+ portamento_t=0;
+
+ do_ksr();
+}
+
+void NoteSkel::set_freq(float f, bool do_port)
+{
+ set_freq(f);
+
+ if (!do_port)
+ old_freq=dest_freq;
+}
+
+void NoteSkel::set_note(int n)
+{
+ note=n;
+ set_freq(440.0*pow(2.0,(float)(n-69)/12.0));
+}
+
+void NoteSkel::set_note(int n, bool do_port)
+{
+ note=n;
+ set_freq(440.0*pow(2.0,(float)(n-69)/12.0), do_port);
+}
+
+int NoteSkel::get_note()
+{
+ return note;
+}
+
+void NoteSkel::set_vel(float v)
+{
+ vel=v*ONE;
+
+ recalc_factors();
+ apply_pfactor();
+}
+
+void NoteSkel::set_portamento_frames(jack_nframes_t t)
+{
+ portamento_frames=t;
+ portamento_t=0;
+}
+
+int NoteSkel::get_program()
+{
+ return program;
+}
diff --git a/synth/note_skel.h b/synth/note_skel.h
new file mode 100644
index 0000000..b36d28c
--- /dev/null
+++ b/synth/note_skel.h
@@ -0,0 +1,54 @@
+#ifndef __NOTE_SKEL_H__
+#define __NOTE_SKEL_H__
+
+#include <jack/jack.h>
+
+#include "programs.h"
+#include "fixed.h"
+
+class NoteSkel
+{
+ public:
+ NoteSkel(int n, float v,program_t &prg, jack_nframes_t pf, fixed_t pb, int prg_no);
+ virtual ~NoteSkel()=0;
+ virtual fixed_t get_sample()=0;
+
+ int get_program();
+ int get_note();
+ void set_note(int n);
+ void set_note(int n, bool do_port);
+ void set_freq(float f);
+ void set_freq(float f, bool do_port);
+ void set_pitchbend(fixed_t pb);
+ void set_vel(float v);
+ void set_portamento_frames(jack_nframes_t f);
+
+ virtual void release_quickly(jack_nframes_t maxt)=0;
+ virtual void release()=0;
+ virtual void reattack()=0;
+ virtual bool still_active()=0;
+
+ virtual void set_param(const parameter_t &p, fixed_t v)=0;
+
+ private:
+ virtual void do_ksl()=0;
+ virtual void do_ksr()=0;
+
+ virtual void recalc_factors()=0;
+ virtual void apply_pfactor()=0;
+
+ fixed_t freq, dest_freq, old_freq;
+ fixed_t vel;
+ jack_nframes_t portamento_t, portamento_frames;
+
+ pfactor_value_t pfactor;
+
+ int note;
+ int program;
+ program_t *curr_prg;
+
+ fixed_t pitchbend;
+};
+
+
+#endif