summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2007-04-11 10:48:50 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2007-04-11 10:48:50 +0000
commit7c4b786851ec90364c0335b46d093fb6dba1af01 (patch)
tree562892475a99808145cb6a35f4098cd2dc78ff15
parent08e633c25c3f70d8d8b900cf09576986a398a474 (diff)
downloadrockbox-7c4b786851ec90364c0335b46d093fb6dba1af01.tar.gz
rockbox-7c4b786851ec90364c0335b46d093fb6dba1af01.zip
Some quick and dirty MIDI player optimizations, now it works on the X5 and M5 too
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13108 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/midi/guspat.c5
-rw-r--r--apps/plugins/midi/synth.c8
-rw-r--r--apps/plugins/midiplay.c12
3 files changed, 11 insertions, 14 deletions
diff --git a/apps/plugins/midi/guspat.c b/apps/plugins/midi/guspat.c
index 716c20d99e..983589fcfd 100644
--- a/apps/plugins/midi/guspat.c
+++ b/apps/plugins/midi/guspat.c
@@ -29,9 +29,12 @@ unsigned int readDWord(int file)
29 return (readChar(file)<<0) | (readChar(file)<<8) | (readChar(file)<<16) | (readChar(file)<<24); 29 return (readChar(file)<<0) | (readChar(file)<<8) | (readChar(file)<<16) | (readChar(file)<<24);
30} 30}
31 31
32int curr_waveform;
33struct GWaveform waveforms[32] IBSS_ATTR;
34
32struct GWaveform * loadWaveform(int file) 35struct GWaveform * loadWaveform(int file)
33{ 36{
34 struct GWaveform * wav = (struct GWaveform *)malloc(sizeof(struct GWaveform)); 37 struct GWaveform * wav = &waveforms[curr_waveform++];
35 rb->memset(wav, 0, sizeof(struct GWaveform)); 38 rb->memset(wav, 0, sizeof(struct GWaveform));
36 39
37 wav->name=readData(file, 7); 40 wav->name=readData(file, 7);
diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c
index a3a3d608e7..5a7a02f0a1 100644
--- a/apps/plugins/midi/synth.c
+++ b/apps/plugins/midi/synth.c
@@ -182,12 +182,7 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
182 return 0; 182 return 0;
183} 183}
184 184
185inline short getSample(int s,struct GWaveform * wf ) 185#define getSample(s,wf) ((short *)(wf)->data)[s]
186{
187 /* Sign conversion moved to guspat.c */
188 /* 8bit conversion NOT YET IMPLEMENTED in guspat.c */
189 return ((short *) wf->data)[s];
190}
191 186
192void setPoint(struct SynthObject * so, int pt) 187void setPoint(struct SynthObject * so, int pt)
193{ 188{
@@ -254,6 +249,7 @@ inline void stopVoice(struct SynthObject * so)
254 so->decay = 0; 249 so->decay = 0;
255} 250}
256 251
252signed short int synthVoice(struct SynthObject * so) ICODE_ATTR;
257signed short int synthVoice(struct SynthObject * so) 253signed short int synthVoice(struct SynthObject * so)
258{ 254{
259 struct GWaveform * wf; 255 struct GWaveform * wf;
diff --git a/apps/plugins/midiplay.c b/apps/plugins/midiplay.c
index 61a834755f..1e3a62b58a 100644
--- a/apps/plugins/midiplay.c
+++ b/apps/plugins/midiplay.c
@@ -81,7 +81,7 @@ PLUGIN_IRAM_DECLARE
81 81
82#ifndef SIMULATOR 82#ifndef SIMULATOR
83 #define SAMPLE_RATE 22050 // 44100 22050 11025 83 #define SAMPLE_RATE 22050 // 44100 22050 11025
84 #define MAX_VOICES 14 // Note: 24 midi channels is the minimum general midi 84 #define MAX_VOICES 20 // Note: 24 midi channels is the minimum general midi
85 // spec implementation 85 // spec implementation
86#else // Simulator requires 44100, and we can afford to use more voices 86#else // Simulator requires 44100, and we can afford to use more voices
87 #define SAMPLE_RATE 44100 87 #define SAMPLE_RATE 44100
@@ -89,7 +89,7 @@ PLUGIN_IRAM_DECLARE
89#endif 89#endif
90 90
91 91
92#define BUF_SIZE 512 92#define BUF_SIZE 256
93#define NBUF 2 93#define NBUF 2
94 94
95#undef SYNC 95#undef SYNC
@@ -110,7 +110,7 @@ long bpm IBSS_ATTR;
110#include "midi/midifile.c" 110#include "midi/midifile.c"
111#include "midi/synth.c" 111#include "midi/synth.c"
112 112
113short gmbuf[BUF_SIZE*NBUF] IBSS_ATTR; 113long gmbuf[BUF_SIZE*NBUF];
114 114
115int quit=0; 115int quit=0;
116struct plugin_api * rb; 116struct plugin_api * rb;
@@ -165,7 +165,7 @@ bool lastswap=1;
165 165
166inline void synthbuf(void) 166inline void synthbuf(void)
167{ 167{
168 short *outptr; 168 long *outptr;
169 register int i; 169 register int i;
170 static int currentSample=0; 170 static int currentSample=0;
171 int synthtemp[2]; 171 int synthtemp[2];
@@ -183,9 +183,7 @@ inline void synthbuf(void)
183 { 183 {
184 synthSample(&synthtemp[0], &synthtemp[1]); 184 synthSample(&synthtemp[0], &synthtemp[1]);
185 currentSample++; 185 currentSample++;
186 *outptr=synthtemp[0]&0xFFFF; 186 *outptr=((synthtemp[0]&0xFFFF) << 16) | (synthtemp[1]&0xFFFF);
187 outptr++;
188 *outptr=synthtemp[1]&0xFFFF;
189 outptr++; 187 outptr++;
190 if(currentSample==numberOfSamples) 188 if(currentSample==numberOfSamples)
191 { 189 {