zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 450bc141deb5192aa842071e4b57dbcdb30d25bf
parent 10ef58a45d8fceb9c3dcd0601507aec0e09455f4
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Sun, 11 Jul 2010 14:18:14 -0400

SynthNote: Created an ABC for notes

* Abstract Base Class added for the synthesizer notes
* In some sections of code, particularly Part.cpp there is a lot of repetition, as
  ADnote, PADnote, and SUBnote have not descended from a base class.
* These three classes now descend from SynthNote, which should be able to clean
  things up nicely with time

Diffstat:
Msrc/Misc/Part.cpp | 242++++++++++++++++++++++++++-----------------------------------------------------
Msrc/Misc/Part.h | 7++++---
Msrc/Synth/ADnote.cpp | 34++++++++++++++--------------------
Msrc/Synth/ADnote.h | 20++++----------------
Msrc/Synth/PADnote.cpp | 31+++++++++++++++----------------
Msrc/Synth/PADnote.h | 15+++++----------
Msrc/Synth/SUBnote.cpp | 31+++++++++++++++----------------
Msrc/Synth/SUBnote.h | 15+++++----------
Asrc/Synth/SynthNote.h | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
9 files changed, 193 insertions(+), 253 deletions(-)

diff --git a/src/Misc/Part.cpp b/src/Misc/Part.cpp @@ -358,50 +358,28 @@ void Part::NoteOn(unsigned char note, if((kit[0].Padenabled != 0) && (partnote[pos].kititem[0].adnote != NULL) && (partnote[posb].kititem[0].adnote != NULL)) { - partnote[pos].kititem[0].adnote->ADlegatonote(notebasefreq, - vel, - portamento, - note, - true); //'true' is to tell it it's being called from here. - partnote[posb].kititem[0].adnote->ADlegatonote(notebasefreq, - vel, - portamento, - note, - true); + partnote[pos].kititem[0].adnote->legatonote(notebasefreq, + vel, portamento, note, true);//'true' is to tell it it's being called from here. + partnote[posb].kititem[0].adnote->legatonote(notebasefreq, + vel, portamento, note, true); } if((kit[0].Psubenabled != 0) && (partnote[pos].kititem[0].subnote != NULL) && (partnote[posb].kititem[0].subnote != NULL)) { - partnote[pos].kititem[0].subnote->SUBlegatonote( - notebasefreq, - vel, - portamento, - note, - true); - partnote[posb].kititem[0].subnote->SUBlegatonote( - notebasefreq, - vel, - portamento, - note, - true); + partnote[pos].kititem[0].subnote->legatonote( + notebasefreq, vel, portamento, note, true); + partnote[posb].kititem[0].subnote->legatonote( + notebasefreq, vel, portamento, note, true); } if((kit[0].Ppadenabled != 0) && (partnote[pos].kititem[0].padnote != NULL) && (partnote[posb].kititem[0].padnote != NULL)) { - partnote[pos].kititem[0].padnote->PADlegatonote( - notebasefreq, - vel, - portamento, - note, - true); - partnote[posb].kititem[0].padnote->PADlegatonote( - notebasefreq, - vel, - portamento, - note, - true); + partnote[pos].kititem[0].padnote->legatonote( + notebasefreq, vel, portamento, note, true); + partnote[posb].kititem[0].padnote->legatonote( + notebasefreq, vel, portamento, note, true); } } else { // "kit mode" legato note @@ -418,7 +396,7 @@ void Part::NoteOn(unsigned char note, partnote[pos].kititem[ci].sendtoparteffect = (kit[item].Psendtoparteffect < - NUM_PART_EFX ? kit[item].Psendtoparteffect : NUM_PART_EFX); //if this parameter is 127 for "unprocessed" + NUM_PART_EFX ? kit[item].Psendtoparteffect : NUM_PART_EFX);//if this parameter is 127 for "unprocessed" partnote[posb].kititem[ci].sendtoparteffect = (kit[item].Psendtoparteffect < NUM_PART_EFX ? kit[item].Psendtoparteffect : NUM_PART_EFX); @@ -426,52 +404,28 @@ void Part::NoteOn(unsigned char note, if((kit[item].Padenabled != 0) && (kit[item].adpars != NULL) && (partnote[pos].kititem[ci].adnote != NULL) && (partnote[posb].kititem[ci].adnote != NULL)) { - partnote[pos].kititem[ci].adnote->ADlegatonote( - notebasefreq, - vel, - portamento, - note, - true); - partnote[posb].kititem[ci].adnote->ADlegatonote( - notebasefreq, - vel, - portamento, - note, - true); + partnote[pos].kititem[ci].adnote->legatonote( + notebasefreq, vel, portamento, note, true); + partnote[posb].kititem[ci].adnote->legatonote( + notebasefreq, vel, portamento, note, true); } if((kit[item].Psubenabled != 0) && (kit[item].subpars != NULL) && (partnote[pos].kititem[ci].subnote != NULL) && (partnote[posb].kititem[ci].subnote != NULL)) { - partnote[pos].kititem[ci].subnote->SUBlegatonote( - notebasefreq, - vel, - portamento, - note, - true); - partnote[posb].kititem[ci].subnote->SUBlegatonote( - notebasefreq, - vel, - portamento, - note, - true); + partnote[pos].kititem[ci].subnote->legatonote( + notebasefreq, vel, portamento, note, true); + partnote[posb].kititem[ci].subnote->legatonote( + notebasefreq, vel, portamento, note, true); } if((kit[item].Ppadenabled != 0) && (kit[item].padpars != NULL) && (partnote[pos].kititem[ci].padnote != NULL) && (partnote[posb].kititem[ci].padnote != NULL)) { - partnote[pos].kititem[ci].padnote->PADlegatonote( - notebasefreq, - vel, - portamento, - note, - true); - partnote[posb].kititem[ci].padnote->PADlegatonote( - notebasefreq, - vel, - portamento, - note, - true); + partnote[pos].kititem[ci].padnote->legatonote( + notebasefreq, vel, portamento, note, true); + partnote[posb].kititem[ci].padnote->legatonote( + notebasefreq, vel, portamento, note, true); } if((kit[item].adpars != NULL) @@ -915,108 +869,72 @@ void Part::AllNotesOff() killallnotes = 1; } +void Part::RunNote(unsigned int k) +{ + unsigned noteplay = 0; + for(int item = 0; item < partnote[k].itemsplaying; item++) { + int sendcurrenttofx = partnote[k].kititem[item].sendtoparteffect; + + for(unsigned type = 0; type < 3; ++type) { + //Select a note + SynthNote **note; + if(type == 0) + note = &partnote[k].kititem[item].adnote; + else if(type == 1) + note = &partnote[k].kititem[item].subnote; + else if(type == 2) + note = &partnote[k].kititem[item].padnote; + + //Process if it exists + if(!(*note)) + continue; + noteplay++; + + REALTYPE *tmpoutr = getTmpBuffer(); + REALTYPE *tmpoutl = getTmpBuffer(); + if((*note)->ready) + (*note)->noteout(&tmpoutl[0], &tmpoutr[0]); + else { + memset(tmpoutl, 0, sizeof(REALTYPE) * SOUND_BUFFER_SIZE); + memset(tmpoutr, 0, sizeof(REALTYPE) * SOUND_BUFFER_SIZE); + } + + if((*note)->finished()) { + delete (*note); + (*note) = NULL; + } + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { //add the note to part(mix) + partfxinputl[sendcurrenttofx][i] += tmpoutl[i]; + partfxinputr[sendcurrenttofx][i] += tmpoutr[i]; + } + returnTmpBuffer(tmpoutr); + returnTmpBuffer(tmpoutl); + } + } + + //Kill note if there is no synth on that note + if(noteplay == 0) + KillNotePos(k); +} /* * Compute Part samples and store them in the partoutl[] and partoutr[] */ void Part::ComputePartSmps() { - int i, k; - int noteplay; //0 if there is nothing activated - for(int nefx = 0; nefx < NUM_PART_EFX + 1; nefx++) { - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { + for(unsigned nefx = 0; nefx < NUM_PART_EFX + 1; nefx++) { + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { partfxinputl[nefx][i] = 0.0; partfxinputr[nefx][i] = 0.0; } } - for(k = 0; k < POLIPHONY; k++) { + for(unsigned k = 0; k < POLIPHONY; k++) { if(partnote[k].status == KEY_OFF) continue; - noteplay = 0; partnote[k].time++; //get the sampledata of the note and kill it if it's finished - - for(int item = 0; item < partnote[k].itemsplaying; item++) { - int sendcurrenttofx = partnote[k].kititem[item].sendtoparteffect; - - ADnote *adnote = partnote[k].kititem[item].adnote; - SUBnote *subnote = partnote[k].kititem[item].subnote; - PADnote *padnote = partnote[k].kititem[item].padnote; - //get from the ADnote - if(adnote) { - REALTYPE *tmpoutr = getTmpBuffer(); - REALTYPE *tmpoutl = getTmpBuffer(); - noteplay++; - if(adnote->ready) - adnote->noteout(&tmpoutl[0], &tmpoutr[0]); - else { - memset(tmpoutl, 0, sizeof(REALTYPE) * SOUND_BUFFER_SIZE); - memset(tmpoutr, 0, sizeof(REALTYPE) * SOUND_BUFFER_SIZE); - } - - if(adnote->finished() != 0) { - delete (adnote); - partnote[k].kititem[item].adnote = NULL; - } - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { //add the ADnote to part(mix) - partfxinputl[sendcurrenttofx][i] += tmpoutl[i]; - partfxinputr[sendcurrenttofx][i] += tmpoutr[i]; - } - returnTmpBuffer(tmpoutr); - returnTmpBuffer(tmpoutl); - } - //get from the SUBnote - if(subnote) { - REALTYPE *tmpoutr = getTmpBuffer(); - REALTYPE *tmpoutl = getTmpBuffer(); - noteplay++; - if(subnote->ready) - subnote->noteout(&tmpoutl[0], &tmpoutr[0]); - else { - memset(tmpoutl, 0, sizeof(REALTYPE) * SOUND_BUFFER_SIZE); - memset(tmpoutr, 0, sizeof(REALTYPE) * SOUND_BUFFER_SIZE); - } - - - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { //add the SUBnote to part(mix) - partfxinputl[sendcurrenttofx][i] += tmpoutl[i]; - partfxinputr[sendcurrenttofx][i] += tmpoutr[i]; - } - if(subnote->finished() != 0) { - delete (subnote); - partnote[k].kititem[item].subnote = NULL; - } - returnTmpBuffer(tmpoutr); - returnTmpBuffer(tmpoutl); - } - //get from the PADnote - if(padnote) { - REALTYPE *tmpoutr = getTmpBuffer(); - REALTYPE *tmpoutl = getTmpBuffer(); - noteplay++; - if(padnote->ready) - padnote->noteout(&tmpoutl[0], &tmpoutr[0]); - else { - memset(tmpoutl, 0, sizeof(REALTYPE) * SOUND_BUFFER_SIZE); - memset(tmpoutr, 0, sizeof(REALTYPE) * SOUND_BUFFER_SIZE); - } - - if(padnote->finished() != 0) { - delete (padnote); - partnote[k].kititem[item].padnote = NULL; - } - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { //add the PADnote to part(mix) - partfxinputl[sendcurrenttofx][i] += tmpoutl[i]; - partfxinputr[sendcurrenttofx][i] += tmpoutr[i]; - } - returnTmpBuffer(tmpoutr); - returnTmpBuffer(tmpoutl); - } - } - //Kill note if there is no synth on that note - if(noteplay == 0) - KillNotePos(k); + RunNote(k); } @@ -1025,26 +943,26 @@ void Part::ComputePartSmps() if(!Pefxbypass[nefx]) { partefx[nefx]->out(partfxinputl[nefx], partfxinputr[nefx]); if(Pefxroute[nefx] == 2) { - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { partfxinputl[nefx + 1][i] += partefx[nefx]->efxoutl[i]; partfxinputr[nefx + 1][i] += partefx[nefx]->efxoutr[i]; } } } int routeto = ((Pefxroute[nefx] == 0) ? nefx + 1 : NUM_PART_EFX); - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { partfxinputl[routeto][i] += partfxinputl[nefx][i]; partfxinputr[routeto][i] += partfxinputr[nefx][i]; } } - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { partoutl[i] = partfxinputl[NUM_PART_EFX][i]; partoutr[i] = partfxinputr[NUM_PART_EFX][i]; } //Kill All Notes if killallnotes!=0 if(killallnotes != 0) { - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { REALTYPE tmp = (SOUND_BUFFER_SIZE - i) / (REALTYPE) SOUND_BUFFER_SIZE; partoutl[i] *= tmp; diff --git a/src/Misc/Part.h b/src/Misc/Part.h @@ -158,6 +158,7 @@ class Part int lastnote; private: + void RunNote(unsigned k); void KillNotePos(int pos); void RelaseNotePos(int pos); void MonoMemRenote(); // MonoMem stuff. @@ -169,9 +170,9 @@ class Part int note; //if there is no note playing, the "note"=-1 int itemsplaying; struct { - ADnote *adnote; - SUBnote *subnote; - PADnote *padnote; + class SynthNote *adnote, + *subnote, + *padnote; int sendtoparteffect; } kititem[NUM_KIT_ITEMS]; int time; diff --git a/src/Synth/ADnote.cpp b/src/Synth/ADnote.cpp @@ -37,7 +37,7 @@ ADnote::ADnote(ADnoteParameters *pars, int midinote_, bool besilent) { - ready = 0; + ready = false; tmpwavel = new REALTYPE [SOUND_BUFFER_SIZE]; tmpwaver = new REALTYPE [SOUND_BUFFER_SIZE]; @@ -412,18 +412,15 @@ ADnote::ADnote(ADnoteParameters *pars, } initparameters(); - ready = 1; + ready = true; } // ADlegatonote: This function is (mostly) a copy of ADnote(...) and // initparameters() stuck together with some lines removed so that it // only alter the already playing note (to perform legato). It is // possible I left stuff that is not required for this. -void ADnote::ADlegatonote(REALTYPE freq, - REALTYPE velocity, - int portamento_, - int midinote_, - bool externcall) +void ADnote::legatonote(REALTYPE freq, REALTYPE velocity, int portamento_, + int midinote_, bool externcall) { ADnoteParameters *pars = partparams; //Controller *ctl_=ctl; @@ -700,9 +697,6 @@ void ADnote::ADlegatonote(REALTYPE freq, tmp[i] = 1; ; } - /////////////// - - // End of the ADlegatonote function. } @@ -1884,11 +1878,11 @@ int ADnote::noteout(REALTYPE *outl, REALTYPE *outr) // the note to the actual parameters. Legato.decounter = -10; Legato.msg = LM_ToNorm; - ADlegatonote(Legato.param.freq, - Legato.param.vel, - Legato.param.portamento, - Legato.param.midinote, - false); + legatonote(Legato.param.freq, + Legato.param.vel, + Legato.param.portamento, + Legato.param.midinote, + false); break; } } @@ -1926,11 +1920,11 @@ int ADnote::noteout(REALTYPE *outl, REALTYPE *outr) Legato.msg = LM_CatchUp; REALTYPE catchupfreq = Legato.param.freq * (Legato.param.freq / Legato.lastfreq); //This freq should make this now silent note to catch-up (or should I say resync ?) with the heard note for the same length it stayed at the previous freq during the fadeout. - ADlegatonote(catchupfreq, - Legato.param.vel, - Legato.param.portamento, - Legato.param.midinote, - false); + legatonote(catchupfreq, + Legato.param.vel, + Legato.param.portamento, + Legato.param.midinote, + false); break; } Legato.fade.m -= Legato.fade.step; diff --git a/src/Synth/ADnote.h b/src/Synth/ADnote.h @@ -23,7 +23,7 @@ #ifndef AD_NOTE_H #define AD_NOTE_H -#include "../globals.h" +#include "SynthNote.h" #include "Envelope.h" #include "LFO.h" #include "../DSP/Filter.h" @@ -38,7 +38,7 @@ #define OSCIL_SMP_EXTRA_SAMPLES 5 /**The "additive" synthesizer*/ -class ADnote //ADDitive note +class ADnote :public SynthNote { public: /**Constructor. @@ -56,24 +56,12 @@ class ADnote //ADDitive note ~ADnote(); /**Alters the playing note for legato effect*/ - void ADlegatonote(REALTYPE freq, REALTYPE velocity, int portamento_, - int midinote_, bool externcall); + void legatonote(REALTYPE freq, REALTYPE velocity, int portamento_, + int midinote_, bool externcall); - /**Compute ADnote Samples. - * @return 0 if note is finished*/ int noteout(REALTYPE *outl, REALTYPE *outr); - - /**Release the key for the note and start release portion of envelopes.*/ void relasekey(); - /**Return if note is finished. - * @return finished=1 unfinished=0*/ int finished() const; - - - /**Nonzero when ready for output(the parameters has been computed) - * zero when parameters need to be computed.*/ - char ready; - private: /**Changes the frequency of an oscillator. diff --git a/src/Synth/PADnote.cpp b/src/Synth/PADnote.cpp @@ -30,7 +30,7 @@ PADnote::PADnote(PADnoteParameters *parameters, int midinote, bool besilent) { - ready = 0; + ready = false; // Initialise some legato-specific vars Legato.msg = LM_Norm; @@ -157,7 +157,7 @@ PADnote::PADnote(PADnoteParameters *parameters, NoteGlobalPar.FilterFreqTracking = pars->GlobalFilter->getfreqtracking( basefreq); - ready = 1; ///sa il pun pe asta doar cand e chiar gata + ready = true; ///sa il pun pe asta doar cand e chiar gata if(parameters->sample[nsample].smp == NULL) { finished_ = true; @@ -166,11 +166,11 @@ PADnote::PADnote(PADnoteParameters *parameters, } -// PADlegatonote: This function is (mostly) a copy of PADnote(...) +// legatonote: This function is (mostly) a copy of PADnote(...) // with some lines removed so that it only alter the already playing // note (to perform legato). It is possible I left stuff that is not // required for this. -void PADnote::PADlegatonote(REALTYPE freq, +void PADnote::legatonote(REALTYPE freq, REALTYPE velocity, int portamento_, int midinote, @@ -280,7 +280,6 @@ void PADnote::PADlegatonote(REALTYPE freq, return; } - // End of the PADlegatonote function. } @@ -523,11 +522,11 @@ int PADnote::noteout(REALTYPE *outl, REALTYPE *outr) // the note to the actual parameters. Legato.decounter = -10; Legato.msg = LM_ToNorm; - PADlegatonote(Legato.param.freq, - Legato.param.vel, - Legato.param.portamento, - Legato.param.midinote, - false); + legatonote(Legato.param.freq, + Legato.param.vel, + Legato.param.portamento, + Legato.param.midinote, + false); break; } } @@ -565,11 +564,11 @@ int PADnote::noteout(REALTYPE *outl, REALTYPE *outr) Legato.msg = LM_CatchUp; REALTYPE catchupfreq = Legato.param.freq * (Legato.param.freq / Legato.lastfreq); //This freq should make this now silent note to catch-up (or should I say resync ?) with the heard note for the same length it stayed at the previous freq during the fadeout. - PADlegatonote(catchupfreq, - Legato.param.vel, - Legato.param.portamento, - Legato.param.midinote, - false); + legatonote(catchupfreq, + Legato.param.vel, + Legato.param.portamento, + Legato.param.midinote, + false); break; } Legato.fade.m -= Legato.fade.step; @@ -596,7 +595,7 @@ int PADnote::noteout(REALTYPE *outl, REALTYPE *outr) return 1; } -int PADnote::finished() +int PADnote::finished() const { return finished_; } diff --git a/src/Synth/PADnote.h b/src/Synth/PADnote.h @@ -21,6 +21,7 @@ #ifndef PAD_NOTE_H #define PAD_NOTE_H +#include "SynthNote.h" #include "../globals.h" #include "../Params/PADnoteParameters.h" #include "../Params/Controller.h" @@ -30,7 +31,7 @@ #include "../Params/Controller.h" /**The "pad" synthesizer*/ -class PADnote +class PADnote :public SynthNote { public: PADnote(PADnoteParameters *parameters, @@ -42,18 +43,12 @@ class PADnote bool besilent); ~PADnote(); - void PADlegatonote(REALTYPE freq, - REALTYPE velocity, - int portamento_, - int midinote, - bool externcall); + void legatonote(REALTYPE freq, REALTYPE velocity, int portamento_, + int midinote, bool externcall); int noteout(REALTYPE *outl, REALTYPE *outr); - int finished(); + int finished() const; void relasekey(); - - int ready; - private: void fadein(REALTYPE *smps); void computecurrentparameters(); diff --git a/src/Synth/SUBnote.cpp b/src/Synth/SUBnote.cpp @@ -35,7 +35,7 @@ SUBnote::SUBnote(SUBnoteParameters *parameters, int midinote, bool besilent) { - ready = 0; + ready = false; tmpsmp = new REALTYPE[SOUND_BUFFER_SIZE]; tmprnd = new REALTYPE[SOUND_BUFFER_SIZE]; @@ -188,15 +188,15 @@ SUBnote::SUBnote(SUBnoteParameters *parameters, initparameters(basefreq / 440.0 * freq); oldamplitude = newamplitude; - ready = 1; + ready = true; } -// SUBlegatonote: This function is (mostly) a copy of SUBnote(...) and +// legatonote: This function is (mostly) a copy of SUBnote(...) and // initparameters(...) stuck together with some lines removed so that // it only alter the already playing note (to perform legato). It is // possible I left stuff that is not required for this. -void SUBnote::SUBlegatonote(REALTYPE freq, +void SUBnote::legatonote(REALTYPE freq, REALTYPE velocity, int portamento_, int midinote, @@ -369,7 +369,6 @@ void SUBnote::SUBlegatonote(REALTYPE freq, oldamplitude = newamplitude; - // End of the SUBlegatonote function. } @@ -693,11 +692,11 @@ int SUBnote::noteout(REALTYPE *outl, REALTYPE *outr) // the note to the actual parameters. Legato.decounter = -10; Legato.msg = LM_ToNorm; - SUBlegatonote(Legato.param.freq, - Legato.param.vel, - Legato.param.portamento, - Legato.param.midinote, - false); + legatonote(Legato.param.freq, + Legato.param.vel, + Legato.param.portamento, + Legato.param.midinote, + false); break; } } @@ -735,11 +734,11 @@ int SUBnote::noteout(REALTYPE *outl, REALTYPE *outr) Legato.msg = LM_CatchUp; REALTYPE catchupfreq = Legato.param.freq * (Legato.param.freq / Legato.lastfreq); //This freq should make this now silent note to catch-up (or should I say resync ?) with the heard note for the same length it stayed at the previous freq during the fadeout. - SUBlegatonote(catchupfreq, - Legato.param.vel, - Legato.param.portamento, - Legato.param.midinote, - false); + legatonote(catchupfreq, + Legato.param.vel, + Legato.param.portamento, + Legato.param.midinote, + false); break; } Legato.fade.m -= Legato.fade.step; @@ -780,7 +779,7 @@ void SUBnote::relasekey() /* * Check if the note is finished */ -int SUBnote::finished() +int SUBnote::finished() const { if(NoteEnabled == OFF) return 1; diff --git a/src/Synth/SUBnote.h b/src/Synth/SUBnote.h @@ -23,13 +23,14 @@ #ifndef SUB_NOTE_H #define SUB_NOTE_H +#include "SynthNote.h" #include "../globals.h" #include "../Params/SUBnoteParameters.h" #include "../Params/Controller.h" #include "Envelope.h" #include "../DSP/Filter.h" -class SUBnote +class SUBnote :public SynthNote { public: SUBnote(SUBnoteParameters *parameters, @@ -41,18 +42,12 @@ class SUBnote bool besilent); ~SUBnote(); - void SUBlegatonote(REALTYPE freq, - REALTYPE velocity, - int portamento_, - int midinote, - bool externcall); + void legatonote(REALTYPE freq, REALTYPE velocity, int portamento_, + int midinote, bool externcall); int noteout(REALTYPE *outl, REALTYPE *outr); //note output,return 0 if the note is finished void relasekey(); - int finished(); - - int ready; //if I can get the sampledata - + int finished() const; private: void computecurrentparameters(); diff --git a/src/Synth/SynthNote.h b/src/Synth/SynthNote.h @@ -0,0 +1,51 @@ +/* + ZynAddSubFX - a software synthesizer + + Note.h - Abstract Base Class for synthesizers + Copyright (C) 2010-2010 Mark McCurry + Author: Mark McCurry + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License + as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License (version 2 or later) for more details. + + You should have received a copy of the GNU General Public License (version 2) + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ +#ifndef SYNTH_NOTE_H +#define SYNTH_NOTE_H +#include "../globals.h" + +class SynthNote +{ + public: + virtual ~SynthNote() {} + + /**Compute Output Samples + * @return 0 if note is finished*/ + virtual int noteout(REALTYPE *outl, REALTYPE *outr) = 0; + + //TODO fix this spelling error [noisey commit] + /**Release the key for the note and start release portion of envelopes.*/ + virtual void relasekey() = 0; + + /**Return if note is finished. + * @return finished=1 unfinished=0*/ + virtual int finished() const = 0; + + virtual void legatonote(REALTYPE freq, REALTYPE velocity, + int portamento_, int midinote_, bool externcall) = 0; + /**true when ready for output(the parameters has been computed) + * false when parameters need to be computed.*/ + bool ready; +}; + +#endif +