Sequence File Formats For the Music Sequence Maker Program Paul Gauthier Ver 1.0 May 1989 As of this writting, Apple has not released a format for sequence files that can be played directly by the Note Sequencer toolset. The format described below was developed to allow sequences to be stored on disk and to allow a sequence to be played with different sets of instruments. When Apple releases a standard format for sequence files, the Music Sequence Maker program will be modified to support the standard format. The Music Sequence Maker program saves a sequence as a set of three files: A sequence file (YourFileName.SEQ) An instrument file (YourFileName.INS) A waveform file (YourFileName.WVE) The formats for the three files are shown below: 1. The Sequence File (.SEQ) (Type F1) -------------------------------- This file contains the notes of the song, the length and tempo of the song and the name of the corresponding instrument file to load. type bytes description ---- ----- ----------- string 16 A Pascal-style string containing the name of the instrument file. One length byte followed by 15 characters. longint 4 The total length of the sequence file in bytes. longint 4 The total number of "ticks" in sequence. The duration of each note in the sequence is measured in units of ticks. The length of a tick is set by the input parameters to the SeqStartUp call and the value of the increment. longint 4 The tempo value in force when the sequence was saved. This is the "increment" value and is the number of interrupts that make up one tick. longint 4 Reserved for future expansion. longint 4 Reserved for future expansion. longint 4 Reserved for future expansion. longint 4 Phrase ID code = 0x00000001 This is the start of the sequence. A handle to this spot is given to StartSeq to start the sequence. The Phrase ID code shows that this is the start of a "phrase" (containing pointers to "patterns" which contain the notes.) longint 4 Relative pointer (an index) to the first (and only) pattern. The Note Sequencer expects to see a memory pointer (an absolute address) here that points to the pattern. Since we don't know where the Memory Manager will put the sequence when it's loaded into memory, the sequence file contains a relative address measured from the start of the sequence file. Before the sequence can be played, this longint must be converted to an absolute address. This is the main job of procedure RelocateSequence in the PlaySeq program. longint 4 End-of-Phrase marker = 0xFFFFFFFF. longint 4 Pattern ID code = 0x00000000. This is the start of the only pattern in the sequence. A pattern is a collection of "Seq Items", each 4 bytes long containing information for each note to play. longint 4 The Seq Items. See the Apple IIgs Toolbox . Reference Update for full details. For . the Music Sequence Maker, only Note . Commands are used. Their format is shown . below: Seq Item Note Command Format: Bits 0-6 Volume. For Music Studio song files, the volume setting for all notes is set to the volume setting for the entire song. A volume of 0 is a "Note Off" command. Bit 7 Chord bit. If set, play simultaneously with next seq item. Bits 8-14 Pitch. 0 to 127. 60 is middle C. Bit 15 Note bit. Always set to 1 for note commands. Bits 16-26 Duration. Gives number of ticks note is to play. If 0, this is a "Note On" command. Bits 27-30 Track Number. Shows which track note is for. Tracks can be assigned to different instruments. Bit 31 Delay Bit. If set, the Note Sequencer finishes playing this note before playing the next one. 2. The Instrument File (Type F2) ------------------------------------ This file contains definitions for up to 15 instruments. The instrument number corresponds to the "track number" stored in each Seq Item of the sequence file. type bytes description ---- ----- ----------- string 16 A Pascal-style string containing the name of the waveform file. A length byte followed by 15 characters. array 15*80 A 15 element array of instruments. Each instrument is a standard instrument data structure. The description below comes from the "notesyn.h" include file in APW. The only difference from the standard is the value of "aWCount" and "bWCount". The standard definition calls for both values to be 1. The instrument file expects aWCount to be 8 and bWCount to be 1. This lets any instrument have a total of 8 waves (present in some Music Studio instruments.) Format for an instrument: typedef struct Envelope { Byte st1BkPt; /* Envelope - */ Word st1Increment; /* Envelope - */ Byte st2BkPt; /* Envelope - */ Word st2Increment; /* Envelope - */ Byte st3BkPt; /* Envelope - */ Word st3Increment; /* Envelope - */ Byte st4BkPt; /* Envelope - */ Word st4Increment; /* Envelope - */ Byte st5BkPt; /* Envelope - */ Word st5Increment; /* Envelope - */ Byte st6BkPt; /* Envelope - */ Word st6Increment; /* Envelope - */ Byte st7BkPt; /* Envelope - */ Word st7Increment; /* Envelope - */ Byte st8BkPt; /* Envelope - */ Word st8Increment; /* Envelope - */ } Envelope, *EnvelopePtr, **EnvelopeHndl; typedef struct Waveform { Byte wfTopKey; /* Waveform - */ Byte wfWaveAddress; /* Waveform - */ Byte wfWaveSize; /* Waveform - */ Byte wfDocMode; /* Waveform - */ Word wfRelPitch; /* Waveform - */ } Waveform, *WaveformPtr, **WaveformHndl; #define aWCount 8 #define bWCount 1 typedef struct Instrument { Envelope theEnvelope; /* Instrument - */ Byte releaseSegment; /* Instrument - */ Byte priorityIncrement; /* Instrument - */ Byte pitchBendRange; /* Instrument - */ Byte vibratoDepth; /* Instrument - */ Byte vibratoSpeed; /* Instrument - */ Byte inSpare; /* Instrument - */ Byte aWaveCount; /* Instrument - */ Byte bWaveCount; /* Instrument - */ Waveform abWaveList[aWCount]; } Instrument, *InstrumentPtr, **InstrumentHndl; The format of the overall instrument file: typedef struct InstrumentFile {/* The instrument file */ char waveFileName[16]; /* The name of the sound wave file */ Instrument instruments[15];/* Music Studio instruments */ } InstrumentFile; 3. The Waveform File (.WVE) (Type F3) ------------------------------- The waveform file is a copy of up to 64K of memory that is loaded into the DOC RAM to provide the underlying instrument sounds. There is no preliminary header to the file. The name of the waveform file is stored at the beginning of the instrument file so that the two files (.INS and .WVE) must stay together.