1/*----------------------------------------------------------------------------
2 *
3 * File:
4 * jet_data.h
5 *
6 * Contents and purpose:
7 * Internal data structures and interfaces for JET
8 *
9 * Copyright (c) 2006 Sonic Network Inc.
10
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
14 *
15 *      http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
22 *----------------------------------------------------------------------------
23 * Revision Control:
24 *   $Revision: 554 $
25 *   $Date: 2007-02-02 11:06:10 -0800 (Fri, 02 Feb 2007) $
26 *----------------------------------------------------------------------------
27*/
28
29#ifndef _JET_DATA_H
30#define _JET_DATA_H
31
32#include "eas.h"
33#include "jet.h"
34
35/* maximum number of segments allowed in a JET file */
36#ifndef JET_MAX_SEGMENTS
37#define JET_MAX_SEGMENTS            32
38#endif
39
40/* maximum number of DLS collections allowed in a JET file */
41#ifndef JET_MAX_DLS_COLLECTIONS
42#define JET_MAX_DLS_COLLECTIONS     4
43#endif
44
45/* maximum number of JET events in internal queue */
46#ifndef JET_EVENT_QUEUE_SIZE
47#define JET_EVENT_QUEUE_SIZE        32
48#endif
49
50/* maximum number of JET events in application queue */
51#ifndef APP_EVENT_QUEUE_SIZE
52#define APP_EVENT_QUEUE_SIZE        32
53#endif
54
55/* maximum number of active mute events */
56#ifndef JET_MUTE_QUEUE_SIZE
57#define JET_MUTE_QUEUE_SIZE         8
58#endif
59
60/*----------------------------------------------------------------------------
61 * JET event definitions
62 *----------------------------------------------------------------------------
63*/
64#define JET_EVENT_APP_LOW           80
65#define JET_EVENT_APP_HIGH          83
66#define JET_EVENT_LOW               102
67#define JET_EVENT_HIGH              119
68#define JET_EVENT_MARKER            102
69#define JET_EVENT_TRIGGER_CLIP      103
70
71#define JET_MARKER_LOOP_END         0
72
73#define JET_CLIP_ACTIVE_FLAG        0x80
74#define JET_CLIP_TRIGGER_FLAG       0x40
75#define JET_CLIP_ID_MASK            0x3f
76
77/*----------------------------------------------------------------------------
78 * JET file definitions
79 *----------------------------------------------------------------------------
80*/
81#define JET_TAG(a,b,c,d) (\
82    ( ((EAS_U32)(a) & 0xFF) << 24 ) \
83    + ( ((EAS_U32)(b) & 0xFF) << 16 ) \
84    + ( ((EAS_U32)(c) & 0xFF) <<  8 ) \
85    + ( ((EAS_U32)(d) & 0xFF)))
86
87#define JET_VERSION 0x01000000
88#define JET_HEADER_TAG JET_TAG('J','E','T',' ')
89#define JET_INFO_CHUNK JET_TAG('J','I','N','F')
90#define JET_SMF_CHUNK JET_TAG('J','S','M','F')
91#define JET_DLS_CHUNK JET_TAG('J','D','L','S')
92#define INFO_JET_COPYRIGHT JET_TAG('J','C','O','P')
93#define JET_APP_DATA_CHUNK JET_TAG('J','A','P','P')
94
95#define INFO_NUM_SMF_CHUNKS JET_TAG('S','M','F','#')
96#define INFO_NUM_DLS_CHUNKS JET_TAG('D','L','S','#')
97#define INFO_JET_VERSION JET_TAG('J','V','E','R')
98
99/*----------------------------------------------------------------------------
100 * S_JET_SEGMENT
101 *
102 * JET segment data
103 *----------------------------------------------------------------------------
104*/
105typedef struct s_jet_segment_tag
106{
107    EAS_HANDLE          streamHandle;
108    EAS_U32             muteFlags;
109    EAS_I16             repeatCount;
110    EAS_U8              userID;
111    EAS_I8              transpose;
112    EAS_I8              libNum;
113    EAS_U8              state;
114    EAS_U8              flags;
115} S_JET_SEGMENT;
116
117/* S_JET_SEGMENT.state */
118typedef enum
119{
120    JET_STATE_CLOSED,
121    JET_STATE_OPEN,
122    JET_STATE_READY,
123    JET_STATE_PLAYING,
124    JET_STATE_PAUSED,
125    JET_STATE_STOPPING
126} E_JET_SEGMENT_STATE;
127
128/* S_JEG_SEGMENT.flags */
129#define JET_SEG_FLAG_MUTE_UPDATE        0x01
130
131/*----------------------------------------------------------------------------
132 * S_JET_DATA
133 *
134 * Main JET data structure
135 *----------------------------------------------------------------------------
136*/
137#define SEG_QUEUE_DEPTH 3
138typedef struct s_jet_data_tag
139{
140    EAS_FILE_HANDLE     jetFileHandle;
141    S_JET_SEGMENT       segQueue[SEG_QUEUE_DEPTH];
142    EAS_I32             segmentOffsets[JET_MAX_SEGMENTS];
143    EAS_I32             appDataOffset;
144    EAS_I32             appDataSize;
145    EAS_DLSLIB_HANDLE   libHandles[JET_MAX_DLS_COLLECTIONS];
146    EAS_U32             jetEventQueue[JET_EVENT_QUEUE_SIZE];
147    EAS_U32             appEventQueue[APP_EVENT_QUEUE_SIZE];
148    S_JET_CONFIG        config;
149    EAS_U32             segmentTime;
150    EAS_U8              muteQueue[JET_MUTE_QUEUE_SIZE];
151    EAS_U8              numSegments;
152    EAS_U8              numLibraries;
153    EAS_U8              flags;
154    EAS_U8              playSegment;
155    EAS_U8              queueSegment;
156    EAS_U8              numQueuedSegments;
157    EAS_U8              jetEventQueueRead;
158    EAS_U8              jetEventQueueWrite;
159    EAS_U8              appEventQueueRead;
160    EAS_U8              appEventQueueWrite;
161} S_JET_DATA;
162
163/* flags for S_JET_DATA.flags */
164#define JET_FLAGS_PLAYING       1
165
166#define JET_EVENT_VAL_MASK      0x0000007f  /* mask for value */
167#define JET_EVENT_CTRL_MASK     0x00003f80  /* mask for controller */
168#define JET_EVENT_CHAN_MASK     0x0003c000  /* mask for channel */
169#define JET_EVENT_TRACK_MASK    0x00fc0000  /* mask for track number */
170#define JET_EVENT_SEG_MASK      0xff000000  /* mask for segment ID */
171#define JET_EVENT_CTRL_SHIFT    7           /* shift for controller number */
172#define JET_EVENT_CHAN_SHIFT    14          /* shift to for MIDI channel */
173#define JET_EVENT_TRACK_SHIFT   18          /* shift to get track ID to bit 0 */
174#define JET_EVENT_SEG_SHIFT     24          /* shift to get segment ID to bit 0 */
175
176/* prototype for callback function */
177extern void JET_Event (EAS_DATA_HANDLE easHandle, EAS_U32 segTrack, EAS_U8 channel, EAS_U8 controller, EAS_U8 value);
178
179/* prototype for JET render function */
180extern EAS_PUBLIC EAS_RESULT JET_Process (EAS_DATA_HANDLE easHandle);
181
182#endif
183
184