summaryrefslogtreecommitdiff
path: root/apps/plugins/midi
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/midi')
-rw-r--r--apps/plugins/midi/guspat.c12
-rw-r--r--apps/plugins/midi/synth.c22
2 files changed, 20 insertions, 14 deletions
diff --git a/apps/plugins/midi/guspat.c b/apps/plugins/midi/guspat.c
index 6508591f74..f674b64caa 100644
--- a/apps/plugins/midi/guspat.c
+++ b/apps/plugins/midi/guspat.c
@@ -66,6 +66,18 @@ struct GWaveform * loadWaveform(int file)
66 wav->res=readData(file, 36); 66 wav->res=readData(file, 36);
67 wav->data=readData(file, wav->wavSize); 67 wav->data=readData(file, wav->wavSize);
68 68
69 int a=0;
70
71 //If we have a 16 bit waveform
72 if(wav->mode & 1 && (wav->mode & 2))
73 {
74 for(a=0; a<wav->wavSize; a+=2) //Convert it to
75 {
76 //wav->data[a]=wav->data[a]; //+((wav->mode & 2) << 6);
77 wav->data[a|1]=wav->data[(a)|1]+(1 << 7);
78 }
79 }
80
69 return wav; 81 return wav;
70} 82}
71 83
diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c
index 86cb43483a..99864e557e 100644
--- a/apps/plugins/midi/synth.c
+++ b/apps/plugins/midi/synth.c
@@ -186,10 +186,7 @@ inline signed short int getSample(struct GWaveform * wf, unsigned int s)
186 { 186 {
187 187
188 if(s<<1 >= wf->wavSize) 188 if(s<<1 >= wf->wavSize)
189 {
190 // printf("\nSAMPLE OUT OF RANGE: s=%d 2s=%d ws=%d", s, 2*s, wf->wavSize);
191 return 0; 189 return 0;
192 }
193 190
194 191
195 /* 192 /*
@@ -198,14 +195,14 @@ inline signed short int getSample(struct GWaveform * wf, unsigned int s)
198 */ 195 */
199 196
200 197
201 //If they are unsigned, convert them to signed 198 //Sign conversion moved into guspat.c
202 //or was it the other way around. Whatever, it works 199 unsigned char b1=wf->data[s<<1]; //+((wf->mode & 2) << 6);
203 unsigned char b1=wf->data[s<<1]+((wf->mode & 2) << 6); 200 unsigned char b2=wf->data[(s<<1)|1]; //+((wf->mode & 2) << 6);
204 unsigned char b2=wf->data[(s<<1)|1]+((wf->mode & 2) << 6); 201 return (b1 | (b2<<8)) ;
205 return (b1 | (b2<<8));
206 } 202 }
207 else 203 else
208 { //8-bit samples 204 { //8-bit samples
205 //Do we even have anything 8-bit in our set?
209 unsigned char b1=wf->data[s]+((wf->mode & 2) << 6); 206 unsigned char b1=wf->data[s]+((wf->mode & 2) << 6);
210 return b1<<8; 207 return b1<<8;
211 } 208 }
@@ -237,10 +234,6 @@ inline void setPoint(struct SynthObject * so, int pt)
237 so->curPoint = pt; 234 so->curPoint = pt;
238 235
239 int r=0; 236 int r=0;
240
241
242
243
244 int rate = so->wf->envRate[pt]; 237 int rate = so->wf->envRate[pt];
245 238
246 r=3-((rate>>6) & 0x3); // Some blatant Timidity code for rate conversion... 239 r=3-((rate>>6) & 0x3); // Some blatant Timidity code for rate conversion...
@@ -256,7 +249,7 @@ inline void setPoint(struct SynthObject * so, int pt)
256 default this to 10, and maybe later have an option to set it to 9 249 default this to 10, and maybe later have an option to set it to 9
257 for longer decays. 250 for longer decays.
258 */ 251 */
259 so->curRate = r<<9; 252 so->curRate = r<<10;
260 253
261 254
262 so->targetOffset = so->wf->envOffset[pt]<<(20); 255 so->targetOffset = so->wf->envOffset[pt]<<(20);
@@ -372,6 +365,7 @@ inline signed short int synthVoice(int v)
372 if(so->curOffset < 0) 365 if(so->curOffset < 0)
373 so->isUsed=0; //This is OK 366 so->isUsed=0; //This is OK
374 367
368
375 s = s * (so->curOffset >> 22); 369 s = s * (so->curOffset >> 22);
376 s = s>>6; 370 s = s>>6;
377 371