eas_miditypes.h revision e442bb7cd6a085b33a4dd52c0e20a157ada7feb1
1/*----------------------------------------------------------------------------
2 *
3 * File:
4 * eas_miditypes.h
5 *
6 * Contents and purpose:
7 * Contains declarations for the MIDI stream parser.
8 *
9 *
10 * Copyright Sonic Network Inc. 2005
11
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 *      http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 *----------------------------------------------------------------------------
25 * Revision Control:
26 *   $Revision: 778 $
27 *   $Date: 2007-07-23 16:45:17 -0700 (Mon, 23 Jul 2007) $
28 *----------------------------------------------------------------------------
29*/
30
31#ifndef _EAS_MIDITYPES_H
32#define _EAS_MIDITYPES_H
33
34#include "eas_data.h"
35#include "eas_parser.h"
36
37/*----------------------------------------------------------------------------
38 * S_MIDI_STREAM
39 *
40 * Maintains parser state for the MIDI stream parser
41 *
42 *----------------------------------------------------------------------------
43*/
44
45typedef struct s_midi_stream_tag
46{
47	EAS_BOOL8			byte3;				/* flag indicates 3rd byte expected */
48	EAS_BOOL8			pending;			/* flag indicates more data expected */
49	EAS_U8				sysExState;			/* maintains the SysEx state */
50	EAS_U8				runningStatus;		/* last running status received */
51	EAS_U8				status;				/* status byte */
52	EAS_U8				d1;					/* first data byte */
53	EAS_U8				d2;					/* second data byte */
54	EAS_U8				flags;				/* flags - see below for definition */
55#ifdef JET_INTERFACE
56	EAS_U32				jetData;			/* JET data */
57#endif
58} S_MIDI_STREAM;
59
60/* flags for S_MIDI_STREAM.flags */
61#define MIDI_FLAG_GM_ON			0x01		/* GM System On message received */
62#define MIDI_FLAG_FIRST_NOTE	0x02		/* first note received */
63
64/* flags for S_MIDI_STREAM.jetFlags */
65#define MIDI_FLAGS_JET_MUTE		0x00000001	/* track is muted */
66#define MIDI_FLAGS_JET_CB		0x00000002	/* JET callback enabled */
67
68/*----------------------------------------------------------------------------
69 *
70 * S_SMF_STREAM
71 *
72 * This structure contains data required to parse an SMF stream. For SMF0 files, there
73 * will be a single instance of this per file. For SMF1 files, there will be multiple instance,
74 * one for each separate stream in the file.
75 *
76 *----------------------------------------------------------------------------
77*/
78
79typedef struct s_smf_stream_tag
80{
81	EAS_FILE_HANDLE		fileHandle;			/* host wrapper file handle */
82	EAS_U32				ticks;				/* time of next event in stream */
83	EAS_I32 			startFilePos;		/* start location of track within file */
84	S_MIDI_STREAM 		midiStream;			/* MIDI stream state */
85} S_SMF_STREAM;
86
87/*----------------------------------------------------------------------------
88 *
89 * S_SMF_DATA
90 *
91 * This structure contains the instance data required to parse an SMF stream.
92 *
93 *----------------------------------------------------------------------------
94*/
95
96typedef struct s_smf_data_tag
97{
98#ifdef _CHECKED_BUILD
99	EAS_U32				handleCheck;		/* signature check for checked build */
100#endif
101	S_SMF_STREAM		*streams;			/* pointer to individual streams in file */
102	S_SMF_STREAM		*nextStream;		/* pointer to next stream with event */
103	S_SYNTH				*pSynth;			/* pointer to synth */
104	EAS_FILE_HANDLE		fileHandle;			/* file handle */
105	S_METADATA_CB		metadata;			/* metadata callback */
106	EAS_I32				fileOffset;			/* for embedded files */
107	EAS_I32				time;				/* current time in milliseconds/256 */
108	EAS_U16				numStreams;			/* actual number of streams */
109	EAS_U16				tickConv;			/* current MIDI tick to msec conversion */
110	EAS_U16				ppqn;				/* ticks per quarter note */
111	EAS_U8				state;				/* current state EAS_STATE_XXXX */
112	EAS_U8				flags;				/* flags - see definitions below */
113} S_SMF_DATA;
114
115#define SMF_FLAGS_CHASE_MODE		0x01	/* chase mode - skip to first note */
116#define SMF_FLAGS_HAS_TIME_SIG		0x02	/* time signature encountered at time 0 */
117#define SMF_FLAGS_HAS_TEMPO			0x04	/* tempo encountered at time 0  */
118#define SMF_FLAGS_HAS_GM_ON			0x08	/* GM System On encountered at time 0 */
119#define SMF_FLAGS_JET_STREAM		0x80	/* JET in use - keep strict timing */
120
121/* combo flags indicate setup bar */
122#define SMF_FLAGS_SETUP_BAR (SMF_FLAGS_HAS_TIME_SIG | SMF_FLAGS_HAS_TEMPO | SMF_FLAGS_HAS_GM_ON)
123
124/*----------------------------------------------------------------------------
125 * Interactive MIDI structure
126 *----------------------------------------------------------------------------
127*/
128typedef struct s_interactive_midi_tag
129{
130#ifdef _CHECKED_BUILD
131	EAS_U32				handleCheck;		/* signature check for checked build */
132#endif
133	S_SYNTH		*pSynth;			/* pointer to synth */
134	S_MIDI_STREAM		stream;				/* stream data */
135} S_INTERACTIVE_MIDI;
136
137#endif /* #ifndef _EAS_MIDITYPES_H */
138
139