diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/midi/guspat.c | 8 | ||||
-rw-r--r-- | apps/plugins/midi/guspat.h | 2 | ||||
-rw-r--r-- | apps/plugins/midi/midifile.c | 7 | ||||
-rw-r--r-- | apps/plugins/midi/midiutil.c | 42 | ||||
-rw-r--r-- | apps/plugins/midi/sequencer.c | 2 | ||||
-rw-r--r-- | apps/plugins/midi/synth.c | 38 | ||||
-rw-r--r-- | apps/plugins/midi2wav.c | 71 | ||||
-rw-r--r-- | apps/plugins/viewers.config | 1 |
8 files changed, 114 insertions, 57 deletions
diff --git a/apps/plugins/midi/guspat.c b/apps/plugins/midi/guspat.c index f0f1effd2a..675d6ffe3d 100644 --- a/apps/plugins/midi/guspat.c +++ b/apps/plugins/midi/guspat.c | |||
@@ -94,6 +94,14 @@ struct GPatch * gusload(char * filename) | |||
94 | 94 | ||
95 | int file = rb->open(filename, O_RDONLY); | 95 | int file = rb->open(filename, O_RDONLY); |
96 | 96 | ||
97 | if(file == -1) | ||
98 | { | ||
99 | char message[50]; | ||
100 | snprintf(message, 50, "Error opening %s", filename); | ||
101 | rb->splash(HZ*2, true, message); | ||
102 | return NULL; | ||
103 | } | ||
104 | |||
97 | gp->header=readData(file, 12); | 105 | gp->header=readData(file, 12); |
98 | gp->gravisid=readData(file, 10); | 106 | gp->gravisid=readData(file, 10); |
99 | gp->desc=readData(file, 60); | 107 | gp->desc=readData(file, 60); |
diff --git a/apps/plugins/midi/guspat.h b/apps/plugins/midi/guspat.h index 5007c4d2ca..75bdb2ca01 100644 --- a/apps/plugins/midi/guspat.h +++ b/apps/plugins/midi/guspat.h | |||
@@ -17,7 +17,7 @@ | |||
17 | ****************************************************************************/ | 17 | ****************************************************************************/ |
18 | 18 | ||
19 | //This came from one of the Gravis documents | 19 | //This came from one of the Gravis documents |
20 | const static unsigned int gustable[]= | 20 | static const unsigned int gustable[]= |
21 | { | 21 | { |
22 | 8175, 8661, 9177, 9722, 10300, 10913, 11562, 12249, 12978, 13750, 14567, 15433, | 22 | 8175, 8661, 9177, 9722, 10300, 10913, 11562, 12249, 12978, 13750, 14567, 15433, |
23 | 16351, 17323, 18354, 19445, 20601, 21826, 23124, 24499, 25956, 27500, 29135, 30867, | 23 | 16351, 17323, 18354, 19445, 20601, 21826, 23124, 24499, 25956, 27500, 29135, 30867, |
diff --git a/apps/plugins/midi/midifile.c b/apps/plugins/midi/midifile.c index 08efb73529..c786b8e5a6 100644 --- a/apps/plugins/midi/midifile.c +++ b/apps/plugins/midi/midifile.c | |||
@@ -185,7 +185,6 @@ struct Track * readTrack(int file) | |||
185 | trk->pos = 0; | 185 | trk->pos = 0; |
186 | trk->delta = 0; | 186 | trk->delta = 0; |
187 | 187 | ||
188 | int len=0; | ||
189 | int numEvents=0; | 188 | int numEvents=0; |
190 | 189 | ||
191 | int pos = rb->lseek(file, 0, SEEK_CUR); | 190 | int pos = rb->lseek(file, 0, SEEK_CUR); |
@@ -269,6 +268,8 @@ int readVarData(int file) | |||
269 | return(value); | 268 | return(value); |
270 | } | 269 | } |
271 | 270 | ||
271 | |||
272 | /* | ||
272 | //This function should not be needed because we | 273 | //This function should not be needed because we |
273 | //can just release the whole memory buffer at once | 274 | //can just release the whole memory buffer at once |
274 | void unloadFile(struct MIDIfile * mf) | 275 | void unloadFile(struct MIDIfile * mf) |
@@ -296,10 +297,10 @@ void unloadFile(struct MIDIfile * mf) | |||
296 | } | 297 | } |
297 | free(mf); //Unload the main struct | 298 | free(mf); //Unload the main struct |
298 | } | 299 | } |
299 | 300 | */ | |
300 | void bail(const char * err) | 301 | void bail(const char * err) |
301 | { | 302 | { |
302 | printf("\nERROR: %s\n", err); | 303 | rb->splash(HZ*3, true, err); |
303 | exit(0); | 304 | exit(0); |
304 | } | 305 | } |
305 | 306 | ||
diff --git a/apps/plugins/midi/midiutil.c b/apps/plugins/midi/midiutil.c index 0ab5a35a78..41a02ae682 100644 --- a/apps/plugins/midi/midiutil.c +++ b/apps/plugins/midi/midiutil.c | |||
@@ -40,16 +40,18 @@ | |||
40 | #define CTRL_PANNING 10 | 40 | #define CTRL_PANNING 10 |
41 | #define CHANNEL 1 | 41 | #define CHANNEL 1 |
42 | 42 | ||
43 | 43 | //Most of these are deprecated.. rampdown is used, maybe one other one too | |
44 | #define STATE_ATTACK 1 | 44 | #define STATE_ATTACK 1 |
45 | #define STATE_DECAY 2 | 45 | #define STATE_DECAY 2 |
46 | #define STATE_SUSTAIN 3 | 46 | #define STATE_SUSTAIN 3 |
47 | #define STATE_RELEASE 4 | 47 | #define STATE_RELEASE 4 |
48 | #define STATE_RAMPDOWN 5 | 48 | #define STATE_RAMPDOWN 5 |
49 | 49 | ||
50 | //Loop states | ||
50 | #define STATE_LOOPING 7 | 51 | #define STATE_LOOPING 7 |
51 | #define STATE_NONLOOPING 8 | 52 | #define STATE_NONLOOPING 8 |
52 | 53 | ||
54 | //Various bits in the GUS mode byte | ||
53 | #define LOOP_ENABLED 4 | 55 | #define LOOP_ENABLED 4 |
54 | #define LOOP_PINGPONG 8 | 56 | #define LOOP_PINGPONG 8 |
55 | #define LOOP_REVERSE 16 | 57 | #define LOOP_REVERSE 16 |
@@ -65,7 +67,8 @@ unsigned char chVol[16]; //Channel volume | |||
65 | unsigned char chPanLeft[16]; //Channel panning | 67 | unsigned char chPanLeft[16]; //Channel panning |
66 | unsigned char chPanRight[16]; | 68 | unsigned char chPanRight[16]; |
67 | unsigned char chPat[16]; //Channel patch | 69 | unsigned char chPat[16]; //Channel patch |
68 | unsigned char chPW[16]; //Channel pitch wheel, MSB | 70 | unsigned char chPW[16]; //Channel pitch wheel, MSB only |
71 | |||
69 | 72 | ||
70 | struct GPatch * gusload(char *); | 73 | struct GPatch * gusload(char *); |
71 | struct GPatch * patchSet[128]; | 74 | struct GPatch * patchSet[128]; |
@@ -118,8 +121,19 @@ struct MIDIfile | |||
118 | int numPatches; | 121 | int numPatches; |
119 | }; | 122 | }; |
120 | 123 | ||
121 | void *my_malloc(int size); | ||
122 | 124 | ||
125 | |||
126 | void sendEvent(struct Event * ev); | ||
127 | int tick(struct MIDIfile * mf); | ||
128 | inline void setPoint(struct SynthObject * so, int pt); | ||
129 | struct Event * getEvent(struct Track * tr, int evNum); | ||
130 | int readTwoBytes(int file); | ||
131 | int readFourBytes(int file); | ||
132 | int readVarData(int file); | ||
133 | int midimain(void * filename); | ||
134 | |||
135 | |||
136 | //Rick's code | ||
123 | void *alloc(int size) | 137 | void *alloc(int size) |
124 | { | 138 | { |
125 | static char *offset = NULL; | 139 | static char *offset = NULL; |
@@ -143,7 +157,7 @@ void *alloc(int size) | |||
143 | totalSize -= size + 4; | 157 | totalSize -= size + 4; |
144 | return ret; | 158 | return ret; |
145 | } | 159 | } |
146 | 160 | /* | |
147 | void *ralloc(char *offset, int len) | 161 | void *ralloc(char *offset, int len) |
148 | { | 162 | { |
149 | int size; | 163 | int size; |
@@ -175,18 +189,13 @@ void *ralloc(char *offset, int len) | |||
175 | 189 | ||
176 | return ret; | 190 | return ret; |
177 | } | 191 | } |
178 | 192 | */ | |
179 | 193 | ||
180 | void * allocate(int size) | 194 | void * allocate(int size) |
181 | { | 195 | { |
182 | return alloc(size); | 196 | return alloc(size); |
183 | } | 197 | } |
184 | 198 | ||
185 | void sendEvent(struct Event * ev); | ||
186 | int tick(struct MIDIfile * mf); | ||
187 | inline void setPoint(struct SynthObject * so, int pt); | ||
188 | struct Event * getEvent(struct Track * tr, int evNum); | ||
189 | |||
190 | unsigned char readChar(int file) | 199 | unsigned char readChar(int file) |
191 | { | 200 | { |
192 | char buf[2]; | 201 | char buf[2]; |
@@ -211,11 +220,9 @@ int eof(int fd) | |||
211 | return size+1 == rb->lseek(fd, 0, SEEK_CUR); | 220 | return size+1 == rb->lseek(fd, 0, SEEK_CUR); |
212 | } | 221 | } |
213 | 222 | ||
214 | void printf(char *fmt, ...) {} | 223 | void printf(char *fmt, ...) {fmt=fmt; } |
215 | |||
216 | //#define my_malloc(a) malloc(a) | ||
217 | |||
218 | 224 | ||
225 | /* | ||
219 | void *audio_bufferbase; | 226 | void *audio_bufferbase; |
220 | void *audio_bufferpointer; | 227 | void *audio_bufferpointer; |
221 | unsigned int audio_buffer_free; | 228 | unsigned int audio_buffer_free; |
@@ -252,11 +259,8 @@ void setmallocpos(void *pointer) | |||
252 | audio_bufferpointer = pointer; | 259 | audio_bufferpointer = pointer; |
253 | audio_buffer_free = audio_bufferpointer - audio_bufferbase; | 260 | audio_buffer_free = audio_bufferpointer - audio_bufferbase; |
254 | } | 261 | } |
255 | 262 | */ | |
256 | void exit(int code) | 263 | void exit(int code) |
257 | { | 264 | { |
265 | code = code; //Stub function, kill warning for now | ||
258 | } | 266 | } |
259 | |||
260 | void free(void * ptr) | ||
261 | { | ||
262 | } \ No newline at end of file | ||
diff --git a/apps/plugins/midi/sequencer.c b/apps/plugins/midi/sequencer.c index fb98fdaf51..f7c6f30376 100644 --- a/apps/plugins/midi/sequencer.c +++ b/apps/plugins/midi/sequencer.c | |||
@@ -242,7 +242,7 @@ void sendEvent(struct Event * ev) | |||
242 | int tick(struct MIDIfile * mf) | 242 | int tick(struct MIDIfile * mf) |
243 | { | 243 | { |
244 | if(mf==NULL) | 244 | if(mf==NULL) |
245 | return; | 245 | return 0; |
246 | 246 | ||
247 | int a=0; | 247 | int a=0; |
248 | int tracksAdv=0; | 248 | int tracksAdv=0; |
diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c index 0d07ed91d0..86cb43483a 100644 --- a/apps/plugins/midi/synth.c +++ b/apps/plugins/midi/synth.c | |||
@@ -49,7 +49,7 @@ void readTextBlock(int file, char * buf) | |||
49 | 49 | ||
50 | //Filename is the name of the config file | 50 | //Filename is the name of the config file |
51 | //The MIDI file should have been loaded at this point | 51 | //The MIDI file should have been loaded at this point |
52 | void initSynth(struct MIDIfile * mf, char * filename, char * drumConfig) | 52 | int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig) |
53 | { | 53 | { |
54 | char patchUsed[128]; | 54 | char patchUsed[128]; |
55 | char drumUsed[128]; | 55 | char drumUsed[128]; |
@@ -92,8 +92,8 @@ void initSynth(struct MIDIfile * mf, char * filename, char * drumConfig) | |||
92 | if(mf->tracks[a] == NULL) | 92 | if(mf->tracks[a] == NULL) |
93 | { | 93 | { |
94 | printf("\nNULL TRACK !!!"); | 94 | printf("\nNULL TRACK !!!"); |
95 | exit(1); | 95 | rb->splash(HZ*2, true, "Null Track in loader."); |
96 | return; | 96 | return -1; |
97 | } | 97 | } |
98 | 98 | ||
99 | for(ts=0; ts<mf->tracks[a]->numEvents; ts++) | 99 | for(ts=0; ts<mf->tracks[a]->numEvents; ts++) |
@@ -112,29 +112,43 @@ void initSynth(struct MIDIfile * mf, char * filename, char * drumConfig) | |||
112 | } | 112 | } |
113 | 113 | ||
114 | int file = rb->open(filename, O_RDONLY); | 114 | int file = rb->open(filename, O_RDONLY); |
115 | if(file == -1) | ||
116 | { | ||
117 | rb->splash(HZ*2, true, "Bad patch config.\nDid you install the patchset?"); | ||
118 | return -1; | ||
119 | } | ||
115 | 120 | ||
116 | char name[30]; | 121 | char name[40]; |
117 | char fn[30]; | 122 | char fn[40]; |
118 | 123 | ||
119 | //Scan our config file and load the right patches as needed | 124 | //Scan our config file and load the right patches as needed |
120 | int c = 0; | 125 | int c = 0; |
121 | rb->snprintf(name, 30, ""); | 126 | rb->snprintf(name, 40, ""); |
122 | for(a=0; a<128; a++) | 127 | for(a=0; a<128; a++) |
123 | { | 128 | { |
124 | while(readChar(file)!=' ' && !eof(file)); | 129 | while(readChar(file)!=' ' && !eof(file)); |
125 | readTextBlock(file, name); | 130 | readTextBlock(file, name); |
126 | 131 | ||
127 | rb->snprintf(fn, 30, "/patchset/%s.pat", name); | 132 | rb->snprintf(fn, 40, "/.rockbox/patchset/%s.pat", name); |
128 | printf("\nLOADING: <%s> ", fn); | 133 | printf("\nLOADING: <%s> ", fn); |
134 | |||
129 | if(patchUsed[a]==1) | 135 | if(patchUsed[a]==1) |
130 | patchSet[a]=gusload(fn); | 136 | patchSet[a]=gusload(fn); |
131 | 137 | ||
138 | // if(patchSet[a] == NULL) | ||
139 | // return -1; | ||
140 | |||
132 | while((c != '\n')) | 141 | while((c != '\n')) |
133 | c = readChar(file); | 142 | c = readChar(file); |
134 | } | 143 | } |
135 | rb->close(file); | 144 | rb->close(file); |
136 | 145 | ||
137 | file = rb->open(drumConfig, O_RDONLY); | 146 | file = rb->open(drumConfig, O_RDONLY); |
147 | if(file == -1) | ||
148 | { | ||
149 | rb->splash(HZ*2, true, "Bad drum config.\nDid you install the patchset?"); | ||
150 | return -1; | ||
151 | } | ||
138 | 152 | ||
139 | //Scan our config file and load the drum data | 153 | //Scan our config file and load the drum data |
140 | int idx=0; | 154 | int idx=0; |
@@ -143,7 +157,7 @@ void initSynth(struct MIDIfile * mf, char * filename, char * drumConfig) | |||
143 | { | 157 | { |
144 | readTextBlock(file, number); | 158 | readTextBlock(file, number); |
145 | readTextBlock(file, name); | 159 | readTextBlock(file, name); |
146 | rb->snprintf(fn, 30, "/patchset/%s.pat", name); | 160 | rb->snprintf(fn, 40, "/.rockbox/patchset/%s.pat", name); |
147 | 161 | ||
148 | idx = rb->atoi(number); | 162 | idx = rb->atoi(number); |
149 | if(idx == 0) | 163 | if(idx == 0) |
@@ -151,13 +165,15 @@ void initSynth(struct MIDIfile * mf, char * filename, char * drumConfig) | |||
151 | 165 | ||
152 | if(drumUsed[idx]==1) | 166 | if(drumUsed[idx]==1) |
153 | drumSet[idx]=gusload(fn); | 167 | drumSet[idx]=gusload(fn); |
168 | |||
169 | // if(drumSet[idx] == NULL) | ||
170 | // return -1; | ||
171 | |||
154 | while((c != '\n') && (c != 255) && (!eof(file))) | 172 | while((c != '\n') && (c != 255) && (!eof(file))) |
155 | { | ||
156 | printf("loop"); | ||
157 | c = readChar(file); | 173 | c = readChar(file); |
158 | } | ||
159 | } | 174 | } |
160 | rb->close(file); | 175 | rb->close(file); |
176 | return 0; | ||
161 | } | 177 | } |
162 | 178 | ||
163 | 179 | ||
diff --git a/apps/plugins/midi2wav.c b/apps/plugins/midi2wav.c index f8368535d1..0b1659b1dd 100644 --- a/apps/plugins/midi2wav.c +++ b/apps/plugins/midi2wav.c | |||
@@ -19,13 +19,17 @@ | |||
19 | #define SAMPLE_RATE 48000 | 19 | #define SAMPLE_RATE 48000 |
20 | #define MAX_VOICES 100 | 20 | #define MAX_VOICES 100 |
21 | 21 | ||
22 | /* This is for writing to the DSP directly from the Simulator | 22 | /* |
23 | #if defined(SIMULATOR) | ||
24 | // This is for writing to the DSP directly from the Simulator | ||
23 | #include <stdio.h> | 25 | #include <stdio.h> |
24 | #include <stdlib.h> | 26 | #include <stdlib.h> |
25 | #include <linux/soundcard.h> | 27 | #include <linux/soundcard.h> |
26 | #include <sys/ioctl.h> | 28 | #include <sys/ioctl.h> |
29 | #endif | ||
27 | */ | 30 | */ |
28 | 31 | ||
32 | |||
29 | #include "../../plugin.h" | 33 | #include "../../plugin.h" |
30 | #include "midi/midiutil.c" | 34 | #include "midi/midiutil.c" |
31 | #include "midi/guspat.h" | 35 | #include "midi/guspat.h" |
@@ -47,23 +51,56 @@ struct plugin_api * rb; | |||
47 | 51 | ||
48 | 52 | ||
49 | 53 | ||
54 | |||
50 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | 55 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) |
51 | { | 56 | { |
52 | TEST_PLUGIN_API(api); | 57 | TEST_PLUGIN_API(api); |
53 | (void)parameter; | 58 | rb = api; |
54 | rb = api; | 59 | TEST_PLUGIN_API(api); |
55 | rb->splash(HZ*2, true, "MIDI"); | 60 | (void)parameter; |
56 | midimain(); | 61 | rb = api; |
57 | rb->splash(HZ*2, true, "FINISHED PLAYING"); | 62 | |
58 | return PLUGIN_OK; | 63 | if(parameter == NULL) |
64 | { | ||
65 | rb->splash(HZ*2, true, " Play .MID file "); | ||
66 | return PLUGIN_OK; | ||
67 | } | ||
68 | rb->splash(HZ, true, parameter); | ||
69 | if(midimain(parameter) == -1) | ||
70 | { | ||
71 | return PLUGIN_ERROR; | ||
72 | } | ||
73 | rb->splash(HZ*3, true, "FINISHED PLAYING"); | ||
74 | return PLUGIN_OK; | ||
59 | } | 75 | } |
60 | 76 | ||
61 | 77 | ||
62 | int midimain() | 78 | int midimain(void * filename) |
63 | { | 79 | { |
64 | rb->splash(HZ*2, true, "OPENED DSP"); | 80 | |
81 | printf("\nHello.\n"); | ||
82 | |||
83 | rb->splash(HZ/5, true, "LOADING MIDI"); | ||
84 | |||
85 | struct MIDIfile * mf = loadFile(filename); | ||
86 | long bpm, nsmp, l; | ||
87 | |||
88 | int bp=0; | ||
89 | |||
90 | rb->splash(HZ/5, true, "LOADING PATCHES"); | ||
91 | if (initSynth(mf, "/.rockbox/patchset/patchset.cfg", "/.rockbox/patchset/drums.cfg") == -1) | ||
92 | { | ||
93 | return -1; | ||
94 | } | ||
95 | |||
65 | fd=rb->open("/dsp.raw", O_WRONLY|O_CREAT); | 96 | fd=rb->open("/dsp.raw", O_WRONLY|O_CREAT); |
97 | |||
66 | /* | 98 | /* |
99 | //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 | ||
101 | //your sound device is. | ||
102 | |||
103 | #if defined(SIMULATOR) | ||
67 | int arg, status; | 104 | int arg, status; |
68 | int bit, samp, ch; | 105 | int bit, samp, ch; |
69 | 106 | ||
@@ -82,24 +119,14 @@ int midimain() | |||
82 | status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg); | 119 | status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg); |
83 | status = ioctl(fd, SOUND_PCM_READ_RATE, &arg); | 120 | status = ioctl(fd, SOUND_PCM_READ_RATE, &arg); |
84 | samp=arg; | 121 | samp=arg; |
122 | #endif | ||
85 | */ | 123 | */ |
86 | 124 | ||
87 | printf("\nHello.\n"); | ||
88 | // initSound(); //Open the computer's sound card | ||
89 | int a=0; | ||
90 | 125 | ||
91 | rb->splash(HZ*2, true, "LOADING MIDI"); | 126 | rb->splash(HZ/5, true, " START PLAYING "); |
92 | 127 | ||
93 | struct MIDIfile * mf = loadFile("/test.mid"); | ||
94 | 128 | ||
95 | rb->splash(HZ*2, true, "LOADED MIDI"); | ||
96 | long bpm, nsmp, l; | ||
97 | |||
98 | int bp=0; | ||
99 | 129 | ||
100 | rb->splash(HZ*2, true, "LOADING PATCHES"); | ||
101 | initSynth(mf, "/iriver2.cfg", "/drums.cfg"); //Initialize the MIDI syntehsizer | ||
102 | rb->splash(HZ*2, true, "START PLAYING"); | ||
103 | 130 | ||
104 | signed char buf[3000]; | 131 | signed char buf[3000]; |
105 | 132 | ||
diff --git a/apps/plugins/viewers.config b/apps/plugins/viewers.config index dcb7ca126f..9b30e20f7b 100644 --- a/apps/plugins/viewers.config +++ b/apps/plugins/viewers.config | |||
@@ -17,3 +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 | ||