1 /*---------------------------------------------------------------------------*
2   Project:  Synth application for AX
3   File:     syn.h
4 
5   Copyright (C)1998-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: syn.h,v $
14   Revision 1.5  07/25/2006 08:07:55  aka
15   Modified to support controller speakers.
16 
17   Revision 1.4  2006/01/31 06:02:06  aka
18   Changed arguments of SYNInitSynth().
19 
20   Revision 1.3  01/30/2006 11:50:10  aka
21   Changed copyright.
22 
23   Revision 1.2  01/30/2006 11:31:35  aka
24   Renamed from ARAM to MRAM.
25 
26   Revision 1.1.1.1  2005/05/12 02:41:07  yasuh-to
27   Imported from dolphin tree.
28 
29     2     8/16/01 12:27p Billyjack
30     added zeroBuffer offset to API
31 
32     1     5/09/01 1:28p Billyjack
33     created
34 
35   $NoKeywords: $
36  *---------------------------------------------------------------------------*/
37 
38 #ifndef __SYN_H__
39 #define __SYN_H__
40 
41 #include <revolution/wt.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 #define SYN_INPUT_BUFFER_SIZE      256
48 
49 typedef struct SYNSYNTH SYNSYNTH;
50 
51 typedef void (*SYNCallback)(AXVPB *axvpb, SYNSYNTH *synth, u8 midiChannel);
52 
53 struct SYNSYNTH
54 {
55     void        *next;                  // synth list
56 
57     WTINST      *percussiveInst;        // pointer to instrument[0] in wavetable
58     WTINST      *melodicInst;           // pointer to instrument[0] in wavetable
59     WTREGION    *region;                // pointer to region[0] in wavetable
60     WTART       *art;                   // pointer to articulation[0] in wavetable
61     WTSAMPLE    *sample;                // pointer to sample[0] in wavetable
62     WTADPCM     *adpcm;                 // pointer to adpcm[0] in wavetable
63     u32         samplesBaseWord;        // base address (16bit) of samples in RAM
64     u32         samplesBaseByte;        // base address (8bit)of samples in RAM
65     u32         samplesBaseNibble;      // base address (nibble) of samples in RAM
66     u32         zeroBaseWord;           // base address (16bit) of zero buffer in RAM
67     u32         zeroBaseByte;           // base address (8bit)of zero buffer in RAM
68     u32         zeroBaseNibble;         // base address (nibble) of zero buffer in RAM
69     u32         priorityVoiceAlloc;     // priority for allocating new note
70     u32         priorityNoteOn;         // priority for notes that are on
71     u32         priorityNoteRelease;    // priority for notes being released
72 
73     WTINST      *inst       [16];       // pointer to instrument per channel
74 
75     s32         masterVolume;           // master volume for synth
76 
77     u8          controller  [16][128];  // MIDI controller registers
78 
79     u8          rpn         [16];       // weather to enter rpn or nrpn data
80     s16         dataEntry   [16];       // data entry value
81 
82     s32         pwMaxCents  [16];       // pitch wheel cents at + max
83     s32         pwCents     [16];       // current pitch wheel cents
84 
85     s32         volAttn     [16];       // MIDI channel volume
86     s32         expAttn     [16];       // expression volume
87     s32         auxAAttn    [16];       // aux A (reverb)
88     s32         auxBAttn    [16];       // aux B (chorus)
89 
90     u8          input[SYN_INPUT_BUFFER_SIZE][3];
91     u8          *inputPosition;
92     u32         inputCounter;
93 
94     u32         notes;                  // notes running
95 
96     void        *keyGroup[16][16];      // storage for key group notes
97     void        *voice[16][128];        // storage for voices index references
98 
99     SYNCallback initCallback;
100     SYNCallback updateCallback;
101 
102 };
103 
104 
105 void	SYNInit				(void);
106 void	SYNQuit				(void);
107 void    SYNRunAudioFrame    (void);
108 
109 void    SYNInitSynth        (
110                              SYNSYNTH *synth,                // user allocated synth
111                              u8       *wavetable,            // pointer to wave table
112                              u8       *samples,              // pointer to samples
113                              u8       *zerobuffer,           // pointer to zero buffer
114                              u32      priorityVoiceAlloc,    // priority for voice allocation
115                              u32      priorityNoteOn,        // priority for note on
116                              u32      priorityNoteRelease    // priority for note release
117                              );
118 
119 void    SYNQuitSynth        (SYNSYNTH *synth);
120 void    SYNMidiInput        (SYNSYNTH *synth, u8 *input);
121 u8      SYNGetMidiController(SYNSYNTH *synth, u8 midiChannel, u8 function);
122 void    SYNSetMasterVolume  (SYNSYNTH *synth, s32 dB);
123 s32     SYNGetMasterVolume  (SYNSYNTH *synth);
124 u32     SYNGetActiveNotes   (SYNSYNTH *synth);
125 
126 SYNCallback SYNSetInitCallback  (SYNSYNTH *synth, SYNCallback callback);
127 SYNCallback SYNSetUpdateCallback(SYNSYNTH *synth, SYNCallback callback);
128 
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif // __SYN_H__
135