comparison decoders/timidity/timidity.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 1ba14a084531
children c66080364dff
comparison
equal deleted inserted replaced
454:6bd7ca7d218b 455:cbc2a4ffeeec
396 } 396 }
397 SDL_RWclose(rw); 397 SDL_RWclose(rw);
398 return 0; 398 return 0;
399 } 399 }
400 400
401 int Timidity_Init_NoConfig()
402 {
403 /* Allocate memory for the standard tonebank and drumset */
404 master_tonebank[0] = safe_malloc(sizeof(ToneBank));
405 memset(master_tonebank[0], 0, sizeof(ToneBank));
406 master_tonebank[0]->tone = safe_malloc(128 * sizeof(ToneBankElement));
407 memset(master_tonebank[0]->tone, 0, 128 * sizeof(ToneBankElement));
408
409 master_drumset[0] = safe_malloc(sizeof(ToneBank));
410 memset(master_drumset[0], 0, sizeof(ToneBank));
411 master_drumset[0]->tone = safe_malloc(128 * sizeof(ToneBankElement));
412 memset(master_drumset[0]->tone, 0, 128 * sizeof(ToneBankElement));
413
414 return 0;
415 }
416
401 int Timidity_Init() 417 int Timidity_Init()
402 { 418 {
403 /* !!! FIXME: This may be ugly, but slightly less so than requiring the 419 /* !!! FIXME: This may be ugly, but slightly less so than requiring the
404 * default search path to have only one element. I think. 420 * default search path to have only one element. I think.
405 * 421 *
412 #else 428 #else
413 add_to_pathlist("/usr/local/lib/timidity"); 429 add_to_pathlist("/usr/local/lib/timidity");
414 add_to_pathlist("/etc"); 430 add_to_pathlist("/etc");
415 #endif 431 #endif
416 432
417 /* Allocate memory for the standard tonebank and drumset */ 433 Timidity_Init_NoConfig();
418 master_tonebank[0] = safe_malloc(sizeof(ToneBank));
419 memset(master_tonebank[0], 0, sizeof(ToneBank));
420 master_tonebank[0]->tone = safe_malloc(128 * sizeof(ToneBankElement));
421 memset(master_tonebank[0]->tone, 0, 128 * sizeof(ToneBankElement));
422
423 master_drumset[0] = safe_malloc(sizeof(ToneBank));
424 memset(master_drumset[0], 0, sizeof(ToneBank));
425 master_drumset[0]->tone = safe_malloc(128 * sizeof(ToneBankElement));
426 memset(master_drumset[0]->tone, 0, 128 * sizeof(ToneBankElement));
427 434
428 return read_config_file(CONFIG_FILE); 435 return read_config_file(CONFIG_FILE);
429 } 436 }
430 437
431 MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio) 438 MidiSong *Timidity_LoadDLSSong(SDL_RWops *rw, DLS_Patches *patches, SDL_AudioSpec *audio)
432 { 439 {
433 MidiSong *song; 440 MidiSong *song;
434 Sint32 events; 441 Sint32 events;
435 int i; 442 int i;
436 443
438 return NULL; 445 return NULL;
439 446
440 /* Allocate memory for the song */ 447 /* Allocate memory for the song */
441 song = (MidiSong *)safe_malloc(sizeof(*song)); 448 song = (MidiSong *)safe_malloc(sizeof(*song));
442 memset(song, 0, sizeof(*song)); 449 memset(song, 0, sizeof(*song));
450 song->patches = patches;
443 451
444 for (i = 0; i < 128; i++) 452 for (i = 0; i < 128; i++)
445 { 453 {
446 if (master_tonebank[i]) 454 if (master_tonebank[i])
447 { 455 {
527 load_missing_instruments(song); 535 load_missing_instruments(song);
528 536
529 return(song); 537 return(song);
530 } 538 }
531 539
540 MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio)
541 {
542 return Timidity_LoadDLSSong(rw, NULL, audio);
543 }
544
532 void Timidity_FreeSong(MidiSong *song) 545 void Timidity_FreeSong(MidiSong *song)
533 { 546 {
534 int i; 547 int i;
535 548
536 free_instruments(song); 549 free_instruments(song);