zynaddsubfx

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

commit 6ddc5ff44be31aef98d5dca1bc48c1a1fa065b15
parent 2922cb4e88c3e13a990ca408a171b2f183e954d6
Author: fundamental <[email protected]>
Date:   Thu,  8 Oct 2009 22:24:31 -0400

SUBnote: integrated memcpy/memset

Diffstat:
Msrc/Synth/SUBnote.cpp | 19+++++++------------
Msrc/Synth/SUBnote.h | 2+-
2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/src/Synth/SUBnote.cpp b/src/Synth/SUBnote.cpp @@ -418,7 +418,6 @@ void SUBnote::filter(bpfilter &filter,REALTYPE *smps) filter.yn2=filter.yn1; filter.yn1=out; smps[i]=out; - }; }; @@ -519,17 +518,15 @@ int SUBnote::noteout(REALTYPE *outl,REALTYPE *outr) { int i; - for (i=0;i<SOUND_BUFFER_SIZE;i++) { - outl[i]=denormalkillbuf[i]; - outr[i]=denormalkillbuf[i]; - }; + memcpy(outl, denormalkillbuf, SOUND_BUFFER_SIZE * sizeof(REALTYPE)); + memcpy(outr, denormalkillbuf, SOUND_BUFFER_SIZE * sizeof(REALTYPE)); if (NoteEnabled==OFF) return(0); //left channel for (i=0;i<SOUND_BUFFER_SIZE;i++) tmprnd[i]=RND*2.0-1.0; for (int n=0;n<numharmonics;n++) { - for (i=0;i<SOUND_BUFFER_SIZE;i++) tmpsmp[i]=tmprnd[i]; + memcpy(tmpsmp, tmprnd, SOUND_BUFFER_SIZE * sizeof(REALTYPE)); for (int nph=0;nph<numstages;nph++) filter(lfilter[nph+n*numstages],tmpsmp); for (i=0;i<SOUND_BUFFER_SIZE;i++) outl[i]+=tmpsmp[i]; @@ -541,13 +538,13 @@ int SUBnote::noteout(REALTYPE *outl,REALTYPE *outr) if (stereo!=0) { for (i=0;i<SOUND_BUFFER_SIZE;i++) tmprnd[i]=RND*2.0-1.0; for (int n=0;n<numharmonics;n++) { - for (i=0;i<SOUND_BUFFER_SIZE;i++) tmpsmp[i]=tmprnd[i]; + memcpy(tmpsmp, tmprnd, SOUND_BUFFER_SIZE * sizeof(REALTYPE)); for (int nph=0;nph<numstages;nph++) filter(rfilter[nph+n*numstages],tmpsmp); for (i=0;i<SOUND_BUFFER_SIZE;i++) outr[i]+=tmpsmp[i]; }; if (GlobalFilterR!=NULL) GlobalFilterR->filterout(&outr[0]); - } else for (i=0;i<SOUND_BUFFER_SIZE;i++) outr[i]=outl[i]; + } else memcpy(outr, outl, SOUND_BUFFER_SIZE * sizeof(REALTYPE)); if (firsttick!=0) { int n=10; @@ -581,10 +578,8 @@ int SUBnote::noteout(REALTYPE *outl,REALTYPE *outr) // Apply legato-specific sound signal modifications if (Legato.silent) { // Silencer if (Legato.msg!=LM_FadeIn) { - for (i=0;i<SOUND_BUFFER_SIZE;i++) { - outl[i]=0.0; - outr[i]=0.0; - } + memset(outl, 0, SOUND_BUFFER_SIZE* sizeof(REALTYPE)); + memset(outr, 0, SOUND_BUFFER_SIZE* sizeof(REALTYPE)); } } switch (Legato.msg) { diff --git a/src/Synth/SUBnote.h b/src/Synth/SUBnote.h @@ -83,7 +83,7 @@ private: void initfilter(bpfilter &filter,REALTYPE freq,REALTYPE bw,REALTYPE amp,REALTYPE mag); void computefiltercoefs(bpfilter &filter,REALTYPE freq,REALTYPE bw,REALTYPE gain); - void filter(bpfilter &filter,REALTYPE *smps); + inline void filter(bpfilter &filter,REALTYPE *smps); bpfilter *lfilter,*rfilter;