From e78131ccbbcb81da94e5992f788c6ea291a2050d Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Thu, 6 Jan 2011 20:16:19 +0100 Subject: The synthesizer can now load the compiled notes There are still issues: - filtertest.prog.so: output_note-message which is not true - huge size of the .so (48K are too much!) --- synth/channel.cpp | 50 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) (limited to 'synth/channel.cpp') diff --git a/synth/channel.cpp b/synth/channel.cpp index ddad9fe..d70b199 100644 --- a/synth/channel.cpp +++ b/synth/channel.cpp @@ -5,6 +5,8 @@ #include "note.h" +#include "note_funcs.h" + Channel::Channel() { @@ -34,7 +36,7 @@ void Channel::cleanup() for (it=notes.begin(); it!=notes.end(); it++) if ((*it)->still_active()==false) { - delete *it; + (*it)->destroy(); it=notes.erase(it); } } @@ -86,15 +88,22 @@ void Channel::note_on(int note, int vel) { //if the program has changed, kill the previous note and //create a new one - delete n; + n->destroy(); notes.clear(); - notes.push_back( new Note(note,(float)vel/128.0, - curr_prg, - portamento_frames, - pitchbend, - program) ); - + NoteSkel *newnote=NULL; + if (curr_prg.create_func==NULL) + newnote = new Note(note,(float)vel/128.0, + curr_prg, + portamento_frames, pitchbend, + program); + else + newnote = curr_prg.create_func(note,(float)vel/128.0, + curr_prg, + portamento_frames, pitchbend, + program); + + notes.push_back(newnote); } else //program did not change { @@ -122,11 +131,22 @@ void Channel::note_on(int note, int vel) } } if (neednewnote) - notes.push_back( new Note(note,(float)vel/128.0, - curr_prg, - portamento_frames, - pitchbend, - program) ); + { + NoteSkel *newnote=NULL; + if (curr_prg.create_func==NULL) + newnote = new Note(note,(float)vel/128.0, + curr_prg, + portamento_frames, pitchbend, + program); + else + newnote = curr_prg.create_func(note,(float)vel/128.0, + curr_prg, + portamento_frames, pitchbend, + program); + + notes.push_back(newnote); + } + apply_voice_limit(); } } @@ -167,7 +187,7 @@ void Channel::apply_voice_limit() else for (int i=0;idestroy(); it=notes.erase(it); } } @@ -313,7 +333,7 @@ void Channel::panic() list::iterator it; for (it=notes.begin(); it!=notes.end();) { - delete *it; + (*it)->destroy(); it=notes.erase(it); } } -- cgit v1.2.3