1 /*---------------------------------------------------------------------------*
2   Project:  DLS converter for SYN
3   File:     wt.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: wt.h,v $
14   Revision 1.2  2006/02/08 06:21:15  aka
15   Changed copyright.
16 
17   Revision 1.1  2005/11/04 06:12:01  aka
18   Copied from Dolphin tree.
19 
20     1     5/20/01 11:48p Eugene
21     DLS1.0 WaveTable converter. For use with AX/SEQ/SYN/MIX.
22     Source code provided to developers so they may create their own tool
23     chain. MSVC++ project (bleah).
24 
25   $NoKeywords: $
26  *---------------------------------------------------------------------------*/
27 
28 #ifndef __WT_H__
29 #define __WT_H__
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36 #define WT_ART_FLAG_LFO     0x00000001
37 #define WT_ART_FLAG_EG1     0x00000002
38 #define WT_ART_FLAG_EG2     0x00000004
39 
40 #define WT_ADSR_ATTACK      0
41 #define WT_ADSR_DECAY       1
42 #define WT_ADSR_SUSTAIN     2
43 #define WT_ADSR_RELEASE     3
44 */
45 
46 typedef struct WTART    // translated DLS articulation block
47 {
48     // LFO
49     s32 lfoFreq;
50     s32 lfoDelay;
51     s32 lfoAtten;
52     s32 lfoPitch;
53     s32 lfoMod2Atten;
54     s32 lfoMod2Pitch;
55 
56     // EG1
57     s32 eg1Attack;
58     s32 eg1Decay;
59     s32 eg1Sustain;
60     s32 eg1Release;
61     s32 eg1Vel2Attack;
62     s32 eg1Key2Decay;
63 
64     // EG2
65     s32 eg2Attack;
66     s32 eg2Decay;
67     s32 eg2Sustain;
68     s32 eg2Release;
69     s32 eg2Vel2Attack;
70     s32 eg2Key2Decay;
71     s32 eg2Pitch;
72 
73     // pan
74     s32 pan;
75 
76 } WTART;
77 
78 typedef struct WTREGION
79 {
80 
81 //    u8  loKey;
82 //    u8  hiKey;
83 //    u8  loVel;
84 //    u8  hiVel;
85     u8  unityNote;
86     u8  keyGroup;
87 
88     s16 fineTune;
89     s32 attn;
90 
91     u32 loopStart;
92     u32 loopLength;
93 
94     u32 articulationIndex;  // articulation index to reference
95     u32 sampleIndex;        // sample index to reference
96 
97 } WTREGION;
98 
99 typedef struct WTSAMPLE
100 {
101     u16 format;     // ADPCM, PCM16, PCM8
102     u16 sampleRate; // Hz
103     u32 offset;     // offset in bytes from beginning of PCM file
104     u32 length;     // length of sample in bytes
105     u16 adpcmIndex; // ADPCM index to reference if in ADPCM mode
106 
107 } WTSAMPLE;
108 
109 #define WT_FORMAT_ADPCM 0
110 #define WT_FORMAT_PCM16 1
111 #define WT_FORMAT_PCM8  2
112 
113 typedef struct WTADPCM
114 {
115 
116     // values to program at start
117     u16     a[8][2];            //  coef table a1[0],a2[0],a1[1],a2[1]....
118     u16     gain;               //  gain to be applied (0 for ADPCM, 0x0800 for PCM8/16)
119     u16     pred_scale;         //  predictor / scale combination (nibbles, as in hardware)
120     u16     yn1;                //  y[n - 1]
121     u16     yn2;                //  y[n - 2]
122 
123     // loop context
124     u16     loop_pred_scale;    //  predictor / scale combination (nibbles, as in hardware)
125     u16     loop_yn1;           //  y[n - 1]
126     u16     loop_yn2;           //  y[n - 2]
127 
128 } WTADPCM;
129 
130 typedef struct WTINST   // instrument
131 {
132 
133     u16 keyRegion[128];
134 
135 } WTINST;
136 
137 typedef struct WTFILEHEADER   // FILE
138 {
139 
140     u32 offsetPercussiveInst;
141     u32 offsetMelodicInst;
142     u32 offsetRegions;
143     u32 offsetArticulations;
144     u32 offsetSamples;
145     u32 offsetAdpcmContext;
146 
147     // data
148 
149 } WTFILEHEADER;
150 
151 
152 #ifdef __cplusplus
153 }
154 #endif
155 
156 #endif // __WT_H__
157