diff options
Diffstat (limited to 'synth')
-rw-r--r-- | synth/Makefile | 2 | ||||
-rw-r--r-- | synth/channel.cpp | 21 | ||||
-rw-r--r-- | synth/channel.h | 3 | ||||
-rw-r--r-- | synth/jack.cpp | 2 | ||||
-rw-r--r-- | synth/note.cpp | 8 | ||||
-rw-r--r-- | synth/note.h | 2 | ||||
-rw-r--r-- | synth/note_funcs.h | 2 | ||||
-rw-r--r-- | synth/note_skel.cpp | 9 | ||||
-rw-r--r-- | synth/note_skel.h | 2 |
9 files changed, 38 insertions, 13 deletions
diff --git a/synth/Makefile b/synth/Makefile index c1d6dab..864c0a7 100644 --- a/synth/Makefile +++ b/synth/Makefile @@ -1,5 +1,5 @@ CXX=g++ -CFLAGS=-Wall -O2 +CFLAGS=-Wall -g CXXFLAGS=$(CFLAGS) LDFLAGS=-lm `pkg-config --cflags --libs jack` diff --git a/synth/channel.cpp b/synth/channel.cpp index 0042162..fe28e7d 100644 --- a/synth/channel.cpp +++ b/synth/channel.cpp @@ -28,6 +28,7 @@ Channel::Channel() sostenuto_keys.clear(); hold_pedal_pressed=false; legato_pedal_pressed=false; + curr_vol_factor=1.0; } Channel::~Channel() @@ -117,12 +118,14 @@ void Channel::note_on(int note, int vel) newnote = new Note(note,(float)vel/128.0, curr_prg, portamento_frames, pitchbend, - program); + program, + curr_vol_factor); else newnote = curr_prg.create_func(note,(float)vel/128.0, curr_prg, portamento_frames, pitchbend, - program); + program, + curr_vol_factor); notes.push_back(newnote); } @@ -132,6 +135,7 @@ void Channel::note_on(int note, int vel) n->set_note(note,n->still_active()); n->set_vel((float)vel/128.0); if ((legato_pedal_pressed==false) || !n->still_active()) n->reattack(); + n->set_vol_factor(curr_vol_factor); //no need to push back. would become #1 instead of #1 } } @@ -145,6 +149,7 @@ void Channel::note_on(int note, int vel) neednewnote=false; (*it)->reattack(); (*it)->set_vel((float)vel/128.0); + (*it)->set_vol_factor(curr_vol_factor); notes.push_back(*it); //reorder notes notes.erase(it); break; @@ -157,12 +162,14 @@ void Channel::note_on(int note, int vel) newnote = new Note(note,(float)vel/128.0, curr_prg, portamento_frames, pitchbend, - program); + program, + curr_vol_factor); else newnote = curr_prg.create_func(note,(float)vel/128.0, curr_prg, portamento_frames, pitchbend, - program); + program, + curr_vol_factor); notes.push_back(newnote); } @@ -223,6 +230,7 @@ void Channel::set_controller(int con,int val) case 65: set_portamento(val); break; case 64: set_hold_pedal(val>=64); break; case 66: set_sostenuto_pedal(val>=64); break; + case 67: set_soft_pedal(val>=64); break; case 68: set_legato_pedal(val>=64); break; case 119: set_quick_release(val); case 120: panic(); break; @@ -394,6 +402,11 @@ void Channel::set_legato_pedal(bool newstate) { legato_pedal_pressed=newstate; } + +void Channel::set_soft_pedal(bool newstate) +{ + curr_vol_factor = (newstate==false) ? 1.0 : 0.5; //TODO richtigen wert! +} void Channel::panic() { diff --git a/synth/channel.h b/synth/channel.h index b0a855a..9727ab8 100644 --- a/synth/channel.h +++ b/synth/channel.h @@ -40,6 +40,7 @@ class Channel void set_hold_pedal(bool newstate); void set_sostenuto_pedal(bool newstate); void set_legato_pedal(bool newstate); + void set_soft_pedal(bool newstate); float balL, balR; private: @@ -71,6 +72,8 @@ class Channel set<int> sostenuto_keys; bool legato_pedal_pressed; + + float curr_vol_factor; }; #endif diff --git a/synth/jack.cpp b/synth/jack.cpp index 3949722..0c98855 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 b6bfa22..91291d7 100644 --- a/synth/note.cpp +++ b/synth/note.cpp @@ -14,12 +14,9 @@ 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) +Note::Note(int n, float v, program_t &prg, jack_nframes_t pf, fixed_t pb, int prg_no, float vol_fac) { - curr_prg=&prg; - - n_oscillators=prg.n_osc; @@ -92,6 +89,7 @@ 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); + set_vol_factor(vol_fac); pitchbend=pb; @@ -132,7 +130,7 @@ void Note::recalc_factors() for (int i=0;i<n_oscillators;i++) { - pfactor.out[i]=calc_pfactor(curr_prg->pfactor.out[i], vel); + pfactor.out[i]=calc_pfactor(curr_prg->pfactor.out[i], vel) * volume_factor; for (int j=0;j<n_oscillators;j++) pfactor.fm[i][j]=calc_pfactor(curr_prg->pfactor.fm[i][j], vel); diff --git a/synth/note.h b/synth/note.h index 03a7180..cc043e6 100644 --- a/synth/note.h +++ b/synth/note.h @@ -12,7 +12,7 @@ class Note : public NoteSkel { public: - Note(int n, float v,program_t &prg, jack_nframes_t pf, fixed_t pb, int prg_no); + Note(int n, float v,program_t &prg, jack_nframes_t pf, fixed_t pb, int prg_no, float vol_fac); ~Note(); fixed_t get_sample(); diff --git a/synth/note_funcs.h b/synth/note_funcs.h index 2a9d3c0..08ea7f9 100644 --- a/synth/note_funcs.h +++ b/synth/note_funcs.h @@ -14,7 +14,7 @@ struct program_t; typedef void output_note_func_t(string s); typedef string IntToStr_func_t(int i); -typedef NoteSkel* create_func_t (int, float, program_t&, jack_nframes_t, fixed_t, int); +typedef NoteSkel* create_func_t (int, float, program_t&, jack_nframes_t, fixed_t, int, float); typedef void init_func_t(int sr, int fupfr, fixed_t **w, fixed_t **clfo, output_note_func_t* out_n, IntToStr_func_t* its); #endif diff --git a/synth/note_skel.cpp b/synth/note_skel.cpp index b028ca4..988f994 100644 --- a/synth/note_skel.cpp +++ b/synth/note_skel.cpp @@ -62,6 +62,14 @@ void NoteSkel::set_vel(float v) apply_pfactor(); } +void NoteSkel::set_vol_factor(float vol_fac) +{ + volume_factor=vol_fac; + + recalc_factors(); + apply_pfactor(); +} + void NoteSkel::set_portamento_frames(jack_nframes_t t) { portamento_frames=t; @@ -72,3 +80,4 @@ int NoteSkel::get_program() { return program; } + diff --git a/synth/note_skel.h b/synth/note_skel.h index 6aebb8b..1afbe3a 100644 --- a/synth/note_skel.h +++ b/synth/note_skel.h @@ -21,6 +21,7 @@ class NoteSkel void set_freq(float f, bool do_port); void set_pitchbend(fixed_t pb); void set_vel(float v); + void set_vol_factor(float vol_fac); void set_portamento_frames(jack_nframes_t f); virtual void release_quickly(jack_nframes_t maxt)=0; @@ -44,6 +45,7 @@ class NoteSkel jack_nframes_t portamento_t, portamento_frames; pfactor_value_t pfactor; + float volume_factor; int note; int program; |