Pattern::Pattern( IO::File &file ) { DataLength = file.Read16(); Rows = file.Read16(); file.Skip( 4 ); // reserved Data = new u8[ DataLength ]; for( int i = 0; i < DataLength; i++ ) { Data[i] = file.Read8(); } }
Sample::Sample( IO::File &file ) { file.Skip(4); // IMPS DOSFilename[12] = 0; for( int i = 0; i < 12; i++ ) DOSFilename[i] = file.Read8(); file.Skip(1); // 00h GlobalVolume = file.Read8(); u8 Flags = file.Read8(); HasSample = !!(Flags & 1); Data.Bits16 = !!(Flags & 2); Stereo = !!(Flags & 4); Compressed = !!(Flags & 8); Data.Loop = !!(Flags & 16); Data.Sustain = !!(Flags & 32); Data.BidiLoop = !!(Flags & 64); Data.BidiSustain = !!(Flags & 128); DefaultVolume = file.Read8(); Name[26] = 0; for( int i = 0; i < 26; i++ ) Name[i] = file.Read8(); Convert = file.Read8(); DefaultPanning = file.Read8(); Data.Length = file.Read32(); Data.LoopStart = file.Read32(); Data.LoopEnd = file.Read32(); Data.C5Speed = file.Read32(); Data.SustainStart = file.Read32(); Data.SustainEnd = file.Read32(); u32 SamplePointer = file.Read32(); VibratoSpeed = file.Read8(); VibratoDepth = file.Read8(); VibratoRate = file.Read8(); VibratoForm = file.Read8(); file.Seek( SamplePointer ); LoadData( file ); }
void Sample::LoadData( IO::File &file ) { if( !Compressed ) { // subtract offset for unsigned samples int offset = (Convert&1) ? 0 : (Data.Bits16 ? -32768 : -128); // signed samples if( Data.Bits16 ) { Data.Data16 = new s16[ Data.Length ]; for( int i = 0; i < Data.Length; i++ ) { Data.Data16[i] = file.Read16() + offset; } } else { Data.Data8 = new s8[ Data.Length ]; for( int i = 0; i < Data.Length; i++ ) { Data.Data8[i] = file.Read8() + offset; } } } else { // TODO : accept compressed samples. } }
Envelope::Envelope( IO::File &file ) { u8 FLG = file.Read8(); Enabled = !!(FLG & 1); Loop = !!(FLG & 2); Sustain = !!(FLG & 4); IsFilter = !!(FLG & 128); Length = file.Read8(); LoopStart = file.Read8(); LoopEnd = file.Read8(); SustainStart = file.Read8(); SustainEnd = file.Read8(); for( int i = 0; i < 25; i++ ) { Nodes[i].y = file.Read8(); Nodes[i].x = file.Read16(); } }
Instrument::Instrument( IO::File &file ) { file.Skip(4); // IMPI DOSFilename[12] = 0; for( int i = 0; i < 12; i++ ) DOSFilename[i] = file.Read8(); file.Skip(1); // 00h NewNoteAction = file.Read8(); DuplicateCheckType = file.Read8(); DuplicateCheckAction = file.Read8(); Fadeout = file.Read16(); PPS = file.Read8(); PPC = file.Read8(); GlobalVolume = file.Read8(); DefaultPan = file.Read8(); RandomVolume = file.Read8(); RandomPanning = file.Read8(); TrackerVersion = file.Read16(); NumberOfSamples = file.Read8(); Name[26] = 0; for( int i = 0; i < 26; i++ ) Name[i] = file.Read8(); InitialFilterCutoff = file.Read8(); InitialFilterResonance = file.Read8(); MidiChannel = file.Read8(); MidiProgram = file.Read8(); MidiBank = file.Read16(); file.Read8(); // reserved for( int i = 0; i < 120; i++ ) { Notemap[i].Note = file.Read8(); Notemap[i].Sample = file.Read8(); } VolumeEnvelope = new Envelope( file ); PanningEnvelope = new Envelope( file ); PitchEnvelope = new Envelope( file ); }