commit 10ef58a45d8fceb9c3dcd0601507aec0e09455f4
parent 4770ac808720158f7050e902f356f46d444a0968
Author: fundamental <mark.d.mccurry@gmail.com>
Date: Sun, 11 Jul 2010 13:29:58 -0400
Misc: Removing more temporaries
Diffstat:
6 files changed, 42 insertions(+), 55 deletions(-)
diff --git a/src/Misc/Master.cpp b/src/Misc/Master.cpp
@@ -45,9 +45,6 @@ Master::Master()
pthread_mutex_init(&vumutex, NULL);
fft = new FFTwrapper(OSCIL_SIZE);
- tmpmixl = new REALTYPE[SOUND_BUFFER_SIZE];
- tmpmixr = new REALTYPE[SOUND_BUFFER_SIZE];
-
shutup = 0;
for(int npart = 0; npart < NUM_MIDI_PARTS; npart++) {
vuoutpeakpart[npart] = 1e-9;
@@ -371,11 +368,11 @@ void Master::AudioOut(REALTYPE *outl, REALTYPE *outr)
if(sysefx[nefx]->geteffect() == 0)
continue; //the effect is disabled
+ REALTYPE *tmpmixl = getTmpBuffer();
+ REALTYPE *tmpmixr = getTmpBuffer();
//Clean up the samples used by the system effects
- for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
- tmpmixl[i] = 0.0;
- tmpmixr[i] = 0.0;
- }
+ memset(tmpmixl, 0, sizeof(REALTYPE) * SOUND_BUFFER_SIZE);
+ memset(tmpmixr, 0, sizeof(REALTYPE) * SOUND_BUFFER_SIZE);
//Mix the channels according to the part settings about System Effect
for(npart = 0; npart < NUM_MIDI_PARTS; npart++) {
@@ -414,6 +411,9 @@ void Master::AudioOut(REALTYPE *outl, REALTYPE *outr)
outl[i] += tmpmixl[i] * outvol;
outr[i] += tmpmixr[i] * outvol;
}
+
+ returnTmpBuffer(tmpmixl);
+ returnTmpBuffer(tmpmixr);
}
//Mix all parts
@@ -470,8 +470,6 @@ Master::~Master()
for(int nefx = 0; nefx < NUM_SYS_EFX; nefx++)
delete sysefx[nefx];
- delete [] tmpmixl;
- delete [] tmpmixr;
delete fft;
FFT_cleanup();
diff --git a/src/Misc/Master.h b/src/Misc/Master.h
@@ -167,11 +167,6 @@ class Master
REALTYPE volume;
REALTYPE sysefxvol[NUM_SYS_EFX][NUM_MIDI_PARTS];
REALTYPE sysefxsend[NUM_SYS_EFX][NUM_SYS_EFX];
-
- //Temporary mixing samples for part samples which is sent to system effect
- REALTYPE *tmpmixl;
- REALTYPE *tmpmixr;
-
int keyshift;
};
diff --git a/src/Misc/Part.cpp b/src/Misc/Part.cpp
@@ -22,6 +22,7 @@
#include "Part.h"
#include "Microtonal.h"
+#include "Util.h"
#include "../Effects/EffectMgr.h"
#include "../Params/ADnoteParameters.h"
#include "../Params/SUBnoteParameters.h"
@@ -40,8 +41,6 @@ Part::Part(Microtonal *microtonal_, FFTwrapper *fft_, pthread_mutex_t *mutex_)
mutex = mutex_;
partoutl = new REALTYPE [SOUND_BUFFER_SIZE];
partoutr = new REALTYPE [SOUND_BUFFER_SIZE];
- tmpoutl = new REALTYPE [SOUND_BUFFER_SIZE];
- tmpoutr = new REALTYPE [SOUND_BUFFER_SIZE];
for(int n = 0; n < NUM_KIT_ITEMS; n++) {
kit[n].Pname = new unsigned char [PART_MAX_NAME_LEN];
@@ -162,8 +161,6 @@ void Part::cleanup(bool final)
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
partoutl[i] = final ? 0.0 : denormalkillbuf[i];
partoutr[i] = final ? 0.0 : denormalkillbuf[i];
- tmpoutl[i] = 0.0;
- tmpoutr[i] = 0.0;
}
ctl.resetall();
for(int nefx = 0; nefx < NUM_PART_EFX; nefx++)
@@ -195,8 +192,6 @@ Part::~Part()
delete [] Pname;
delete [] partoutl;
delete [] partoutr;
- delete [] tmpoutl;
- delete [] tmpoutr;
for(int nefx = 0; nefx < NUM_PART_EFX; nefx++)
delete (partefx[nefx]);
for(int n = 0; n < NUM_PART_EFX + 1; n++) {
@@ -949,16 +944,17 @@ void Part::ComputePartSmps()
SUBnote *subnote = partnote[k].kititem[item].subnote;
PADnote *padnote = partnote[k].kititem[item].padnote;
//get from the ADnote
- if(adnote != NULL) {
+ if(adnote) {
+ REALTYPE *tmpoutr = getTmpBuffer();
+ REALTYPE *tmpoutl = getTmpBuffer();
noteplay++;
- if(adnote->ready != 0)
+ if(adnote->ready)
adnote->noteout(&tmpoutl[0], &tmpoutr[0]);
- else
- for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
- tmpoutl[i] = 0.0;
- tmpoutr[i] = 0.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;
@@ -967,18 +963,21 @@ void Part::ComputePartSmps()
partfxinputl[sendcurrenttofx][i] += tmpoutl[i];
partfxinputr[sendcurrenttofx][i] += tmpoutr[i];
}
+ returnTmpBuffer(tmpoutr);
+ returnTmpBuffer(tmpoutl);
}
//get from the SUBnote
- if(subnote != NULL) {
+ if(subnote) {
+ REALTYPE *tmpoutr = getTmpBuffer();
+ REALTYPE *tmpoutl = getTmpBuffer();
noteplay++;
- if(subnote->ready != 0)
+ if(subnote->ready)
subnote->noteout(&tmpoutl[0], &tmpoutr[0]);
- else
- for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
- tmpoutl[i] = 0.0;
- tmpoutr[i] = 0.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];
@@ -988,18 +987,21 @@ void Part::ComputePartSmps()
delete (subnote);
partnote[k].kititem[item].subnote = NULL;
}
+ returnTmpBuffer(tmpoutr);
+ returnTmpBuffer(tmpoutl);
}
//get from the PADnote
- if(padnote != NULL) {
+ if(padnote) {
+ REALTYPE *tmpoutr = getTmpBuffer();
+ REALTYPE *tmpoutl = getTmpBuffer();
noteplay++;
- if(padnote->ready != 0)
+ if(padnote->ready)
padnote->noteout(&tmpoutl[0], &tmpoutr[0]);
- else
- for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
- tmpoutl[i] = 0.0;
- tmpoutr[i] = 0.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;
@@ -1008,6 +1010,8 @@ void Part::ComputePartSmps()
partfxinputl[sendcurrenttofx][i] += tmpoutl[i];
partfxinputr[sendcurrenttofx][i] += tmpoutr[i];
}
+ returnTmpBuffer(tmpoutr);
+ returnTmpBuffer(tmpoutl);
}
}
//Kill note if there is no synth on that note
@@ -1045,15 +1049,13 @@ void Part::ComputePartSmps()
(SOUND_BUFFER_SIZE - i) / (REALTYPE) SOUND_BUFFER_SIZE;
partoutl[i] *= tmp;
partoutr[i] *= tmp;
- tmpoutl[i] = 0.0;
- tmpoutr[i] = 0.0;
}
for(int k = 0; k < POLIPHONY; k++)
KillNotePos(k);
killallnotes = 0;
for(int nefx = 0; nefx < NUM_PART_EFX; nefx++)
partefx[nefx]->cleanup();
- ;
+
}
ctl.updateportamento();
}
diff --git a/src/Misc/Part.h b/src/Misc/Part.h
@@ -195,9 +195,6 @@ class Part
PartNotes partnote[POLIPHONY];
- REALTYPE *tmpoutl; //used to get the note
- REALTYPE *tmpoutr;
-
REALTYPE oldfreq; //this is used for portamento
Microtonal *microtonal;
FFTwrapper *fft;
diff --git a/src/Synth/PADnote.cpp b/src/Synth/PADnote.cpp
@@ -103,9 +103,6 @@ PADnote::PADnote(PADnoteParameters *parameters,
poshi_r = poshi_l;
poslo = 0.0;
- tmpwave = new REALTYPE [SOUND_BUFFER_SIZE];
-
-
if(pars->PPanning == 0)
NoteGlobalPar.Panning = RND;
@@ -297,7 +294,6 @@ PADnote::~PADnote()
delete (NoteGlobalPar.GlobalFilterR);
delete (NoteGlobalPar.FilterEnvelope);
delete (NoteGlobalPar.FilterLfo);
- delete [] tmpwave;
}
diff --git a/src/Synth/PADnote.h b/src/Synth/PADnote.h
@@ -118,7 +118,6 @@ class PADnote
REALTYPE globaloldamplitude, globalnewamplitude, velocity, realfreq;
- REALTYPE *tmpwave;
Controller *ctl;
// Legato vars