summaryrefslogtreecommitdiff
path: root/apps/plugins/midi/synth.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/midi/synth.c')
-rw-r--r--apps/plugins/midi/synth.c38
1 files changed, 27 insertions, 11 deletions
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
52void initSynth(struct MIDIfile * mf, char * filename, char * drumConfig) 52int 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