home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXTSTEP 3.0
/
NeXTSTEP3.0.iso
/
NextDeveloper
/
Examples
/
SoundAndMusic
/
Drivers
/
MidiDriver
/
midifile.h
< prev
next >
Wrap
Text File
|
1992-02-14
|
5KB
|
134 lines
#import <streams/streams.h>
#import <objc/objc.h>
typedef struct _MIDIFILEReadStruct {
int quanta;
BOOL metaEventFlag;
int nData;
unsigned char *data;
} MIDIFILEReadStruct;
#define MIDIFILE_DEFAULTQUANTASIZE (1000)
typedef enum _MIDIFILEMetaEvent {
/* In all of the metaevents, data[0] is the metaevent itself. */
MIDIFILE_sequenceNumber = 0,
/*
* data[1] and data[2] contain high and low order bits of number.
*/
MIDIFILE_text = 1,
MIDIFILE_copyright = 2,
MIDIFILE_sequenceOrTrackName = 3,
/* MIDIFILE_instrumentName not supported */
MIDIFILE_lyric = 5,
MIDIFILE_marker = 6,
MIDIFILE_cuePoint = 7,
/* data[1]* specifies null-terminated text.
*/
/*
* MIDIFILE_channelprefix, should be implemented by midifile.c and
* should not be passed up to user.
*/
MIDIFILE_trackChange,
/*
* Track change metaevent: data[1] and data[2] contain high/low order bits,
* respectively, containing the track number. These events can only be
* encountered when reading a level-1 file.
*/
MIDIFILE_tempoChange,
/*
* Tempo change metaevent: data[1:4] contain 4 bytes of data.
*/
MIDIFILE_smpteOffset,
/*
data[1:5] are the 5 numbers hr mn sec fr ff
*/
MIDIFILE_timeSig,
/* data is a single int, where 1-byte fields are nn dd cc bb */
MIDIFILE_keySig
/* data is a single short, where 1-byte fields are sf mi */
} MIDIFILEMetaevent;
extern void *MIDIFILEBeginReading(NXStream *s,MIDIFILEReadStruct *m);
/* InitialBS) reading. Returns a struct that should be passed to
* other reading routines. The struct pointed to by m is used to
* return the MIDIFILE event information. It should not be freed or
* altered by the caller.
* MIDIFILEBeginReading must be balanced by a call to MIDIFILEEndReading.
*/
extern void *MIDIFILEEndReading(void *p);
/* Terminates reading and frees internal structure. */
extern int MIDIFILEReadPreamble(void *p,int *level,int *track_count);
/*
* Reads the header of the specified file, and returns the midifile level
* (format) of the file, and the total number of tracks, in the respective
* parameters. The return value will be non-zero if all is well; any error
* causes zero to be returned.
*/
extern int MIDIFILESetReadQuantaSize(void *p,int usec);
/* Sets read quantum as indicated. */
extern int MIDIFILEReadEvent(void *p);
/*
* Reads the next event in the current track. Return nonzero if successful;
* zero if an error or end-of-stream occurred. The next event data is
* returned in the MIDIFILEReadStruct passed to MIDIFILEBeginReading().
*/
void *MIDIFILEBeginWriting(NXStream *s, int level, char *sequenceName);
/*
* Writes the preamble and opens track zero for writing. In level 1 files,
* track zero is used by convention for timing information (tempo,time
* signature, click track).
* MIDIFILEBeginWriting must be balanced by a call to MIDIFILEEndWriting.
* Returns a struct that must be passed to other writing routines.
*/
extern int MIDIFILEEndWriting(void *p);
/*
* Terminates writing to the stream. After this call, the stream may
* be closed.
*/
extern int MIDIFILEBeginWritingTrack(void *p, char *trackName);
extern int MIDIFILEEndWritingTrack(void *p,int quanta);
/*
* These two functions must be called in a level 1 or 2 file to bracket each
* chunk of track data (except track 0, which is special).
*/
extern int MIDIFILEWriteEvent(void *p,int quanta,int ndata,
unsigned char *bytes);
/* Bytes are assumed to be a valid and complete event. */
extern int MIDIFILEWriteSysExcl(void *p,int quanta,int ndata,
unsigned char *bytes);
/* Writes a system exclusive message. quanta is the time of the message.
* The message must start with 0xf0 and end with 0xf7. ndata includes
* all bytes.
*/
/* The following functions write various meta-events. */
extern BS0MIDIFILEWriteTempo(void *p,int quanta, int beatsPerMinute);
/* Writes the tempo. quanta is the time of the tempo change. */
extern int MIDIFILEWriteSig(void *p,int quanta,short metaevent,
unsigned data);
/* Write time sig or key sig. Specified in midifile format. */
extern int MIDIFILEWriteText(void *p,int quanta,short metaevent,char *data);
extern int MIDIFILEWriteSMPTEoffset(void *p,
unsigned char hr,
unsigned char min,
unsigned char sec,
unsigned char ff,
unsigned char fr);
extern int MIDIFILEWriteSequenceNumber(void *p,int data);