comparison decoders/timidity/instrum.c @ 455:cbc2a4ffeeec

* Added support for loading DLS format instruments: Timidity_LoadDLS(), Timidity_FreeDLS(), Timidity_LoadDLSSong() * Added Timidity_Init_NoConfig()
author hercules
date Fri, 26 Sep 2003 20:51:58 +0000
parents c98a34c00069
children
comparison
equal deleted inserted replaced
454:6bd7ca7d218b 455:cbc2a4ffeeec
38 38
39 #include "timidity.h" 39 #include "timidity.h"
40 #include "options.h" 40 #include "options.h"
41 #include "common.h" 41 #include "common.h"
42 #include "instrum.h" 42 #include "instrum.h"
43 #include "instrum_dls.h"
43 #include "resample.h" 44 #include "resample.h"
44 #include "tables.h" 45 #include "tables.h"
45 46
46 static void free_instrument(Instrument *ip) 47 static void free_instrument(Instrument *ip)
47 { 48 {
176 static char *patch_ext[] = PATCH_EXT_LIST; 177 static char *patch_ext[] = PATCH_EXT_LIST;
177 178
178 if (!name) return 0; 179 if (!name) return 0;
179 180
180 /* Open patch file */ 181 /* Open patch file */
181 if (!(rw=open_file(name))) 182 if ((rw=open_file(name)) == NULL)
182 { 183 {
183 noluck=1; 184 noluck=1;
184 /* Try with various extensions */ 185 /* Try with various extensions */
185 for (i=0; patch_ext[i]; i++) 186 for (i=0; patch_ext[i]; i++)
186 { 187 {
187 if (strlen(name)+strlen(patch_ext[i])<1024) 188 if (strlen(name)+strlen(patch_ext[i])<1024)
188 { 189 {
189 strcpy(tmp, name); 190 strcpy(tmp, name);
190 strcat(tmp, patch_ext[i]); 191 strcat(tmp, patch_ext[i]);
191 if ((rw=open_file(tmp))) 192 if ((rw=open_file(tmp)) != NULL)
192 { 193 {
193 noluck=0; 194 noluck=0;
194 break; 195 break;
195 } 196 }
196 } 197 }
271 READ_LONG(sp->loop_end); 272 READ_LONG(sp->loop_end);
272 READ_SHORT(sp->sample_rate); 273 READ_SHORT(sp->sample_rate);
273 READ_LONG(sp->low_freq); 274 READ_LONG(sp->low_freq);
274 READ_LONG(sp->high_freq); 275 READ_LONG(sp->high_freq);
275 READ_LONG(sp->root_freq); 276 READ_LONG(sp->root_freq);
277 sp->low_vel = 0;
278 sp->high_vel = 127;
276 SDL_RWseek(rw, 2, SEEK_CUR); /* Why have a "root frequency" and then 279 SDL_RWseek(rw, 2, SEEK_CUR); /* Why have a "root frequency" and then
277 * "tuning"?? */ 280 * "tuning"?? */
278 281
279 READ_CHAR(tmp[0]); 282 READ_CHAR(tmp[0]);
280 283
525 } 528 }
526 for (i=0; i<128; i++) 529 for (i=0; i<128; i++)
527 { 530 {
528 if (bank->instrument[i]==MAGIC_LOAD_INSTRUMENT) 531 if (bank->instrument[i]==MAGIC_LOAD_INSTRUMENT)
529 { 532 {
533 bank->instrument[i]=load_instrument_dls(song, dr, b, i);
534 if (bank->instrument[i])
535 {
536 continue;
537 }
530 if (!(bank->tone[i].name)) 538 if (!(bank->tone[i].name))
531 { 539 {
532 SNDDBG(("No instrument mapped to %s %d, program %d%s\n", 540 SNDDBG(("No instrument mapped to %s %d, program %d%s\n",
533 (dr)? "drum set" : "tone bank", b, i, 541 (dr)? "drum set" : "tone bank", b, i,
534 (b!=0) ? "" : " - this instrument will not be heard")); 542 (b!=0) ? "" : " - this instrument will not be heard"));