comparison minijss/jloadxm.c @ 1175:165c673ee012

Rename a variable.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 05 Mar 2015 09:32:58 +0200
parents 14ac28580059
children afdbf62ce8ad
comparison
equal deleted inserted replaced
1174:14ac28580059 1175:165c673ee012
492 static int jssXMLoadExtInstrument(DMResource *inFile, int ninst, JSSModule *module) 492 static int jssXMLoadExtInstrument(DMResource *inFile, int ninst, JSSModule *module)
493 { 493 {
494 XMInstrument1 xmI1; 494 XMInstrument1 xmI1;
495 off_t remainder, pos = dmftell(inFile); 495 off_t remainder, pos = dmftell(inFile);
496 int xmConvTable[XM_MaxInstruments + 1]; 496 int xmConvTable[XM_MaxInstruments + 1];
497 JSSExtInstrument *pEInst; 497 JSSExtInstrument *einst;
498 XMInstrument2 xmI2; 498 XMInstrument2 xmI2;
499 int i, nsample, ret; 499 int i, nsample, ret;
500 500
501 // Get instrument header #1 501 // Get instrument header #1
502 if (!dmf_read_le32(inFile, &xmI1.headSize) || 502 if (!dmf_read_le32(inFile, &xmI1.headSize) ||
520 } 520 }
521 return DMERR_OK; 521 return DMERR_OK;
522 } 522 }
523 523
524 // Allocate instrument 524 // Allocate instrument
525 if ((pEInst = jssAllocateExtInstrument()) == NULL) 525 if ((einst = jssAllocateExtInstrument()) == NULL)
526 { 526 {
527 JSSERROR(DMERR_MALLOC, DMERR_MALLOC, 527 JSSERROR(DMERR_MALLOC, DMERR_MALLOC,
528 "Could not allocate extended instrument structure #%d\n", ninst); 528 "Could not allocate extended instrument structure #%d\n", ninst);
529 } 529 }
530 530
531 module->extInstruments[ninst] = pEInst; 531 module->extInstruments[ninst] = einst;
532 532
533 // Get instrument header #2 533 // Get instrument header #2
534 if (!dmf_read_le32(inFile, &xmI2.headSize) || 534 if (!dmf_read_le32(inFile, &xmI2.headSize) ||
535 !dmf_read_str(inFile, &xmI2.sNumForNotes, sizeof(xmI2.sNumForNotes))) 535 !dmf_read_str(inFile, &xmI2.sNumForNotes, sizeof(xmI2.sNumForNotes)))
536 { 536 {
574 dmfseek(inFile, remainder, SEEK_CUR); 574 dmfseek(inFile, remainder, SEEK_CUR);
575 } 575 }
576 576
577 // Check and convert all ext instrument information 577 // Check and convert all ext instrument information
578 #ifndef JSS_LIGHT 578 #ifndef JSS_LIGHT
579 pEInst->desc = jssASCIItoStr(xmI1.instName, 0, sizeof(xmI1.instName)); 579 einst->desc = jssASCIItoStr(xmI1.instName, 0, sizeof(xmI1.instName));
580 #endif 580 #endif
581 jssXMConvertEnvelope(&pEInst->volumeEnv, &xmI2.volumeEnv, "vol", ninst); 581 jssXMConvertEnvelope(&einst->volumeEnv, &xmI2.volumeEnv, "vol", ninst);
582 jssXMConvertEnvelope(&pEInst->panningEnv, &xmI2.panningEnv, "pan", ninst); 582 jssXMConvertEnvelope(&einst->panningEnv, &xmI2.panningEnv, "pan", ninst);
583 583
584 switch (xmI2.vibratoType) 584 switch (xmI2.vibratoType)
585 { 585 {
586 case 0: pEInst->vibratoType = jvibSine; break; 586 case 0: einst->vibratoType = jvibSine; break;
587 case 1: pEInst->vibratoType = jvibRamp; break; 587 case 1: einst->vibratoType = jvibRamp; break;
588 case 2: pEInst->vibratoType = jvibSquare; break; 588 case 2: einst->vibratoType = jvibSquare; break;
589 case 3: pEInst->vibratoType = jvibRandom; break; 589 case 3: einst->vibratoType = jvibRandom; break;
590 default: 590 default:
591 pEInst->vibratoType = jvibSine; 591 einst->vibratoType = jvibSine;
592 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, 592 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA,
593 "Invalid extinstrument vibrato type %d for inst #%d\n", ninst); 593 "Invalid extinstrument vibrato type %d for inst #%d\n", ninst);
594 break; 594 break;
595 } 595 }
596 pEInst->vibratoSweep = xmI2.vibratoSweep; 596 einst->vibratoSweep = xmI2.vibratoSweep;
597 pEInst->vibratoDepth = xmI2.vibratoDepth; 597 einst->vibratoDepth = xmI2.vibratoDepth;
598 pEInst->vibratoRate = xmI2.vibratoRate; 598 einst->vibratoRate = xmI2.vibratoRate;
599 pEInst->fadeOut = xmI2.fadeOut; 599 einst->fadeOut = xmI2.fadeOut;
600 pEInst->nsamples = xmI1.nsamples; 600 einst->nsamples = xmI1.nsamples;
601 601
602 // Initialize the SNumForNotes conversion table 602 // Initialize the SNumForNotes conversion table
603 for (i = 0; i < XM_MaxInstruments; i++) 603 for (i = 0; i < XM_MaxInstruments; i++)
604 xmConvTable[i] = jsetNotSet; 604 xmConvTable[i] = jsetNotSet;
605 605
623 // Apply new values to sNumForNotes values 623 // Apply new values to sNumForNotes values
624 for (i = 0; i < XM_MaxNotes; i++) 624 for (i = 0; i < XM_MaxNotes; i++)
625 { 625 {
626 int tmp = xmI2.sNumForNotes[i]; 626 int tmp = xmI2.sNumForNotes[i];
627 if (tmp >= 0 && tmp < xmI1.nsamples) 627 if (tmp >= 0 && tmp < xmI1.nsamples)
628 pEInst->sNumForNotes[i] = xmConvTable[tmp]; 628 einst->sNumForNotes[i] = xmConvTable[tmp];
629 else 629 else
630 { 630 {
631 pEInst->sNumForNotes[i] = jsetNotSet; 631 einst->sNumForNotes[i] = jsetNotSet;
632 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, 632 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA,
633 "Ext.instrument #%d sNumForNotes[%d] out of range (%d).\n", 633 "Ext.instrument #%d sNumForNotes[%d] out of range (%d).\n",
634 ninst, i, tmp); 634 ninst, i, tmp);
635 } 635 }
636 } 636 }