Ejemplo n.º 1
0
void LoadAllInstruments ()
{
    LoadInstrument("Piano", "samples/piano.swag", 69, "icons/piano.png"); // reference pitch is A4
    LoadInstrument("Strings", "samples/strings.swag", 72, "icons/strings.png"); // reference pitch is C5
    LoadInstrument("Flute", "samples/flute.swag", 69, "icons/flute.png");
    LoadInstrument("Trumpet", "samples/trumpet.swag", 69, "icons/trumpet.png");
    LoadInstrument("Solo Violin", "samples/violin.swag", 69, "icons/violin.png");
}
Ejemplo n.º 2
0
IT_File* ITFile_Load( char *filename ) {

	IT_File *itf;
	int i;

	u32 messageOffset;

	u32 *instrumentOffsets;
	u32 *sampleOffsets;
	u32 *patternOffsets;

	myfile = fopen( filename, "rb" );

	itf = (IT_File*)malloc(sizeof(IT_File));
	memset( itf, 0, sizeof( IT_File ) );

	read32(); // IMPM
	fread( itf->SongName, 1, 26, myfile );
	itf->PatternHighlight = read16();
	itf->OrdNum = read16();
	itf->InsNum = read16();
	itf->SmpNum = read16();
	itf->PatNum = read16();
	itf->Cwtv = read16();
	itf->Cmwt = read16();
	itf->Flags = read16();
	itf->Special = read16();
	itf->GlobalVolume = read8();
	itf->MasterVolume = read8();
	itf->InitialSpeed = read8();
	itf->InitialTempo = read8();
	itf->PanningSeparation = read8();
	itf->PitchWheelDepth = read8();
	itf->MessageLength = read16();
	messageOffset = read32();
	read32(); // reserved
	for( i = 0; i < 64; i++ )
		itf->InitialChannelPanning[i] = read8();
	for( i = 0; i < 64; i++ )
		itf->InitialChannelVolume[i] = read8();
	itf->OrderList = (u8*)malloc( itf->OrdNum );
	for( i = 0; i < itf->OrdNum; i++ )
		itf->OrderList[i] = read8();
	
	instrumentOffsets = (u32*)malloc( itf->InsNum * 4 );
	sampleOffsets = (u32*)malloc( itf->SmpNum * 4 );
	patternOffsets = (u32*)malloc( itf->PatNum * 4 );

	for( i = 0; i < itf->InsNum; i++ )
		instrumentOffsets[i] = read32();
	for( i = 0; i < itf->SmpNum; i++ )
		sampleOffsets[i] = read32();
	for( i = 0; i < itf->PatNum; i++ )
		patternOffsets[i] = read32();
	
	// load instruments
	itf->Instruments = (IT_Instrument*)malloc( sizeof(IT_Instrument) * itf->InsNum );
	for( i = 0; i < itf->InsNum; i++ ) {
		memset( itf->Instruments+i,0,sizeof( IT_Instrument ) ); 
		if( instrumentOffsets[i] ) {
			fseek( myfile, instrumentOffsets[i], SEEK_SET );
			LoadInstrument( itf->Instruments+i );
		}
	}

	// load samples
	itf->Samples = (IT_Sample*)malloc( sizeof(IT_Sample) * itf->SmpNum );
	for( i = 0; i < itf->SmpNum; i++ ) {
		memset( itf->Samples+i, 0, sizeof( IT_Sample ) );
		if( sampleOffsets[i] ) {
			fseek( myfile, sampleOffsets[i], SEEK_SET );
			LoadSample( itf->Samples + i );
		}
	}

	// load patterns
	itf->Patterns = (IT_Pattern*)malloc( sizeof(IT_Pattern) * itf->PatNum );
	for( i = 0; i < itf->PatNum; i++ ) {
		memset( itf->Patterns+i, 0, sizeof( IT_Pattern ) );
		if( patternOffsets[i] ) {
			fseek( myfile, patternOffsets[i], SEEK_SET );
			LoadPattern( itf->Patterns + i );
		}
	}

	// read message
	if( itf->MessageLength ) {
		fseek( myfile, messageOffset, SEEK_SET );
		itf->Message = malloc( itf->MessageLength+1 );
		itf->Message[itf->MessageLength] = 0;
		fread( itf->Message, 1, itf->MessageLength, myfile );
	}

	return itf;
}