diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/sound/seq_midi_emul.h |
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/sound/seq_midi_emul.h')
-rw-r--r-- | include/sound/seq_midi_emul.h | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/include/sound/seq_midi_emul.h b/include/sound/seq_midi_emul.h new file mode 100644 index 000000000000..e58ca45bc73b --- /dev/null +++ b/include/sound/seq_midi_emul.h | |||
@@ -0,0 +1,195 @@ | |||
1 | #ifndef __SOUND_SEQ_MIDI_EMUL_H | ||
2 | #define __SOUND_SEQ_MIDI_EMUL_H | ||
3 | |||
4 | /* | ||
5 | * Midi channel definition for optional channel management. | ||
6 | * | ||
7 | * Copyright (C) 1999 Steve Ratcliffe | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #include "seq_kernel.h" | ||
26 | |||
27 | /* | ||
28 | * This structure is used to keep track of the current state on each | ||
29 | * channel. All drivers for hardware that does not understand midi | ||
30 | * directly will probably need to use this structure. | ||
31 | */ | ||
32 | typedef struct snd_midi_channel { | ||
33 | void *private; /* A back pointer to driver data */ | ||
34 | int number; /* The channel number */ | ||
35 | int client; /* The client associated with this channel */ | ||
36 | int port; /* The port associated with this channel */ | ||
37 | |||
38 | unsigned char midi_mode; /* GM, GS, XG etc */ | ||
39 | unsigned int | ||
40 | drum_channel:1, /* Drum channel */ | ||
41 | param_type:1 /* RPN/NRPN */ | ||
42 | ; | ||
43 | |||
44 | unsigned char midi_aftertouch; /* Aftertouch (key pressure) */ | ||
45 | unsigned char midi_pressure; /* Channel pressure */ | ||
46 | unsigned char midi_program; /* Instrument number */ | ||
47 | short midi_pitchbend; /* Pitch bend amount */ | ||
48 | |||
49 | unsigned char control[128]; /* Current value of all controls */ | ||
50 | unsigned char note[128]; /* Current status for all notes */ | ||
51 | |||
52 | short gm_rpn_pitch_bend_range; /* Pitch bend range */ | ||
53 | short gm_rpn_fine_tuning; /* Master fine tuning */ | ||
54 | short gm_rpn_coarse_tuning; /* Master coarse tuning */ | ||
55 | |||
56 | } snd_midi_channel_t; | ||
57 | |||
58 | /* | ||
59 | * A structure that represets a set of channels bound to a port. There | ||
60 | * would usually be 16 channels per port. But fewer could be used for | ||
61 | * particular cases. | ||
62 | * The channel set consists of information describing the client and | ||
63 | * port for this midi synth and an array of snd_midi_channel_t structures. | ||
64 | * A driver that had no need for snd_midi_channel_t could still use the | ||
65 | * channel set type if it wished with the channel array null. | ||
66 | */ | ||
67 | typedef struct snd_midi_channel_set { | ||
68 | void *private_data; /* Driver data */ | ||
69 | int client; /* Client for this port */ | ||
70 | int port; /* The port number */ | ||
71 | |||
72 | int max_channels; /* Size of the channels array */ | ||
73 | snd_midi_channel_t *channels; | ||
74 | |||
75 | unsigned char midi_mode; /* MIDI operating mode */ | ||
76 | unsigned char gs_master_volume; /* SYSEX master volume: 0-127 */ | ||
77 | unsigned char gs_chorus_mode; | ||
78 | unsigned char gs_reverb_mode; | ||
79 | |||
80 | } snd_midi_channel_set_t; | ||
81 | |||
82 | typedef struct snd_seq_midi_op { | ||
83 | void (*note_on)(void *private_data, int note, int vel, snd_midi_channel_t *chan); | ||
84 | void (*note_off)(void *private_data,int note, int vel, snd_midi_channel_t *chan); /* release note */ | ||
85 | void (*key_press)(void *private_data, int note, int vel, snd_midi_channel_t *chan); | ||
86 | void (*note_terminate)(void *private_data, int note, snd_midi_channel_t *chan); /* terminate note immediately */ | ||
87 | void (*control)(void *private_data, int type, snd_midi_channel_t *chan); | ||
88 | void (*nrpn)(void *private_data, snd_midi_channel_t *chan, snd_midi_channel_set_t *chset); | ||
89 | void (*sysex)(void *private_data, unsigned char *buf, int len, int parsed, snd_midi_channel_set_t *chset); | ||
90 | } snd_midi_op_t; | ||
91 | |||
92 | /* | ||
93 | * These defines are used so that pitchbend, aftertouch etc, can be | ||
94 | * distinguished from controller values. | ||
95 | */ | ||
96 | /* 0-127 controller values */ | ||
97 | #define MIDI_CTL_PITCHBEND 0x80 | ||
98 | #define MIDI_CTL_AFTERTOUCH 0x81 | ||
99 | #define MIDI_CTL_CHAN_PRESSURE 0x82 | ||
100 | |||
101 | /* | ||
102 | * These names exist to allow symbolic access to the controls array. | ||
103 | * The usage is eg: chan->gm_bank_select. Another implementation would | ||
104 | * be really have these members in the struct, and not the array. | ||
105 | */ | ||
106 | #define gm_bank_select control[0] | ||
107 | #define gm_modulation control[1] | ||
108 | #define gm_breath control[2] | ||
109 | #define gm_foot_pedal control[4] | ||
110 | #define gm_portamento_time control[5] | ||
111 | #define gm_data_entry control[6] | ||
112 | #define gm_volume control[7] | ||
113 | #define gm_balance control[8] | ||
114 | #define gm_pan control[10] | ||
115 | #define gm_expression control[11] | ||
116 | #define gm_effect_control1 control[12] | ||
117 | #define gm_effect_control2 control[13] | ||
118 | #define gm_slider1 control[16] | ||
119 | #define gm_slider2 control[17] | ||
120 | #define gm_slider3 control[18] | ||
121 | #define gm_slider4 control[19] | ||
122 | |||
123 | #define gm_bank_select_lsb control[32] | ||
124 | #define gm_modulation_wheel_lsb control[33] | ||
125 | #define gm_breath_lsb control[34] | ||
126 | #define gm_foot_pedal_lsb control[36] | ||
127 | #define gm_portamento_time_lsb control[37] | ||
128 | #define gm_data_entry_lsb control[38] | ||
129 | #define gm_volume_lsb control[39] | ||
130 | #define gm_balance_lsb control[40] | ||
131 | #define gm_pan_lsb control[42] | ||
132 | #define gm_expression_lsb control[43] | ||
133 | #define gm_effect_control1_lsb control[44] | ||
134 | #define gm_effect_control2_lsb control[45] | ||
135 | |||
136 | #define gm_sustain control[MIDI_CTL_SUSTAIN] | ||
137 | #define gm_hold gm_sustain | ||
138 | #define gm_portamento control[MIDI_CTL_PORTAMENTO] | ||
139 | #define gm_sostenuto control[MIDI_CTL_SOSTENUTO] | ||
140 | |||
141 | /* | ||
142 | * These macros give the complete value of the controls that consist | ||
143 | * of coarse and fine pairs. Of course the fine controls are seldom used | ||
144 | * but there is no harm in being complete. | ||
145 | */ | ||
146 | #define SNDRV_GM_BANK_SELECT(cp) (((cp)->control[0]<<7)|((cp)->control[32])) | ||
147 | #define SNDRV_GM_MODULATION_WHEEL(cp) (((cp)->control[1]<<7)|((cp)->control[33])) | ||
148 | #define SNDRV_GM_BREATH(cp) (((cp)->control[2]<<7)|((cp)->control[34])) | ||
149 | #define SNDRV_GM_FOOT_PEDAL(cp) (((cp)->control[4]<<7)|((cp)->control[36])) | ||
150 | #define SNDRV_GM_PORTAMENTO_TIME(cp) (((cp)->control[5]<<7)|((cp)->control[37])) | ||
151 | #define SNDRV_GM_DATA_ENTRY(cp) (((cp)->control[6]<<7)|((cp)->control[38])) | ||
152 | #define SNDRV_GM_VOLUME(cp) (((cp)->control[7]<<7)|((cp)->control[39])) | ||
153 | #define SNDRV_GM_BALANCE(cp) (((cp)->control[8]<<7)|((cp)->control[40])) | ||
154 | #define SNDRV_GM_PAN(cp) (((cp)->control[10]<<7)|((cp)->control[42])) | ||
155 | #define SNDRV_GM_EXPRESSION(cp) (((cp)->control[11]<<7)|((cp)->control[43])) | ||
156 | |||
157 | |||
158 | /* MIDI mode */ | ||
159 | #define SNDRV_MIDI_MODE_NONE 0 /* Generic midi */ | ||
160 | #define SNDRV_MIDI_MODE_GM 1 | ||
161 | #define SNDRV_MIDI_MODE_GS 2 | ||
162 | #define SNDRV_MIDI_MODE_XG 3 | ||
163 | #define SNDRV_MIDI_MODE_MT32 4 | ||
164 | |||
165 | /* MIDI note state */ | ||
166 | #define SNDRV_MIDI_NOTE_OFF 0x00 | ||
167 | #define SNDRV_MIDI_NOTE_ON 0x01 | ||
168 | #define SNDRV_MIDI_NOTE_RELEASED 0x02 | ||
169 | #define SNDRV_MIDI_NOTE_SOSTENUTO 0x04 | ||
170 | |||
171 | #define SNDRV_MIDI_PARAM_TYPE_REGISTERED 0 | ||
172 | #define SNDRV_MIDI_PARAM_TYPE_NONREGISTERED 1 | ||
173 | |||
174 | /* SYSEX parse flag */ | ||
175 | enum { | ||
176 | SNDRV_MIDI_SYSEX_NOT_PARSED = 0, | ||
177 | SNDRV_MIDI_SYSEX_GM_ON, | ||
178 | SNDRV_MIDI_SYSEX_GS_ON, | ||
179 | SNDRV_MIDI_SYSEX_GS_RESET, | ||
180 | SNDRV_MIDI_SYSEX_GS_CHORUS_MODE, | ||
181 | SNDRV_MIDI_SYSEX_GS_REVERB_MODE, | ||
182 | SNDRV_MIDI_SYSEX_GS_MASTER_VOLUME, | ||
183 | SNDRV_MIDI_SYSEX_GS_PROGRAM, | ||
184 | SNDRV_MIDI_SYSEX_GS_DRUM_CHANNEL, | ||
185 | SNDRV_MIDI_SYSEX_XG_ON, | ||
186 | }; | ||
187 | |||
188 | /* Prototypes for midi_process.c */ | ||
189 | void snd_midi_process_event(snd_midi_op_t *ops, snd_seq_event_t *ev, | ||
190 | snd_midi_channel_set_t *chanset); | ||
191 | void snd_midi_channel_set_clear(snd_midi_channel_set_t *chset); | ||
192 | snd_midi_channel_set_t *snd_midi_channel_alloc_set(int n); | ||
193 | void snd_midi_channel_free_set(snd_midi_channel_set_t *chset); | ||
194 | |||
195 | #endif /* __SOUND_SEQ_MIDI_EMUL_H */ | ||