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