From c3584c0d636c8c9abbfd5ee6980c21e935bea512 Mon Sep 17 00:00:00 2001 From: Stepan Moskovchenko Date: Wed, 17 Oct 2007 05:06:57 +0000 Subject: [PATCH] MIDI: Scale each instrument by a calibration value, since not all patches are at the same base volume. This should make some files sound more natural, without some instruments overpowering others. Ultimately, these values need to be moved to the config file, and the table should probably be put in IRAM or something. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15161 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/midi/sequencer.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/apps/plugins/midi/sequencer.c b/apps/plugins/midi/sequencer.c index 4c9520f91d..e20047a231 100644 --- a/apps/plugins/midi/sequencer.c +++ b/apps/plugins/midi/sequencer.c @@ -25,13 +25,36 @@ extern struct plugin_api * rb; long tempo=375000; +/* From the old patch config.... each patch is scaled. + * Should be moved into patchset.cfg + * But everyone would need a new config file. + * + * While this really does need to go into the patch config, + * I doubt anyone has made their own custom rockbox patchset + * (if you have, please send a copy my way :) ) + */ +static const unsigned char patchScale[]= +{ + 125,115,115,100,100,80,115,100,100,100,100,80,100,100,100,100, + 100,100,100,100,60,100,100,100,150,155,145,100,125,86,125,85, + 161,160,133,160,135,133,100,128,150,100,100,150,100,130,100,200, + 100,100,125,125,100,100,100,100,124,110,111,100,139,113,115,115, + 125,115,95,140,100,100,105,100,90,100,80,80,100,125,100,80, + 100,100,100,250,130,100,100,100,115,100,100,120,200,100,100,80, + 130,100,100,150,100,100,100,100,100,100,200,100,100,100,100,100, + 100,100,113,100,200,100,100,100,30,100,100,100,100,100,100,100 +}; + /* Sets the volume scaling by channel volume and note volume */ /* This way we can do the multiplication/indexing once per */ /* MIDI event at the most, instead of once per sample. */ static inline void setVolScale(int a) { struct SynthObject * so = &voices[a]; - so->volscale = ((signed short int)so->vol*(signed short int)chVol[so->ch]); + int ch = so->ch; + + so->volscale = so->vol * chVol[ch]*patchScale[chPat[ch]] / 100; + //((signed short int)so->vol*(signed short int)chVol[ch])*patchScale[chPat[ch]]; } static inline void setVol(int ch, int vol)