Annotation of Examples/SoundAndMusic/MidiDriver/midifile.h, revision 1.1.1.1

1.1       root        1: #import <streams/streams.h>
                      2: #import <objc/objc.h>
                      3: 
                      4: typedef struct _MIDIFILEReadStruct {
                      5:     int quanta;
                      6:     BOOL metaEventFlag;
                      7:     int nData;
                      8:     unsigned char *data;
                      9: } MIDIFILEReadStruct;
                     10: 
                     11: #define MIDIFILE_DEFAULTQUANTASIZE (1000)
                     12: 
                     13: typedef enum _MIDIFILEMetaEvent {
                     14:     /* In all of the metaevents, data[0] is the metaevent itself. */
                     15:     MIDIFILE_sequenceNumber = 0,
                     16:     /*
                     17:      * data[1] and data[2] contain high and low order bits of number. 
                     18:      */
                     19:     MIDIFILE_text = 1,
                     20:     MIDIFILE_copyright = 2,
                     21:     MIDIFILE_sequenceOrTrackName = 3,
                     22:     /* MIDIFILE_instrumentName not supported */  
                     23:     MIDIFILE_lyric = 5,
                     24:     MIDIFILE_marker = 6,
                     25:     MIDIFILE_cuePoint = 7,
                     26:     /* data[1]* specifies null-terminated text. 
                     27:      */
                     28:     /*
                     29:      * MIDIFILE_channelprefix, should be implemented by midifile.c and 
                     30:      * should not be passed up to user. 
                     31:      */
                     32:     MIDIFILE_trackChange,
                     33:     /*
                     34:      * Track change metaevent: data[1] and data[2] contain high/low order bits,
                     35:      * respectively, containing the track number. These events can only be 
                     36:      * encountered when reading a level-1 file.
                     37:      */
                     38:     MIDIFILE_tempoChange,
                     39:     /*
                     40:      * Tempo change metaevent: data[1:4] contain 4 bytes of data.
                     41:      */
                     42:     MIDIFILE_smpteOffset,
                     43:     /*
                     44:       data[1:5] are the 5 numbers hr mn sec fr ff
                     45:       */
                     46:     MIDIFILE_timeSig,
                     47:     /* data is a single int, where 1-byte fields are nn dd cc bb */
                     48:     MIDIFILE_keySig
                     49:     /*  data is a single short, where 1-byte fields are sf mi  */
                     50:   } MIDIFILEMetaevent;
                     51: 
                     52: extern void *MIDIFILEBeginReading(NXStream *s,MIDIFILEReadStruct *m);
                     53: /* Initializes reading.  Returns a struct that should be passed to
                     54:  * other reading routines.  The struct pointed to by m is used to 
                     55:  * return the MIDIFILE event information.  It should not be freed or
                     56:  * altered by the caller.
                     57:  * MIDIFILEBeginReading must be balanced by a call to MIDIFILEEndReading.
                     58:  */
                     59: 
                     60: extern void *MIDIFILEEndReading(void *p);
                     61: /* Terminates reading and frees internal structure. */
                     62: 
                     63: extern int MIDIFILEReadPreamble(void *p,int *level,int *track_count);
                     64: /*
                     65:  * Reads the header of the specified file, and returns the midifile level 
                     66:  * (format) of the file, and the total number of tracks, in the respective 
                     67:  * parameters. The return value will be non-zero if all is well; any error
                     68:  * causes zero to be returned.
                     69:  */
                     70: 
                     71: extern int MIDIFILESetReadQuantaSize(void *p,int usec);
                     72: /* Sets read quantum as indicated. */
                     73: 
                     74: extern int MIDIFILEReadEvent(void *p);
                     75: /*
                     76:  * Reads the next event in the current track. Return nonzero if successful;
                     77:  * zero if an error or end-of-stream occurred. The next event data is 
                     78:  * returned in the MIDIFILEReadStruct passed to MIDIFILEBeginReading().
                     79:  */
                     80: 
                     81: void *MIDIFILEBeginWriting(NXStream *s, int level, char *sequenceName);
                     82: /*
                     83:  * Writes the preamble and opens track zero for writing. In level 1 files,
                     84:  * track zero is used by convention for timing information (tempo,time
                     85:  * signature, click track). 
                     86:  * MIDIFILEBeginWriting must be balanced by a call to MIDIFILEEndWriting.
                     87:  * Returns a struct that must be passed to other writing routines.
                     88:  */
                     89: 
                     90: extern int MIDIFILEEndWriting(void *p);
                     91: /*
                     92:  * Terminates writing to the stream. After this call, the stream may
                     93:  * be closed.
                     94:  */
                     95: 
                     96: extern int MIDIFILEBeginWritingTrack(void *p, char *trackName);
                     97: extern int MIDIFILEEndWritingTrack(void *p,int quanta);
                     98: /*
                     99:  * These two functions must be called in a level 1 or 2 file to bracket each
                    100:  * chunk of track data (except track 0, which is special).
                    101:  */
                    102: 
                    103: extern int MIDIFILEWriteEvent(void *p,int quanta,int ndata,
                    104:                              unsigned char *bytes);
                    105: /* Bytes are assumed to be a valid and complete event. */
                    106: 
                    107: extern int MIDIFILEWriteSysExcl(void *p,int quanta,int ndata,
                    108:                                unsigned char *bytes);
                    109: /* Writes a system exclusive message.  quanta is the time of the message. 
                    110:  * The message must start with 0xf0 and end with 0xf7. ndata includes
                    111:  * all bytes. 
                    112:  */
                    113: 
                    114: /* The following functions write various meta-events. */
                    115: extern int MIDIFILEWriteTempo(void *p,int quanta, int beatsPerMinute);
                    116: /* Writes the tempo.  quanta is the time of the tempo change. */
                    117: 
                    118: extern int MIDIFILEWriteSig(void *p,int quanta,short metaevent,
                    119:                            unsigned data);
                    120: /* Write time sig or key sig. Specified in midifile format. */
                    121: 
                    122: extern int MIDIFILEWriteText(void *p,int quanta,short metaevent,char *data);
                    123: 
                    124: extern int MIDIFILEWriteSMPTEoffset(void *p,
                    125:                                    unsigned char hr,
                    126:                                    unsigned char min,
                    127:                                    unsigned char sec,
                    128:                                    unsigned char ff,
                    129:                                    unsigned char fr);
                    130: 
                    131: extern int MIDIFILEWriteSequenceNumber(void *p,int data);
                    132: 
                    133: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.