From 28b5afd05a075cce1f46e5cc85c7e2caae3fc6ee Mon Sep 17 00:00:00 2001 From: Stepan Moskovchenko Date: Wed, 3 May 2006 19:32:22 +0000 Subject: Optimize synth code by pre-computing the volume scaling for each note. Scaling is now calculated once per MIDI event at the most, instead of once per sample. Increase voice ramping speed, increase number of active voices a little. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9870 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/midi/synth.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'apps/plugins/midi/synth.c') diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c index a364889ea0..2b70074158 100644 --- a/apps/plugins/midi/synth.c +++ b/apps/plugins/midi/synth.c @@ -255,7 +255,6 @@ inline void stopVoice(struct SynthObject * so) } - signed short int synthVoice(struct SynthObject * so) { struct GWaveform * wf; @@ -362,16 +361,21 @@ signed short int synthVoice(struct SynthObject * so) if(so->state == STATE_RAMPDOWN) { - so->decay--; - if(so->decay == 0) + so->decay-=5; + if(so->decay < 5) so->isUsed=0; s = (s * so->decay) >> 8; } - return s*((signed short int)so->vol*(signed short int)chVol[so->ch])>>14; + /* Scaling by channel volume and note volume is done in sequencer.c */ + /* That saves us some multiplication and pointer operations */ + return s*so->volscale>>14; } + + + inline void synthSample(int * mixL, int * mixR) { register int dL=0; -- cgit v1.2.3