zynaddsubfx

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

commit 0adbb0532845d8f10d3b4636a95c59b301d10d2c
parent 3b8e3f871fda2f995adf66d436e68addf393af39
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Thu,  8 Oct 2009 21:19:16 -0400

ADnote: started to use memset/memcpy

Started to use memset/memcpy based upon suggestion by Alan Calvert

Diffstat:
MChangeLog | 3+++
Msrc/Synth/ADnote.cpp | 23++++++++---------------
2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -950,3 +950,6 @@ 06 Oct 2009 (Mark McCurry) - Added first simple profiling test +08 Oct 2009 (Mark McCurry) + - Started to see if memset/memcpy offer performance benifits when + widely used diff --git a/src/Synth/ADnote.cpp b/src/Synth/ADnote.cpp @@ -22,7 +22,7 @@ #include <math.h> #include <stdlib.h> #include <stdio.h> - +#include <string.h> #include "../globals.h" #include "../Misc/Util.h" @@ -590,7 +590,7 @@ void ADnote::KillVoice(int nvoice) if ((NoteVoicePar[nvoice].FMEnabled!=NONE)&&(NoteVoicePar[nvoice].FMVoice<0)) delete []NoteVoicePar[nvoice].FMSmp; if (NoteVoicePar[nvoice].VoiceOut!=NULL) - for (int i=0;i<SOUND_BUFFER_SIZE;i++) NoteVoicePar[nvoice].VoiceOut[i]=0.0;//do not delete, yet: perhaps is used by another voice + memset(NoteVoicePar[nvoice].VoiceOut, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE));//do not delete, yet: perhaps is used by another voice NoteVoicePar[nvoice].Enabled=OFF; }; @@ -1301,18 +1301,13 @@ int ADnote::noteout(REALTYPE *outl,REALTYPE *outr) { int i,nvoice; - 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); - for (i=0;i<SOUND_BUFFER_SIZE;i++) { - bypassl[i]=0.0; - bypassr[i]=0.0; - }; - + memset(bypassl, 0, SOUND_BUFFER_SIZE*sizeof(REALTYPE)); + memset(bypassr, 0, SOUND_BUFFER_SIZE*sizeof(REALTYPE)); computecurrentparameters(); for (nvoice=0;nvoice<NUM_VOICES;nvoice++) { @@ -1512,10 +1507,8 @@ int ADnote::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(outl, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE)); } } switch (Legato.msg) {