diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/midi/guspat.c | 12 | ||||
-rw-r--r-- | apps/plugins/midi/synth.c | 22 | ||||
-rw-r--r-- | apps/plugins/midi2wav.c | 37 | ||||
-rw-r--r-- | apps/plugins/viewers.config | 2 |
4 files changed, 48 insertions, 25 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 | ||
diff --git a/apps/plugins/midi2wav.c b/apps/plugins/midi2wav.c index 0b1659b1dd..3cf2866a12 100644 --- a/apps/plugins/midi2wav.c +++ b/apps/plugins/midi2wav.c | |||
@@ -19,15 +19,21 @@ | |||
19 | #define SAMPLE_RATE 48000 | 19 | #define SAMPLE_RATE 48000 |
20 | #define MAX_VOICES 100 | 20 | #define MAX_VOICES 100 |
21 | 21 | ||
22 | /* | 22 | |
23 | //Only define LOCAL_DSP on Simulator or else we're asking for trouble | ||
23 | #if defined(SIMULATOR) | 24 | #if defined(SIMULATOR) |
25 | //Enable this to write to the soundcard via a /dsv/dsp symlink in / | ||
26 | // #define LOCAL_DSP | ||
27 | #endif | ||
28 | |||
29 | |||
30 | #if defined(LOCAL_DSP) | ||
24 | // This is for writing to the DSP directly from the Simulator | 31 | // This is for writing to the DSP directly from the Simulator |
25 | #include <stdio.h> | 32 | #include <stdio.h> |
26 | #include <stdlib.h> | 33 | #include <stdlib.h> |
27 | #include <linux/soundcard.h> | 34 | #include <linux/soundcard.h> |
28 | #include <sys/ioctl.h> | 35 | #include <sys/ioctl.h> |
29 | #endif | 36 | #endif |
30 | */ | ||
31 | 37 | ||
32 | 38 | ||
33 | #include "../../plugin.h" | 39 | #include "../../plugin.h" |
@@ -40,9 +46,9 @@ | |||
40 | 46 | ||
41 | 47 | ||
42 | 48 | ||
43 | //#include "lib/xxx2wav.h" | 49 | #include "lib/xxx2wav.h" |
44 | 50 | ||
45 | int fd=-1; //File descriptor, for opening /dev/dsp and writing to it | 51 | int fd=-1; //File descriptor where the output is written |
46 | 52 | ||
47 | extern long tempo; //The sequencer keeps track of this | 53 | extern long tempo; //The sequencer keeps track of this |
48 | 54 | ||
@@ -93,14 +99,12 @@ int midimain(void * filename) | |||
93 | return -1; | 99 | return -1; |
94 | } | 100 | } |
95 | 101 | ||
96 | fd=rb->open("/dsp.raw", O_WRONLY|O_CREAT); | ||
97 | |||
98 | /* | ||
99 | //This lets you hear the music through the sound card if you are on Simulator | 102 | //This lets you hear the music through the sound card if you are on Simulator |
100 | //Make a symlink, archos/dsp.raw and make it point to /dev/dsp or whatever | 103 | //Make a symlink, archos/dsp.raw and make it point to /dev/dsp or whatever |
101 | //your sound device is. | 104 | //your sound device is. |
102 | 105 | ||
103 | #if defined(SIMULATOR) | 106 | #if defined(LOCAL_DSP) |
107 | fd=rb->open("/dsp.raw", O_WRONLY); | ||
104 | int arg, status; | 108 | int arg, status; |
105 | int bit, samp, ch; | 109 | int bit, samp, ch; |
106 | 110 | ||
@@ -119,8 +123,15 @@ int midimain(void * filename) | |||
119 | status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg); | 123 | status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg); |
120 | status = ioctl(fd, SOUND_PCM_READ_RATE, &arg); | 124 | status = ioctl(fd, SOUND_PCM_READ_RATE, &arg); |
121 | samp=arg; | 125 | samp=arg; |
126 | #else | ||
127 | file_info_struct file_info; | ||
128 | file_info.samplerate = 48000; | ||
129 | file_info.infile = fd; | ||
130 | file_info.channels = 2; | ||
131 | file_info.bitspersample = 16; | ||
132 | local_init("/miditest.tmp", "/miditest.wav", &file_info, rb); | ||
133 | fd = file_info.outfile; | ||
122 | #endif | 134 | #endif |
123 | */ | ||
124 | 135 | ||
125 | 136 | ||
126 | rb->splash(HZ/5, true, " START PLAYING "); | 137 | rb->splash(HZ/5, true, " START PLAYING "); |
@@ -190,6 +201,12 @@ int midimain(void * filename) | |||
190 | 201 | ||
191 | // unloadFile(mf); | 202 | // unloadFile(mf); |
192 | printf("\n"); | 203 | printf("\n"); |
193 | rb->close(fd); | 204 | |
205 | #if !defined(LOCAL_DSP) | ||
206 | |||
207 | close_wav(&file_info); | ||
208 | #else | ||
209 | rb->close(fd); | ||
210 | #endif | ||
194 | return 0; | 211 | return 0; |
195 | } | 212 | } |
diff --git a/apps/plugins/viewers.config b/apps/plugins/viewers.config index 9b30e20f7b..0b4f847322 100644 --- a/apps/plugins/viewers.config +++ b/apps/plugins/viewers.config | |||
@@ -17,4 +17,4 @@ ogg,vorbis2wav.rock, 00 00 00 00 00 00 | |||
17 | wv,wv2wav.rock, 00 00 00 00 00 00 | 17 | wv,wv2wav.rock, 00 00 00 00 00 00 |
18 | m3u,iriverify.rock,00 00 00 00 00 00 | 18 | m3u,iriverify.rock,00 00 00 00 00 00 |
19 | mpc,mpc2wav.rock, 00 00 00 00 00 00 | 19 | mpc,mpc2wav.rock, 00 00 00 00 00 00 |
20 | mid,midi2wav.rock, 01 20 30 40 50 60 | 20 | mid,midi2wav.rock, 20 70 70 3F 00 00 |