summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/midi/midifile.c2
-rw-r--r--apps/plugins/midi/synth.c17
-rw-r--r--apps/plugins/midiplay.c68
3 files changed, 69 insertions, 18 deletions
diff --git a/apps/plugins/midi/midifile.c b/apps/plugins/midi/midifile.c
index 13887e4a98..11f81b1fd6 100644
--- a/apps/plugins/midi/midifile.c
+++ b/apps/plugins/midi/midifile.c
@@ -68,8 +68,6 @@ struct MIDIfile * loadFile(char * filename)
68 int track=0; 68 int track=0;
69 69
70 printf("\nFile has %d tracks.", mfload->numTracks); 70 printf("\nFile has %d tracks.", mfload->numTracks);
71 printf("Time division=%d\n", mfload->div);
72
73 71
74 while(! eof(file) && track < mfload->numTracks) 72 while(! eof(file) && track < mfload->numTracks)
75 { 73 {
diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c
index 2b70074158..2ec263da60 100644
--- a/apps/plugins/midi/synth.c
+++ b/apps/plugins/midi/synth.c
@@ -103,19 +103,20 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
103 drumUsed[getEvent(mf->tracks[a], ts)->d1]=1; 103 drumUsed[getEvent(mf->tracks[a], ts)->d1]=1;
104 104
105 if( (getEvent(mf->tracks[a], ts)->status & 0xF0) == MIDI_PRGM) 105 if( (getEvent(mf->tracks[a], ts)->status & 0xF0) == MIDI_PRGM)
106 {
107/* if(patchUsed[getEvent(mf->tracks[a], ts)->d1]==0)
108 printf("\nI need to load patch %d.", getEvent(mf->tracks[a], ts)->d1);
109*/
110 patchUsed[getEvent(mf->tracks[a], ts)->d1]=1; 106 patchUsed[getEvent(mf->tracks[a], ts)->d1]=1;
111 }
112 } 107 }
113 } 108 }
114 109
115 int file = rb->open(filename, O_RDONLY); 110 int file = rb->open(filename, O_RDONLY);
116 if(file == -1) 111 if(file < 0)
117 { 112 {
118 rb->splash(HZ*2, true, "Bad patch config.\nDid you install the patchset?"); 113 printf("\n");
114 printf("\nNo MIDI patchset found.");
115 printf("\nPlease install the instruments.");
116 printf("\nSee Rockbox page for more info.");
117
118 rb->splash(HZ*2, true, "No Instruments");
119 rb->splash(HZ*2, true, "No Instruments");
119 return -1; 120 return -1;
120 } 121 }
121 122
@@ -148,7 +149,7 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
148 rb->close(file); 149 rb->close(file);
149 150
150 file = rb->open(drumConfig, O_RDONLY); 151 file = rb->open(drumConfig, O_RDONLY);
151 if(file == -1) 152 if(file < 0)
152 { 153 {
153 rb->splash(HZ*2, true, "Bad drum config.\nDid you install the patchset?"); 154 rb->splash(HZ*2, true, "Bad drum config.\nDid you install the patchset?");
154 return -1; 155 return -1;
diff --git a/apps/plugins/midiplay.c b/apps/plugins/midiplay.c
index d420508473..70ffaa7d92 100644
--- a/apps/plugins/midiplay.c
+++ b/apps/plugins/midiplay.c
@@ -22,7 +22,7 @@ PLUGIN_HEADER
22 22
23#define FRACTSIZE 10 23#define FRACTSIZE 10
24#define SAMPLE_RATE 22050 // 44100 22050 11025 24#define SAMPLE_RATE 22050 // 44100 22050 11025
25#define MAX_VOICES 13 // Note: 24 midi channels is the minimum general midi 25#define MAX_VOICES 14 // Note: 24 midi channels is the minimum general midi
26 // spec implementation 26 // spec implementation
27#define BUF_SIZE 512 27#define BUF_SIZE 512
28#define NBUF 2 28#define NBUF 2
@@ -161,13 +161,12 @@ void get_more(unsigned char** start, size_t* size)
161 161
162int midimain(void * filename) 162int midimain(void * filename)
163{ 163{
164 int button; 164 int notesUsed = 0;
165 165 int a=0;
166 /* rb->splash(HZ/5, true, "LOADING MIDI"); */
167 printf("\nLoading file"); 166 printf("\nLoading file");
168 mf= loadFile(filename); 167 mf= loadFile(filename);
169 168
170 /* rb->splash(HZ/5, true, "LOADING PATCHES"); */ 169
171 if (initSynth(mf, "/.rockbox/patchset/patchset.cfg", "/.rockbox/patchset/drums.cfg") == -1) 170 if (initSynth(mf, "/.rockbox/patchset/patchset.cfg", "/.rockbox/patchset/drums.cfg") == -1)
172 return -1; 171 return -1;
173 172
@@ -191,14 +190,25 @@ int midimain(void * filename)
191 bpm=mf->div*1000000/tempo; 190 bpm=mf->div*1000000/tempo;
192 numberOfSamples=SAMPLE_RATE/bpm; 191 numberOfSamples=SAMPLE_RATE/bpm;
193 192
194 tick(); 193
194
195 /* Skip over any junk in the beginning of the file, so start playing */
196 /* after the first note event */
197 do
198 {
199 notesUsed = 0;
200 for(a=0; a<MAX_VOICES; a++)
201 if(voices[a].isUsed == 1)
202 notesUsed++;
203 tick();
204 } while(notesUsed == 0);
195 205
196 synthbuf(); 206 synthbuf();
197#ifndef SIMULATOR 207#ifndef SIMULATOR
198 rb->pcm_play_data(&get_more, NULL, 0); 208 rb->pcm_play_data(&get_more, NULL, 0);
199#endif 209#endif
200 210
201 button=rb->button_status(); 211 int vol=0;
202 212
203 while(!quit) 213 while(!quit)
204 { 214 {
@@ -206,7 +216,49 @@ int midimain(void * filename)
206 synthbuf(); 216 synthbuf();
207 #endif 217 #endif
208 rb->yield(); 218 rb->yield();
209 if(rb->button_status()!=button) quit=1; 219
220 /* Code taken from Oscilloscope plugin */
221 switch(rb->button_get(false))
222 {
223 case BUTTON_UP:
224 case BUTTON_UP | BUTTON_REPEAT:
225 vol = rb->global_settings->volume;
226 if (vol < rb->sound_max(SOUND_VOLUME))
227 {
228 vol++;
229 rb->sound_set(SOUND_VOLUME, vol);
230 rb->global_settings->volume = vol;
231 }
232 break;
233
234 case BUTTON_DOWN:
235 case BUTTON_DOWN | BUTTON_REPEAT:
236 vol = rb->global_settings->volume;
237 if (vol > rb->sound_min(SOUND_VOLUME))
238 {
239 vol--;
240 rb->sound_set(SOUND_VOLUME, vol);
241 rb->global_settings->volume = vol;
242 }
243 break;
244
245 case BUTTON_RIGHT:
246 {
247 /* Skip 3 seconds */
248 /* Should skip length be retrieved from the RB settings? */
249 int samp = 3*SAMPLE_RATE;
250 int tickCount = samp / numberOfSamples;
251 int a=0;
252 for(a=0; a<tickCount; a++)
253 tick();
254 break;
255 }
256
257 case BUTTON_OFF:
258 quit=1;
259 }
260
261
210 } 262 }
211 263
212 return 0; 264 return 0;