summaryrefslogtreecommitdiff
path: root/apps/plugins/midi/synth.c
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2011-09-06 10:34:20 +0000
committerNils Wallménius <nils@rockbox.org>2011-09-06 10:34:20 +0000
commit2afc175a4e2505c52bd0bae1469732d00f0eb5cb (patch)
tree8c79be6d4e847574102e2b138f1dc025df9101f3 /apps/plugins/midi/synth.c
parent2ac668e44cec12616a4d675f8eade8049ed10af9 (diff)
downloadrockbox-2afc175a4e2505c52bd0bae1469732d00f0eb5cb.zip
rockbox-2afc175a4e2505c52bd0bae1469732d00f0eb5cb.tar.gz
rockbox-2afc175a4e2505c52bd0bae1469732d00f0eb5cb.tar.bz2
rockbox-2afc175a4e2505c52bd0bae1469732d00f0eb5cb.tar.xz
midi: make the patch sample data pointer a *int16_t to get rid of some ugly casting and drop an acessor macro to make caching the pointer in the synthVoice loop possible. Speeds up midi by 1-2% on cf and 3-5% on PP.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30438 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/midi/synth.c')
-rw-r--r--apps/plugins/midi/synth.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c
index 0ad7bb5..663565e 100644
--- a/apps/plugins/midi/synth.c
+++ b/apps/plugins/midi/synth.c
@@ -201,8 +201,6 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
return 0;
}
-#define getSample(s,wf) ((short *)(wf)->data)[s]
-
void setPoint(struct SynthObject * so, int pt) ICODE_ATTR;
void setPoint(struct SynthObject * so, int pt)
{
@@ -269,6 +267,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i
register unsigned int cp_temp = so->cp;
wf = so->wf;
+ const int16_t *sample_data = wf->data;
const unsigned int pan = chPan[so->ch];
const int volscale = so->volscale;
@@ -309,7 +308,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i
cp_temp += so->delta;
}
- s2 = getSample((cp_temp >> FRACTSIZE)+1, wf);
+ s2 = sample_data[(cp_temp >> FRACTSIZE)+1];
if(LIKELY(mode_mask28))
{
@@ -319,7 +318,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i
if(UNLIKELY(mode_mask_looprev))
{
cp_temp += diff_loop;
- s2=getSample((cp_temp >> FRACTSIZE), wf);
+ s2 = sample_data[cp_temp >> FRACTSIZE];
}
else
{
@@ -333,7 +332,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i
if(UNLIKELY(!mode_mask24))
{
cp_temp -= diff_loop;
- s2=getSample((cp_temp >> FRACTSIZE), wf);
+ s2 = sample_data[cp_temp >> FRACTSIZE];
}
else
{
@@ -346,7 +345,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i
if(UNLIKELY(cp_temp >= num_samples))
{
cp_temp -= so->delta;
- s2 = getSample((cp_temp >> FRACTSIZE)+1, wf);
+ s2 = sample_data[(cp_temp >> FRACTSIZE)+1];
if (!rampdown) /* stop voice */
{
@@ -356,7 +355,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i
}
/* Better, working, linear interpolation */
- s1=getSample((cp_temp >> FRACTSIZE), wf);
+ s1 = sample_data[cp_temp >> FRACTSIZE];
s1 +=((signed)((s2 - s1) * (cp_temp & ((1<<FRACTSIZE)-1)))>>FRACTSIZE);