Pierluigi Bettitoni
"Intelligent Music Workstation", CD-ROM, Winter 1994
© IEEE Computer Society Press.
{the following numerical constants define the treated Meta Events; they
will be used in the reading loop during a CASE operation, to distinguish
what kind of Meta Event has been met}
- CONST
- SeqNumEvt = $00;
- TextEvt = $01;
- CopyrightEvt = $02;
- SeqTrkNameEvt = $03;
- InstNameEvt = $04;
- LyricEvt = $05;
- MarkerEvt = $06;
- CuePtEvt = $07;
- MIDIChPrefixEvt = $20;
- EotEvt = $2F; {because of reading loop structure used in the Unit
SMFInOutProc, no need of a reading function for it}
- SetTempoEvt = $51;
- SmpteOffsetEvt = $54;
- TimeSignEvt = $58;
- KeySignEvt = $59;
- SeqSpecEvt = $7F;
- F0SysExEvt = $F0;
- F7SysExEvt = $F7;
{This function reads a variable length from a MIDI FILE and decodes it}
Function ReadVarLen(fromfile: integer; var value: longint): OSErr;
{PARAMETERS
- fromfile :
- tells from which file reading the variable length;
- value :
- holds the decoded value}
{This function reads from a Midi File a Header Chunk}
Function R_MThdHeader(FileRef: integer; Var chunktype: OSType; Var Format, Ntrks: integer;
Var metricaltime: boolean; Var param1, param2: integer): OSerr;
{PARAMETERS
- FileRef :
- is the parameter which identifies the file we are reading from; it will always have this meaning, so it will not be specified
further;
- chunktype :
- contains the four bytes 'MThd';
- Format :
- may be 0,1 or 2, and tells the Format of the Standard Midi File;
- Ntrks :
- tells how many tracks are there in the Midi File;
- metricaltime:
- is used to distinguish the meaning of the delta times; if it is true, we have division 0, for metricaltime, else we have division 1, for time code based time;
- param1 :
- when metricaltime is true, it contains the number of Ticks per quarter note, else it contains one of these values: 24, 25, 29 or 30, corresponding to the four standard Smpte and Midi time code formats, and represent the number of frames/sec;
- param2 :
- when metricaltime is false, it contains the resolution within a frame (typical values for it are 4, 8, 10, 80, or 100); not used otherwise}
{This function reads from a Midi File the header of a Track Chunk}
Function R_MTrkHeader(FileRef: integer; var chunktype: OSType; VAR Trklen: longint): OSerr;
{PARAMETERS
- chunktype : holds the four bytes 'MTrk';
- Trklen :
- tells the number of data bytes contained in the track}
{This function reads from a Midi File the sequence number}
Function R_SeqNumEvt(FileRef: integer; ThisLength: Longint; var ssss: integer): OSerr;
{PARAMETERS
- ssss :
- holds the sequence number;
- ThisLength :
- is the number of data bytes of the Meta Event}
{This function reads from a Midi File a text event}
Function R_TextEvt(FileRef: integer; ThisLength: Longint; VAR MetaPtr: ptr): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes of the Meta Event;
- MetaPtr :
- is a pointer to an array in which storing the bytes read; please, remember that it's up to the user to deallocate the memory used by the array, after allocating the datas anywhere it is required to by the calling application, in order to prevent memory from undesirable fragmentation; in case of allocation failure, we give a protection, in terms of skipping those bytes which won't be stored, together with a StopAlert box making the user aware of this fact, and telling the Midi Event which will be skipped, too. This protection is implemented in the SMFInOutProc unit}
{This function reads from a Midi File copyright event}
Function R_CopyrightEvt(FileRef: integer; ThisLength: Longint; VAR MetaPtr: ptr): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes of the Meta Event;
- MetaPtr :
- is a pointer to an array in which storing the bytes read; please, remember that it's up to the user to deallocate the memory used by the array, after allocating the datas anywhere it is required to by the calling application, in order to prevent memory from undesirable fragmentation; in case of allocation failure, we give a protection, in terms of skipping those bytes which won't be stored, together with a StopAlert box making the user aware of this fact, and telling the Midi Event which will be skipped, too. This protection is implemented in the SMFInOutProc unit}
{This function reads from a Midi File sequencer/track name}
Function R_SeqTrkNameEvt(FileRef: integer; ThisLength: Longint; VAR MetaPtr: ptr): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes of the Meta Event;
- MetaPtr :
- is a pointer to an array in which storing the bytes read; please, remember that it's up to the user to deallocate the memory used by the array, after allocating the datas anywhere it is required to by the calling application, in order to prevent memory from undesirable fragmentation; in case of allocation failure, we give a protection, in terms of skipping those bytes which won't be stored, together with a StopAlert box making the user aware of this fact, and telling the Midi Event which will be skipped, too. This protection is implemented in the SMFInOutProc unit}
{This function reads from a Midi File the name of an instrument}
Function R_InstNameEvt(FileRef: integer; ThisLength: Longint; VAR MetaPtr: ptr): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes of the Meta Event;
- MetaPtr :
- is a pointer to an array in which storing the bytes read; please, remember that it's up to the user to deallocate the memory used by the array, after allocating the datas anywhere it is required to by the calling application, in order to prevent memory from undesirable fragmentation; in case of allocation failure, we give a protection, in terms of skipping those bytes which won't be stored, together with a StopAlert box making the user aware of this fact, and telling the Midi Event which will be skipped, too. This protection is implemented in the SMFInOutProc unit}
{This function reads from a Midi File the lyrics}
Function R_LyricEvt(FileRef: integer; ThisLength: Longint; VAR MetaPtr: ptr): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes of the Meta Event;
- MetaPtr :
- is a pointer to an array in which storing the bytes read; please, remember that it's up to the user to deallocate the memory used by the array, after allocating the datas anywhere it is required to by the calling application, in order to prevent memory from undesirable fragmentation; in case of allocation failure, we give a protection, in terms of skipping those bytes which won't be stored, together with a StopAlert box making the user aware of this fact, and telling the Midi Event which will be skipped, too. This protection is implemented in the SMFInOutProc unit}
{This function reads from a Midi File a marker}
Function R_MarkerEvt(FileRef: integer; ThisLength: Longint; VAR MetaPtr: ptr): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes of the Meta Event;
- MetaPtr :
- is a pointer to an array in which storing the bytes read; please, remember that it's up to the user to deallocate the memory used by the array, after allocating the datas anywhere it is required to by the calling application, in order to prevent memory from undesirable fragmentation; in case of allocation failure, we give a protection, in terms of skipping those bytes which won't be stored, together with a StopAlert box making the user aware of this fact, and telling the Midi Event which will be skipped, too. This protection is implemented in the SMFInOutProc unit}
{This function reads from a Midi File cue point event}
Function R_CuePtEvt(FileRef: integer; ThisLength: Longint; VAR MetaPtr: ptr): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes of the Meta Event;
- MetaPtr :
- is a pointer to an array in which storing the bytes read; please, remember that it's up to the user to deallocate the memory used by the array, after allocating the datas anywhere it is required to by the calling application, in order to prevent memory from undesirable fragmentation; in case of allocation failure, we give a protection, in terms of skipping those bytes which won't be stored, together with a StopAlert box making the user aware of this fact, and telling the Midi Event which will be skipped, too. This protection is implemented in the SMFInOutProc unit}
{This function reads from a Midi File a MIDI channel prefix event}
Function R_MIDIChPrefixEvt(FileRef: integer; ThisLength: Longint; var cc: integer): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes of the Meta Event;
- cc :
- is the number of the channel, that is to say a number between 0 and 15}
{This function reads from a Midi File a tempo setting}
Function R_SetTempoEvt(FileRef: integer; ThisLength: Longint; var Dur: longint): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes of the Meta Event;
- Dur :
- specifies the number of microseconds per quarter of a note
{This function reads from a Midi File the SMPTE offset}
Function R_SmpteOffsetEvt(FileRef: integer; ThisLength: Longint; var hr,mn,se,fr,ff: integer): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes of the Meta Event;
- hr :
- is the hours value;
- mn :
- is the minutes value;
- se :
- is the seconds value;
- fr :
- is the number of frames;
- ff :
- is the number of fractional frames}
{This function reads from a Midi File the time signature}
Function R_TimeSignEvt(FileRef: integer; ThisLength: Longint; var nn,dd,cc,bb: integer): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes of the Meta Event;
- nn :
- is the numerator of the time signature fraction;
- dd :
- is the denominator of it;
- cc :
- is the number of MIDI clocks in a metronome click;
- bb :
- is the number of notated 32nd notes in a MIDI quarter note}
{This function reads from a Midi File a key signature}
Function R_KeySignEvt(FileRef: integer; ThisLength: Longint; var sf,mi: integer): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes of the Meta Event;
- sf :
- tells flat(s) or sharp(s) or key of C;
- mi :
- means Major or minor key}
{This function reads from a Midi File Sequencer specific message}
Function R_SeqSpecEvt(FileRef: integer; ThisLength: Longint; VAR MetaPtr: ptr): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes of the Meta Event;
- MetaPtr :
- is a pointer to an array in which storing the bytes read; please, remember that it's up to the user to deallocate the memory used by the array, after allocating the datas anywhere it is required to by the calling application, in order to prevent memory from undesirable fragmentation; in case of allocation failure, we give a protection, in terms of skipping those bytes which won't be stored, together with a StopAlert box making the user aware of this fact, and telling the Midi Event which will be skipped, too. This protection is implemented in the SMFInOutProc unit}
{This function reads from a Midi File an 'F0 syntax' System Exclusive message}
Function R_F0SysexEvt(FileRef: integer; ThisLength: Longint; VAR SysexPtr: ptr): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes of the Meta Event;
- SysexPtr :
- is a pointer to an array in which storing the bytes read; please, remember that it's up to the user to deallocate the memory used by the array, after allocating the datas anywhere it is required to by the calling application, in order to prevent memory from undesirable fragmentation; in case of allocation failure, we give a protection, in terms of skipping those bytes which won't be stored, together with a StopAlert box making the user aware of this fact, and telling the Midi Event which will be skipped, too. This protection is implemented in the SMFInOutProc unit}
{This function reads from a Midi File an 'F7 syntax' System Exclusive message}
Function R_F7SysexEvt(FileRef: integer; ThisLength: Longint; VAR SysexPtr: ptr): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes of the Meta Event;
- SysexPtr :
- is a pointer to an array in which storing the bytes read; please, remember that it's up to the user to deallocate the memory used by the array, after allocating the datas anywhere it is required to by the calling application, in order to prevent memory from undesirable fragmentation; in case of allocation failure, we give a protection, in terms of skipping those bytes which won't be stored, together with a StopAlert box making the user aware of this fact, and telling the Midi Event which will be skipped, too. This protection is implemented in the SMFInOutProc unit}
{This function skips every non recognized information, such as alien chunks,
undefined meta events, and so on}
Function SkipThings(fileref: integer; ThisLength: Longint): OSerr;
{PARAMETERS
- ThisLength :
- is the number of data bytes to be skipped}
[ Index |
Glossary |
Previous Paragraph |
Next Paragraph ]