summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/midi/guspat.c4
-rw-r--r--apps/plugins/midi/guspat.h2
-rw-r--r--apps/plugins/midi/midiutil.c4
-rw-r--r--apps/plugins/midi/midiutil.h2
-rw-r--r--apps/plugins/midi/synth.c13
5 files changed, 12 insertions, 13 deletions
diff --git a/apps/plugins/midi/guspat.c b/apps/plugins/midi/guspat.c
index 5f6ba35110..ea0ca92518 100644
--- a/apps/plugins/midi/guspat.c
+++ b/apps/plugins/midi/guspat.c
@@ -122,7 +122,7 @@ struct GWaveform * loadWaveform(int file)
122 /* Byte-swap if necessary. Gus files are little endian */ 122 /* Byte-swap if necessary. Gus files are little endian */
123 for(a=0; a<wav->numSamples; a++) 123 for(a=0; a<wav->numSamples; a++)
124 { 124 {
125 ((unsigned short *) wav->data)[a] = letoh16(((unsigned short *) wav->data)[a]); 125 ((uint16_t*) wav->data)[a] = letoh16(((uint16_t *) wav->data)[a]);
126 } 126 }
127#endif 127#endif
128 128
@@ -130,7 +130,7 @@ struct GWaveform * loadWaveform(int file)
130 if(wav->mode & 2) 130 if(wav->mode & 2)
131 { 131 {
132 for(a=0; a<wav->numSamples; a++) 132 for(a=0; a<wav->numSamples; a++)
133 ((short *) wav->data)[a] = ((unsigned short *) wav->data)[a] - 32768; 133 ((int16_t *) wav->data)[a] = ((uint16_t *) wav->data)[a] - 32768;
134 134
135 } 135 }
136 136
diff --git a/apps/plugins/midi/guspat.h b/apps/plugins/midi/guspat.h
index c59cf7a3e3..ebb5f227d7 100644
--- a/apps/plugins/midi/guspat.h
+++ b/apps/plugins/midi/guspat.h
@@ -50,7 +50,7 @@ struct GWaveform
50 unsigned int scaleFactor; 50 unsigned int scaleFactor;
51 51
52 unsigned char * res; 52 unsigned char * res;
53 signed char * data; 53 int16_t * data;
54}; 54};
55 55
56 56
diff --git a/apps/plugins/midi/midiutil.c b/apps/plugins/midi/midiutil.c
index f960b72654..f4950408ab 100644
--- a/apps/plugins/midi/midiutil.c
+++ b/apps/plugins/midi/midiutil.c
@@ -114,9 +114,9 @@ unsigned char readChar(int file)
114 return buf[0]; 114 return buf[0];
115} 115}
116 116
117unsigned char * readData(int file, int len) 117void * readData(int file, int len)
118{ 118{
119 unsigned char * dat = malloc(len); 119 void * dat = malloc(len);
120 rb->read(file, dat, len); 120 rb->read(file, dat, len);
121 return dat; 121 return dat;
122} 122}
diff --git a/apps/plugins/midi/midiutil.h b/apps/plugins/midi/midiutil.h
index 62a31d0c65..cf3666c97f 100644
--- a/apps/plugins/midi/midiutil.h
+++ b/apps/plugins/midi/midiutil.h
@@ -148,7 +148,7 @@ int readTwoBytes(int file);
148int readFourBytes(int file); 148int readFourBytes(int file);
149int readVarData(int file); 149int readVarData(int file);
150int eof(int fd); 150int eof(int fd);
151unsigned char * readData(int file, int len); 151void * readData(int file, int len);
152 152
153#define malloc(n) my_malloc(n) 153#define malloc(n) my_malloc(n)
154void * my_malloc(int size); 154void * my_malloc(int size);
diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c
index 0ad7bb59f8..663565ecdb 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)
201 return 0; 201 return 0;
202} 202}
203 203
204#define getSample(s,wf) ((short *)(wf)->data)[s]
205
206void setPoint(struct SynthObject * so, int pt) ICODE_ATTR; 204void setPoint(struct SynthObject * so, int pt) ICODE_ATTR;
207void setPoint(struct SynthObject * so, int pt) 205void setPoint(struct SynthObject * so, int pt)
208{ 206{
@@ -269,6 +267,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i
269 register unsigned int cp_temp = so->cp; 267 register unsigned int cp_temp = so->cp;
270 268
271 wf = so->wf; 269 wf = so->wf;
270 const int16_t *sample_data = wf->data;
272 271
273 const unsigned int pan = chPan[so->ch]; 272 const unsigned int pan = chPan[so->ch];
274 const int volscale = so->volscale; 273 const int volscale = so->volscale;
@@ -309,7 +308,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i
309 cp_temp += so->delta; 308 cp_temp += so->delta;
310 } 309 }
311 310
312 s2 = getSample((cp_temp >> FRACTSIZE)+1, wf); 311 s2 = sample_data[(cp_temp >> FRACTSIZE)+1];
313 312
314 if(LIKELY(mode_mask28)) 313 if(LIKELY(mode_mask28))
315 { 314 {
@@ -319,7 +318,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i
319 if(UNLIKELY(mode_mask_looprev)) 318 if(UNLIKELY(mode_mask_looprev))
320 { 319 {
321 cp_temp += diff_loop; 320 cp_temp += diff_loop;
322 s2=getSample((cp_temp >> FRACTSIZE), wf); 321 s2 = sample_data[cp_temp >> FRACTSIZE];
323 } 322 }
324 else 323 else
325 { 324 {
@@ -333,7 +332,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i
333 if(UNLIKELY(!mode_mask24)) 332 if(UNLIKELY(!mode_mask24))
334 { 333 {
335 cp_temp -= diff_loop; 334 cp_temp -= diff_loop;
336 s2=getSample((cp_temp >> FRACTSIZE), wf); 335 s2 = sample_data[cp_temp >> FRACTSIZE];
337 } 336 }
338 else 337 else
339 { 338 {
@@ -346,7 +345,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i
346 if(UNLIKELY(cp_temp >= num_samples)) 345 if(UNLIKELY(cp_temp >= num_samples))
347 { 346 {
348 cp_temp -= so->delta; 347 cp_temp -= so->delta;
349 s2 = getSample((cp_temp >> FRACTSIZE)+1, wf); 348 s2 = sample_data[(cp_temp >> FRACTSIZE)+1];
350 349
351 if (!rampdown) /* stop voice */ 350 if (!rampdown) /* stop voice */
352 { 351 {
@@ -356,7 +355,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i
356 } 355 }
357 356
358 /* Better, working, linear interpolation */ 357 /* Better, working, linear interpolation */
359 s1=getSample((cp_temp >> FRACTSIZE), wf); 358 s1 = sample_data[cp_temp >> FRACTSIZE];
360 359
361 s1 +=((signed)((s2 - s1) * (cp_temp & ((1<<FRACTSIZE)-1)))>>FRACTSIZE); 360 s1 +=((signed)((s2 - s1) * (cp_temp & ((1<<FRACTSIZE)-1)))>>FRACTSIZE);
362 361