summaryrefslogtreecommitdiff
path: root/apps/plugins/midi/synth.h
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2007-10-08 19:28:41 +0000
committerNils Wallménius <nils@rockbox.org>2007-10-08 19:28:41 +0000
commitf619f8167646632d6eab10f529638eebbdda6af6 (patch)
tree119a1f4051d59808a25612421f613cb09ee1e9d5 /apps/plugins/midi/synth.h
parentd712e252fecf814a48814034a55ba60a1b194598 (diff)
downloadrockbox-f619f8167646632d6eab10f529638eebbdda6af6.tar.gz
rockbox-f619f8167646632d6eab10f529638eebbdda6af6.zip
Change loop structure for sample synthesizing. Gives a nice speedup on both coldfire and arm targets.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15036 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/midi/synth.h')
-rw-r--r--apps/plugins/midi/synth.h55
1 files changed, 1 insertions, 54 deletions
diff --git a/apps/plugins/midi/synth.h b/apps/plugins/midi/synth.h
index e04f9f4bd5..5f9edf89e5 100644
--- a/apps/plugins/midi/synth.h
+++ b/apps/plugins/midi/synth.h
@@ -17,61 +17,8 @@
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig); 19int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig);
20int synthVoice(struct SynthObject * so);
21void setPoint(struct SynthObject * so, int pt); 20void setPoint(struct SynthObject * so, int pt);
22 21void synthSamples(int32_t *buf_ptr, unsigned int num_samples);
23static inline void synthSample(int * mixL, int * mixR)
24{
25 int i;
26 register int dL=0;
27 register int dR=0;
28 register int sample = 0;
29 register struct SynthObject *voicept=voices;
30
31 for(i=MAX_VOICES/2; i > 0; i--)
32 {
33 if(voicept->isUsed==1)
34 {
35 sample = synthVoice(voicept);
36 dL += sample;
37 sample *= chPan[voicept->ch];
38 dR += sample;
39 }
40 voicept++;
41 if(voicept->isUsed==1)
42 {
43 sample = synthVoice(voicept);
44 dL += sample;
45 sample *= chPan[voicept->ch];
46 dR += sample;
47 }
48 voicept++;
49 }
50
51/* if MAX_VOICES is not even we do this to get the last voice */
52#if MAX_VOICES%2
53 if (MAX_VOICES%2)
54 {
55 if(voicept->isUsed==1)
56 {
57 sample = synthVoice(voicept);
58 dL += sample;
59 sample *= chPan[voicept->ch];
60 dR += sample;
61 }
62 }
63#endif
64
65 dL = (dL << 7) - dR;
66
67 *mixL=dL >> 7;
68 *mixR=dR >> 7;
69
70 /* TODO: Automatic Gain Control, anyone? */
71 /* Or, should this be implemented on the DSP's output volume instead? */
72
73 return; /* No more ghetto lowpass filter. Linear interpolation works well. */
74}
75 22
76static inline struct Event * getEvent(struct Track * tr, int evNum) 23static inline struct Event * getEvent(struct Track * tr, int evNum)
77{ 24{