1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - include - snd - common
3   File:     midiplayer.h
4 
5   Copyright 2004-2008 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   $Date:: 2008-09-18#$
14   $Rev: 8573 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NITRO_SND_COMMON_MIDI_PLAYER_H_
19 #define NITRO_SND_COMMON_MIDI_PLAYER_H_
20 
21 #include <nitro/types.h>
22 #include <nitro/snd/common/channel.h>
23 #include <nitro/snd/common/exchannel.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /******************************************************************************
30 	macro definition
31  ******************************************************************************/
32 
33 #define SND_MIDI_TRACK_NUM 16
34 
35 /******************************************************************************
36 	structure definition
37  ******************************************************************************/
38 
39 struct SNDBankData;
40 
41 typedef struct SNDMidiChannel
42 {
43     struct SNDExChannel *chp;
44     u8      key;
45     u8      pad1;
46     u16     pad2;
47 }
48 SNDMidiChannel;
49 
50 typedef struct SNDMidiTrack
51 {
52     struct SNDMidiChannel channels[SND_CHANNEL_NUM];
53     SNDLfoParam mod;
54 
55     s16     sweep_pitch;
56 
57     u16     prgNo;
58     s8      pitchbend;
59 
60     u8      porta_time;
61     u8      volume;
62     s8      pan;
63     u8      expression;
64     s8      transpose;
65     u8      prio;
66     u8      bendrange;
67     u8      porta_flag;
68     u8      porta_key;
69     u8      attack;
70     u8      decay;
71     u8      sustain;
72     u8      release;
73 
74     u8      rpnLSB;
75     u8      rpnMSB;
76     u8      nrpnLSB;
77     u8      nrpnMSB;
78     u8      rpn_flag;
79     u8      pad1;
80     u16     pad2;
81 }
82 SNDMidiTrack;
83 
84 typedef struct SNDMidiPlayer
85 {
86     const struct SNDBankData *bank;
87     SNDMidiTrack track[SND_MIDI_TRACK_NUM];
88 
89     u8      main_volume;
90     u8      prio;
91     u16     pad;
92 }
93 SNDMidiPlayer;
94 
95 /******************************************************************************
96 	public function declaration
97  ******************************************************************************/
98 
99 #ifdef SDK_ARM7
100 
101 void    SND_MidiPlayerInit(SNDMidiPlayer * player);
102 void    SND_MidiPlayerMain(SNDMidiPlayer * player);
103 void    SND_MidiPlayerSetBank(SNDMidiPlayer * player, const struct SNDBankData *bank);
104 void    SND_MidiPlayerProgramChange(SNDMidiPlayer * player, int channel, int prgNo);
105 void    SND_MidiPlayerSendMessage(SNDMidiPlayer * player, u8 status, u8 data1, u8 data2);
106 void    SND_MidiPlayerReset(SNDMidiPlayer * player);
107 
108 #endif
109 
110 #ifdef __cplusplus
111 } /* extern "C" */
112 #endif
113 
114 #endif /* NITRO_SND_COMMON_MIDI_PLAYER_H_ */
115