1 /*---------------------------------------------------------------------------*
2   Project:  Wavetable definitions for AX synthesizer
3   File:     wt.h
4 
5   Copyright 1998-2011 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  *---------------------------------------------------------------------------*/
14 
15 #ifndef __WT_H__
16 #define __WT_H__
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 typedef struct WTART    // translated DLS articulation block
23 {
24     // LFO
25     s32 lfoFreq;
26     s32 lfoDelay;
27     s32 lfoAtten;
28     s32 lfoPitch;
29     s32 lfoMod2Atten;
30     s32 lfoMod2Pitch;
31 
32     // EG1
33     s32 eg1Attack;
34     s32 eg1Decay;
35     s32 eg1Sustain;
36     s32 eg1Release;
37     s32 eg1Vel2Attack;
38     s32 eg1Key2Decay;
39 
40     // EG2
41     s32 eg2Attack;
42     s32 eg2Decay;
43     s32 eg2Sustain;
44     s32 eg2Release;
45     s32 eg2Vel2Attack;
46     s32 eg2Key2Decay;
47     s32 eg2Pitch;
48 
49     // pan
50     s32 pan;
51 
52 } WTART;
53 
54 typedef struct WTREGION
55 {
56     u8  unityNote;
57     u8  keyGroup;
58 
59     s16 fineTune;
60     s32 attn;
61 
62     u32 loopStart;
63     u32 loopLength;
64 
65     u32 articulationIndex;  // articulation index to reference
66     u32 sampleIndex;        // sample index to reference
67 
68 } WTREGION;
69 
70 #ifdef  __MWERKS__
71 #pragma warn_padding off
72 #endif
73 
74 typedef struct WTSAMPLE
75 {
76     u16 format;     // ADPCM, PCM16, PCM8
77     u16 sampleRate; // Hz
78     u32 offset;     // offset in samples from beginning of PCM file
79     u32 length;     // length of sample in samples
80     u16 adpcmIndex; // ADPCM index to reference if in ADPCM mode
81 
82 } WTSAMPLE;
83 
84 #ifdef  __MWERKS__
85 #pragma warn_padding reset
86 #endif
87 
88 #define WT_FORMAT_ADPCM 0
89 #define WT_FORMAT_PCM16 1
90 #define WT_FORMAT_PCM8  2
91 
92 typedef struct WTADPCM
93 {
94 
95     // values to program at start
96     u16     a[8][2];            //  coef table a1[0],a2[0],a1[1],a2[1]....
97     u16     gain;               //  gain to be applied (0 for ADPCM, 0x0800 for PCM8/16)
98     u16     pred_scale;         //  predictor / scale combination (nibbles, as in hardware)
99     u16     yn1;                //  y[n - 1]
100     u16     yn2;                //  y[n - 2]
101 
102     // loop context
103     u16     loop_pred_scale;    //  predictor / scale combination (nibbles, as in hardware)
104     u16     loop_yn1;           //  y[n - 1]
105     u16     loop_yn2;           //  y[n - 2]
106 
107 } WTADPCM;
108 
109 typedef struct WTINST   // instrument
110 {
111 
112     u16 keyRegion[128];
113 
114 } WTINST;
115 
116 typedef struct WTFILEHEADER   // FILE
117 {
118 
119     u32 offsetPercussiveInst;
120     u32 offsetMelodicInst;
121     u32 offsetRegions;
122     u32 offsetArticulations;
123     u32 offsetSamples;
124     u32 offsetAdpcmContext;
125 
126     // data
127 
128 } WTFILEHEADER;
129 
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif // __WT_H__
136