1 /*--------------------------------------------------------------------------*
2   Project: DLS converter for SYN
3   File:    dls.h
4 
5   Copyright (C)2001-2006 Nintendo  All Rights Reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Log: dls.h,v $
14   Revision 1.2  02/08/2006 06:21:14  aka
15   Changed copyright.
16 
17 
18  *--------------------------------------------------------------------------*/
19 
20 #ifndef __DLS_H__
21 #define __DLS_H__
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 
28 /*--------------------------------------------------------------------------*/
29 
30 #define ChunkName(a,b,c,d)(             \
31                                 (a & 0xFF)              \
32                         +       ((b & 0xFF) << 8)       \
33                         +       ((c & 0xFF) << 16)      \
34                         +       ((d & 0xFF) << 24))
35 
36 
37 #define RIFF    ChunkName('R','I','F','F')
38 #define DLS     ChunkName('D','L','S',' ')
39 #define LIST    ChunkName('L','I','S','T')
40 #define COLH    ChunkName('c','o','l','h')
41 #define VERS    ChunkName('v','e','r','s')
42 #define LINS    ChunkName('l','i','n','s')
43 #define INS     ChunkName('i','n','s',' ')
44 #define INSH    ChunkName('i','n','s','h')
45 #define LRGN    ChunkName('l','r','g','n')
46 #define RGN     ChunkName('r','g','n',' ')
47 #define RGNH    ChunkName('r','g','n','h')
48 #define WSMP    ChunkName('w','s','m','p')
49 #define WLNK    ChunkName('w','l','n','k')
50 #define LART    ChunkName('l','a','r','t')
51 #define LAR2    ChunkName('l','a','r','2')
52 #define ART1    ChunkName('a','r','t','1')
53 #define DATA    ChunkName('d','a','t','a')
54 #define PTBL    ChunkName('p','t','b','l')
55 #define DLID    ChunkName('d','l','i','d')
56 #define WVPL    ChunkName('w','v','p','l')
57 #define WAVE    ChunkName('w','a','v','e')
58 #define WAVU    ChunkName('w','a','v','u')
59 #define FMT     ChunkName('f','m','t',' ')
60 #define INFO    ChunkName('I','N','F','O')
61 #define IARL    ChunkName('I','A','R','L')
62 #define IART    ChunkName('I','A','R','T')
63 #define ICMS    ChunkName('I','C','M','S')
64 #define ICMT    ChunkName('I','C','M','T')
65 #define ICOP    ChunkName('I','C','O','P')
66 #define ICRD    ChunkName('I','C','R','D')
67 #define IENG    ChunkName('I','E','N','G')
68 #define IGNR    ChunkName('I','G','N','R')
69 #define IKEY    ChunkName('I','K','E','Y')
70 #define IMED    ChunkName('I','M','E','D')
71 #define INAM    ChunkName('I','N','A','M')
72 #define IPRD    ChunkName('I','P','R','D')
73 #define ISBJ    ChunkName('I','S','B','J')
74 #define ISFT    ChunkName('I','S','F','T')
75 #define ISRC    ChunkName('I','S','R','C')
76 #define ISRF    ChunkName('I','S','R','F')
77 #define ITCH    ChunkName('I','T','C','H')
78 #define SMPL    ChunkName('s','m','p','l')
79 #define ISTD    ChunkName('I','S','T','D')
80 
81 // added these to support Microsoft's DLS spec *chuckle*
82 #define GUID    ChunkName('g','u','i','d')
83 #define WAVH    ChunkName('w','a','v','h')
84 
85 
86 /*--------------------------------------------------------------------------*/
87 
88 //      standard DLS 1.0 sample loop descriptor
89 typedef struct _DLS_LOOP
90 {
91 
92         u32     size;
93         u32     type;
94         u32     start;
95         u32     length;
96 
97 }       DLS_LOOP, *PDLS_LOOP;
98 
99 
100 /*--------------------------------------------------------------------------*/
101 
102 //      standard DLS 1.0 wsmp chunk
103 typedef struct _DLS_WSMP
104 {
105 
106         u32     size;
107         u16     unityNote;
108         s16     fineTune;
109         s32     attenuation;
110         u32     options;
111         u32     sampleLoops;
112         DLS_LOOP                loop[];
113 
114 } DLS_WSMP, *PDLS_WSMP;
115 
116 
117 /*--------------------------------------------------------------------------*/
118 
119 //      standard DLS 1.0 fmt chunk
120 typedef struct _DLS_FMT
121 {
122 
123         u16     formatTag;
124         u16     channels;
125         u32     samplesPerSec;
126         u32     avgBytesPerSec;
127         u16     blockAlign;
128         u16     bitsPerSample;
129 
130 } DLS_FMT, *PDLS_FMT;
131 
132 
133 /*--------------------------------------------------------------------------*/
134 
135 //      standard DLS 1.0 rgnh chunk
136 typedef struct _DLS_RGNH
137 {
138 
139         u16     lowKey;
140         u16     hiKey;
141         u16     lowVelocity;
142         u16     hiVelocity;
143         u16     options;
144         u16     keyGroup;
145 
146 } DLS_RGNH, *PDLS_RGNH;
147 
148 
149 /*--------------------------------------------------------------------------*/
150 
151 //      standard DLS 1.0 wlnk chunk
152 typedef struct _DLS_WLNK
153 {
154 
155         u16     options;
156         u16     phase;
157         u32     channel;
158         u32     index;
159 
160 } DLS_WLNK, *PDLS_WLNK;
161 
162 
163 /*--------------------------------------------------------------------------*/
164 
165 //      standard DLS 1.0 connection block
166 typedef struct _DLS_CONNECTION
167 {
168 
169         u16     source;
170         u16     control;
171         u16     destination;
172         u16     transform;
173         s32     scale;
174 
175 } DLS_CONNECTION, *PDLS_CONNECTION;
176 
177 
178 /*--------------------------------------------------------------------------*/
179 
180 #define CONN_SRC_NONE                           0x0000
181 #define CONN_SRC_LFO                            0x0001
182 #define CONN_SRC_KEYONVELOCITY          0x0002
183 #define CONN_SRC_KEYNUMBER                      0x0003
184 #define CONN_SRC_EG1                            0x0004
185 #define CONN_SRC_EG2                            0x0005
186 #define CONN_SRC_PITCHWHEEL                     0x0006
187 
188 #define CONN_SRC_CC1                            0x0081  //      mod wheel
189 #define CONN_SRC_CC7                            0x0087  //      channel volume
190 #define CONN_SRC_CC10                           0x008A  //      pan
191 #define CONN_SRC_CC11                           0x008B  //      expression
192 #define CONN_SRC_RPN0                           //      ???     //      pitch bend range
193 #define CONN_SRC_RPN1                           //      ???     //      fine tune
194 #define CONN_SRC_RPN2                           //      ???     //      coarse tune
195 
196 #define CONN_DST_NONE                           0x0000
197 #define CONN_DST_ATTENUATION            0x0001
198 #define CONN_DST_RESERVED                       0x0002
199 #define CONN_DST_PITCH                          0x0003
200 #define CONN_DST_PAN                            0x0004
201 
202 #define CONN_DST_LFO_FREQUENCY          0x0104
203 #define CONN_DST_LFO_STARTDELAY         0x0105
204 
205 #define CONN_DST_EG1_ATTACKTIME         0x0206
206 #define CONN_DST_EG1_DECAYTIME          0x0207
207 #define CONN_DST_EG1_RESERVED           0x0208
208 #define CONN_DST_EG1_RELEASETIME        0x0209
209 #define CONN_DST_EG1_SUSTAINLEVEL       0x020A
210 
211 #define CONN_DST_EG2_ATTACKTIME         0x030A
212 #define CONN_DST_EG2_DECAYTIME          0x030B
213 #define CONN_DST_EG2_RESERVED           0x030C
214 #define CONN_DST_EG2_RELEASETIME        0x030D
215 #define CONN_DST_EG2_SUSTAINLEVEL       0x030E
216 
217 #define CONN_TRN_NONE                           0x0000
218 #define CONN_TRN_CONCAVE                        0x0001
219 
220 // compression mode
221 #define MODE_USE_FLAG       0
222 #define MODE_COMPRESS_ALL   1
223 #define MODE_COMPRESS_NONE  2
224 
225 /*--------------------------------------------------------------------------*/
226 void    dls_read_file               (FILE *dlsFile, FILE *wtFile, FILE *pcmFile, int mode);
227 
228 /*--------------------------------------------------------------------------*/
229 
230 #ifdef __cplusplus
231 }
232 #endif
233 
234 #endif  //__DLS_H__
235