summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@thinkpad.(none)>2010-12-30 16:23:59 +0100
committerFlorian Jung <flo@thinkpad.(none)>2010-12-30 16:23:59 +0100
commitbe11f60acfc7a9283ab038b4a1cd25e5e6882cc7 (patch)
tree27be6437871cc09170225ad94bd4637ac0d6dca6
parentcc5d2c7475004c67a709ade241d86f9951749174 (diff)
Note inherits from NoteSkel -- DOES NOT WORK!
The program compiles well, but as soon as a note is created, it exits, because a pure virtual method is called in NoteSkel's ctor (which is called before Note's ctor) which tries to call a function which is implemented in Note, but not in NoteSkel
-rw-r--r--synth/Makefile2
-rw-r--r--synth/jack.cpp2
-rw-r--r--synth/note.cpp64
-rw-r--r--synth/note.h13
-rw-r--r--synth/note_skel.cpp8
-rw-r--r--synth/note_skel.h2
6 files changed, 13 insertions, 78 deletions
diff --git a/synth/Makefile b/synth/Makefile
index 3870262..791e62a 100644
--- a/synth/Makefile
+++ b/synth/Makefile
@@ -2,7 +2,7 @@ CXX=g++
CXXFLAGS=-Wall -g
LDFLAGS=-lm `pkg-config --cflags --libs jack`
-OBJ=channel.o cli.o defines.o envelope.o filter.o globals.o jack.o load.o main.o note.o parser.o programs.o readwave.o util.o
+OBJ=channel.o cli.o defines.o envelope.o filter.o globals.o jack.o load.o main.o note.o note_skel.o parser.o programs.o readwave.o util.o
BIN=synth
DEPENDFILE = .depend
diff --git a/synth/jack.cpp b/synth/jack.cpp
index 093e9b5..1c434f9 100644
--- a/synth/jack.cpp
+++ b/synth/jack.cpp
@@ -12,7 +12,7 @@
using namespace std;
-//#define DO_DEBUGGING_EVENTS
+#define DO_DEBUGGING_EVENTS
jack_port_t *midi_in;
jack_port_t *out_port[N_CHANNELS];
diff --git a/synth/note.cpp b/synth/note.cpp
index 87f1806..6b73fbf 100644
--- a/synth/note.cpp
+++ b/synth/note.cpp
@@ -16,9 +16,8 @@ inline fixed_t init_custom_osc_phase(int len, fixed_t sr)
Note::Note(int n, float v, program_t &prg, jack_nframes_t pf, fixed_t pb, int prg_no)
+ : NoteSkel(n,v,prg,pf,pb,prg_no)
{
- curr_prg=&prg;
-
n_oscillators=prg.n_osc;
@@ -61,17 +60,8 @@ Note::Note(int n, float v, program_t &prg, jack_nframes_t pf, fixed_t pb, int pr
}
- portamento_frames=0;
- set_portamento_frames(pf);
-
- set_note(n);
- freq=dest_freq;
- set_vel(v);
do_ksl();
- pitchbend=pb;
-
- program=prg_no;
filter_params=prg.filter_settings;
orig.filter_params=prg.filter_settings;
@@ -260,52 +250,6 @@ void Note::reattack()
envelope[i]->reattack();
}
-void Note::set_pitchbend(fixed_t pb)
-{
- pitchbend=pb;
-}
-
-void Note::set_freq(float f)
-{
- old_freq=freq;
- dest_freq=f*ONE;
- portamento_t=0;
-
- do_ksr();
-}
-
-void Note::set_freq(float f, bool do_port)
-{
- set_freq(f);
-
- if (!do_port)
- old_freq=dest_freq;
-}
-
-void Note::set_note(int n)
-{
- note=n;
- set_freq(440.0*pow(2.0,(float)(n-69)/12.0));
-}
-
-void Note::set_note(int n, bool do_port)
-{
- note=n;
- set_freq(440.0*pow(2.0,(float)(n-69)/12.0), do_port);
-}
-
-int Note::get_note()
-{
- return note;
-}
-
-void Note::set_vel(float v)
-{
- vel=v*ONE;
-
- recalc_factors();
- apply_pfactor();
-}
void Note::do_ksl()
{ //osc.ksl is in Bel/octave (i.e. dB/10)
@@ -326,12 +270,6 @@ void Note::do_ksr()
envelope[i]->set_ratefactor(1.0 / pow(freq>>SCALE, oscillator[i].ksr));
}
-void Note::set_portamento_frames(jack_nframes_t t)
-{
- portamento_frames=t;
- portamento_t=0;
-}
-
fixed_t Note::get_sample()
{
if (freq!=dest_freq)
diff --git a/synth/note.h b/synth/note.h
index 5035bd2..9e3bc52 100644
--- a/synth/note.h
+++ b/synth/note.h
@@ -7,27 +7,20 @@
#include "envelope.h"
#include "fixed.h"
#include "filter.h"
+#include "note_skel.h"
-class Note
+class Note : public NoteSkel
{
public:
Note(int n, float v,program_t &prg, jack_nframes_t pf, fixed_t pb, int prg_no);
~Note();
fixed_t get_sample();
- 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);
+
void release_quickly(jack_nframes_t maxt);
void release();
void reattack();
bool still_active();
void set_param(const parameter_t &p, fixed_t v);
- int get_program(){return program;}
private:
void do_ksl();
diff --git a/synth/note_skel.cpp b/synth/note_skel.cpp
index acc580f..9523a1b 100644
--- a/synth/note_skel.cpp
+++ b/synth/note_skel.cpp
@@ -6,7 +6,7 @@
using namespace std;
-Note::Note(int n, float v, program_t &prg, jack_nframes_t pf, fixed_t pb, int prg_no)
+NoteSkel::NoteSkel(int n, float v, program_t &prg, jack_nframes_t pf, fixed_t pb, int prg_no)
{
curr_prg=&prg;
@@ -16,13 +16,17 @@ Note::Note(int n, float v, program_t &prg, jack_nframes_t pf, fixed_t pb, int pr
set_note(n);
freq=dest_freq;
set_vel(v);
- do_ksl();
pitchbend=pb;
program=prg_no;
}
+NoteSkel::~NoteSkel()
+{
+
+}
+
void NoteSkel::set_pitchbend(fixed_t pb)
{
pitchbend=pb;
diff --git a/synth/note_skel.h b/synth/note_skel.h
index b36d28c..75cdc8f 100644
--- a/synth/note_skel.h
+++ b/synth/note_skel.h
@@ -10,7 +10,7 @@ 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 ~NoteSkel();
virtual fixed_t get_sample()=0;
int get_program();