summaryrefslogtreecommitdiff
path: root/apps/plugins/midi/synth.c
diff options
context:
space:
mode:
authorStepan Moskovchenko <stevenm@rockbox.org>2006-05-03 19:32:22 +0000
committerStepan Moskovchenko <stevenm@rockbox.org>2006-05-03 19:32:22 +0000
commit28b5afd05a075cce1f46e5cc85c7e2caae3fc6ee (patch)
treed7285c0d7afb20145a0a9918b17827ed59a1cc9b /apps/plugins/midi/synth.c
parent7f1d21480127c9246d2aa7a329f74fd8754b1e42 (diff)
downloadrockbox-28b5afd05a075cce1f46e5cc85c7e2caae3fc6ee.tar.gz
rockbox-28b5afd05a075cce1f46e5cc85c7e2caae3fc6ee.zip
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
Diffstat (limited to 'apps/plugins/midi/synth.c')
-rw-r--r--apps/plugins/midi/synth.c12
1 files changed, 8 insertions, 4 deletions
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)
255 255
256} 256}
257 257
258
259signed short int synthVoice(struct SynthObject * so) 258signed short int synthVoice(struct SynthObject * so)
260{ 259{
261 struct GWaveform * wf; 260 struct GWaveform * wf;
@@ -362,16 +361,21 @@ signed short int synthVoice(struct SynthObject * so)
362 361
363 if(so->state == STATE_RAMPDOWN) 362 if(so->state == STATE_RAMPDOWN)
364 { 363 {
365 so->decay--; 364 so->decay-=5;
366 if(so->decay == 0) 365 if(so->decay < 5)
367 so->isUsed=0; 366 so->isUsed=0;
368 s = (s * so->decay) >> 8; 367 s = (s * so->decay) >> 8;
369 } 368 }
370 369
371 return s*((signed short int)so->vol*(signed short int)chVol[so->ch])>>14; 370 /* Scaling by channel volume and note volume is done in sequencer.c */
371 /* That saves us some multiplication and pointer operations */
372 return s*so->volscale>>14;
372} 373}
373 374
374 375
376
377
378
375inline void synthSample(int * mixL, int * mixR) 379inline void synthSample(int * mixL, int * mixR)
376{ 380{
377 register int dL=0; 381 register int dL=0;