1
2 #ifndef __SOUND_SEQ_MIDI_EMUL_H
3 #define __SOUND_SEQ_MIDI_EMUL_H
4
5
6
7
8
9
10
11 #include <sound/seq_kernel.h>
12
13
14
15
16
17
18 struct snd_midi_channel {
19 void *private;
20 int number;
21 int client;
22 int port;
23
24 unsigned char midi_mode;
25 unsigned int
26 drum_channel:1,
27 param_type:1
28 ;
29
30 unsigned char midi_aftertouch;
31 unsigned char midi_pressure;
32 unsigned char midi_program;
33 short midi_pitchbend;
34
35 unsigned char control[128];
36 unsigned char note[128];
37
38 short gm_rpn_pitch_bend_range;
39 short gm_rpn_fine_tuning;
40 short gm_rpn_coarse_tuning;
41
42 };
43
44
45
46
47
48
49
50
51
52
53 struct snd_midi_channel_set {
54 void *private_data;
55 int client;
56 int port;
57
58 int max_channels;
59 struct snd_midi_channel *channels;
60
61 unsigned char midi_mode;
62 unsigned char gs_master_volume;
63 unsigned char gs_chorus_mode;
64 unsigned char gs_reverb_mode;
65
66 };
67
68 struct snd_midi_op {
69 void (*note_on)(void *private_data, int note, int vel, struct snd_midi_channel *chan);
70 void (*note_off)(void *private_data,int note, int vel, struct snd_midi_channel *chan);
71 void (*key_press)(void *private_data, int note, int vel, struct snd_midi_channel *chan);
72 void (*note_terminate)(void *private_data, int note, struct snd_midi_channel *chan);
73 void (*control)(void *private_data, int type, struct snd_midi_channel *chan);
74 void (*nrpn)(void *private_data, struct snd_midi_channel *chan,
75 struct snd_midi_channel_set *chset);
76 void (*sysex)(void *private_data, unsigned char *buf, int len, int parsed,
77 struct snd_midi_channel_set *chset);
78 };
79
80
81
82
83
84
85 #define MIDI_CTL_PITCHBEND 0x80
86 #define MIDI_CTL_AFTERTOUCH 0x81
87 #define MIDI_CTL_CHAN_PRESSURE 0x82
88
89
90
91
92
93
94 #define gm_bank_select control[0]
95 #define gm_modulation control[1]
96 #define gm_breath control[2]
97 #define gm_foot_pedal control[4]
98 #define gm_portamento_time control[5]
99 #define gm_data_entry control[6]
100 #define gm_volume control[7]
101 #define gm_balance control[8]
102 #define gm_pan control[10]
103 #define gm_expression control[11]
104 #define gm_effect_control1 control[12]
105 #define gm_effect_control2 control[13]
106 #define gm_slider1 control[16]
107 #define gm_slider2 control[17]
108 #define gm_slider3 control[18]
109 #define gm_slider4 control[19]
110
111 #define gm_bank_select_lsb control[32]
112 #define gm_modulation_wheel_lsb control[33]
113 #define gm_breath_lsb control[34]
114 #define gm_foot_pedal_lsb control[36]
115 #define gm_portamento_time_lsb control[37]
116 #define gm_data_entry_lsb control[38]
117 #define gm_volume_lsb control[39]
118 #define gm_balance_lsb control[40]
119 #define gm_pan_lsb control[42]
120 #define gm_expression_lsb control[43]
121 #define gm_effect_control1_lsb control[44]
122 #define gm_effect_control2_lsb control[45]
123
124 #define gm_sustain control[MIDI_CTL_SUSTAIN]
125 #define gm_hold gm_sustain
126 #define gm_portamento control[MIDI_CTL_PORTAMENTO]
127 #define gm_sostenuto control[MIDI_CTL_SOSTENUTO]
128
129
130
131
132
133
134 #define SNDRV_GM_BANK_SELECT(cp) (((cp)->control[0]<<7)|((cp)->control[32]))
135 #define SNDRV_GM_MODULATION_WHEEL(cp) (((cp)->control[1]<<7)|((cp)->control[33]))
136 #define SNDRV_GM_BREATH(cp) (((cp)->control[2]<<7)|((cp)->control[34]))
137 #define SNDRV_GM_FOOT_PEDAL(cp) (((cp)->control[4]<<7)|((cp)->control[36]))
138 #define SNDRV_GM_PORTAMENTO_TIME(cp) (((cp)->control[5]<<7)|((cp)->control[37]))
139 #define SNDRV_GM_DATA_ENTRY(cp) (((cp)->control[6]<<7)|((cp)->control[38]))
140 #define SNDRV_GM_VOLUME(cp) (((cp)->control[7]<<7)|((cp)->control[39]))
141 #define SNDRV_GM_BALANCE(cp) (((cp)->control[8]<<7)|((cp)->control[40]))
142 #define SNDRV_GM_PAN(cp) (((cp)->control[10]<<7)|((cp)->control[42]))
143 #define SNDRV_GM_EXPRESSION(cp) (((cp)->control[11]<<7)|((cp)->control[43]))
144
145
146
147 #define SNDRV_MIDI_MODE_NONE 0
148 #define SNDRV_MIDI_MODE_GM 1
149 #define SNDRV_MIDI_MODE_GS 2
150 #define SNDRV_MIDI_MODE_XG 3
151 #define SNDRV_MIDI_MODE_MT32 4
152
153
154 #define SNDRV_MIDI_NOTE_OFF 0x00
155 #define SNDRV_MIDI_NOTE_ON 0x01
156 #define SNDRV_MIDI_NOTE_RELEASED 0x02
157 #define SNDRV_MIDI_NOTE_SOSTENUTO 0x04
158
159 #define SNDRV_MIDI_PARAM_TYPE_REGISTERED 0
160 #define SNDRV_MIDI_PARAM_TYPE_NONREGISTERED 1
161
162
163 enum {
164 SNDRV_MIDI_SYSEX_NOT_PARSED = 0,
165 SNDRV_MIDI_SYSEX_GM_ON,
166 SNDRV_MIDI_SYSEX_GS_ON,
167 SNDRV_MIDI_SYSEX_GS_RESET,
168 SNDRV_MIDI_SYSEX_GS_CHORUS_MODE,
169 SNDRV_MIDI_SYSEX_GS_REVERB_MODE,
170 SNDRV_MIDI_SYSEX_GS_MASTER_VOLUME,
171 SNDRV_MIDI_SYSEX_GS_PROGRAM,
172 SNDRV_MIDI_SYSEX_GS_DRUM_CHANNEL,
173 SNDRV_MIDI_SYSEX_XG_ON,
174 };
175
176
177 void snd_midi_process_event(struct snd_midi_op *ops, struct snd_seq_event *ev,
178 struct snd_midi_channel_set *chanset);
179 void snd_midi_channel_set_clear(struct snd_midi_channel_set *chset);
180 struct snd_midi_channel_set *snd_midi_channel_alloc_set(int n);
181 void snd_midi_channel_free_set(struct snd_midi_channel_set *chset);
182
183 #endif