0001
0002 #ifndef __SOUND_SEQ_MIDI_EMUL_H
0003 #define __SOUND_SEQ_MIDI_EMUL_H
0004
0005
0006
0007
0008
0009
0010
0011 #include <sound/seq_kernel.h>
0012
0013
0014
0015
0016
0017
0018 struct snd_midi_channel {
0019 void *private;
0020 int number;
0021 int client;
0022 int port;
0023
0024 unsigned char midi_mode;
0025 unsigned int
0026 drum_channel:1,
0027 param_type:1
0028 ;
0029
0030 unsigned char midi_aftertouch;
0031 unsigned char midi_pressure;
0032 unsigned char midi_program;
0033 short midi_pitchbend;
0034
0035 unsigned char control[128];
0036 unsigned char note[128];
0037
0038 short gm_rpn_pitch_bend_range;
0039 short gm_rpn_fine_tuning;
0040 short gm_rpn_coarse_tuning;
0041
0042 };
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 struct snd_midi_channel_set {
0054 void *private_data;
0055 int client;
0056 int port;
0057
0058 int max_channels;
0059 struct snd_midi_channel *channels;
0060
0061 unsigned char midi_mode;
0062 unsigned char gs_master_volume;
0063 unsigned char gs_chorus_mode;
0064 unsigned char gs_reverb_mode;
0065
0066 };
0067
0068 struct snd_midi_op {
0069 void (*note_on)(void *private_data, int note, int vel, struct snd_midi_channel *chan);
0070 void (*note_off)(void *private_data,int note, int vel, struct snd_midi_channel *chan);
0071 void (*key_press)(void *private_data, int note, int vel, struct snd_midi_channel *chan);
0072 void (*note_terminate)(void *private_data, int note, struct snd_midi_channel *chan);
0073 void (*control)(void *private_data, int type, struct snd_midi_channel *chan);
0074 void (*nrpn)(void *private_data, struct snd_midi_channel *chan,
0075 struct snd_midi_channel_set *chset);
0076 void (*sysex)(void *private_data, unsigned char *buf, int len, int parsed,
0077 struct snd_midi_channel_set *chset);
0078 };
0079
0080
0081
0082
0083
0084
0085 #define MIDI_CTL_PITCHBEND 0x80
0086 #define MIDI_CTL_AFTERTOUCH 0x81
0087 #define MIDI_CTL_CHAN_PRESSURE 0x82
0088
0089
0090
0091
0092
0093
0094 #define gm_bank_select control[0]
0095 #define gm_modulation control[1]
0096 #define gm_breath control[2]
0097 #define gm_foot_pedal control[4]
0098 #define gm_portamento_time control[5]
0099 #define gm_data_entry control[6]
0100 #define gm_volume control[7]
0101 #define gm_balance control[8]
0102 #define gm_pan control[10]
0103 #define gm_expression control[11]
0104 #define gm_effect_control1 control[12]
0105 #define gm_effect_control2 control[13]
0106 #define gm_slider1 control[16]
0107 #define gm_slider2 control[17]
0108 #define gm_slider3 control[18]
0109 #define gm_slider4 control[19]
0110
0111 #define gm_bank_select_lsb control[32]
0112 #define gm_modulation_wheel_lsb control[33]
0113 #define gm_breath_lsb control[34]
0114 #define gm_foot_pedal_lsb control[36]
0115 #define gm_portamento_time_lsb control[37]
0116 #define gm_data_entry_lsb control[38]
0117 #define gm_volume_lsb control[39]
0118 #define gm_balance_lsb control[40]
0119 #define gm_pan_lsb control[42]
0120 #define gm_expression_lsb control[43]
0121 #define gm_effect_control1_lsb control[44]
0122 #define gm_effect_control2_lsb control[45]
0123
0124 #define gm_sustain control[MIDI_CTL_SUSTAIN]
0125 #define gm_hold gm_sustain
0126 #define gm_portamento control[MIDI_CTL_PORTAMENTO]
0127 #define gm_sostenuto control[MIDI_CTL_SOSTENUTO]
0128
0129
0130
0131
0132
0133
0134 #define SNDRV_GM_BANK_SELECT(cp) (((cp)->control[0]<<7)|((cp)->control[32]))
0135 #define SNDRV_GM_MODULATION_WHEEL(cp) (((cp)->control[1]<<7)|((cp)->control[33]))
0136 #define SNDRV_GM_BREATH(cp) (((cp)->control[2]<<7)|((cp)->control[34]))
0137 #define SNDRV_GM_FOOT_PEDAL(cp) (((cp)->control[4]<<7)|((cp)->control[36]))
0138 #define SNDRV_GM_PORTAMENTO_TIME(cp) (((cp)->control[5]<<7)|((cp)->control[37]))
0139 #define SNDRV_GM_DATA_ENTRY(cp) (((cp)->control[6]<<7)|((cp)->control[38]))
0140 #define SNDRV_GM_VOLUME(cp) (((cp)->control[7]<<7)|((cp)->control[39]))
0141 #define SNDRV_GM_BALANCE(cp) (((cp)->control[8]<<7)|((cp)->control[40]))
0142 #define SNDRV_GM_PAN(cp) (((cp)->control[10]<<7)|((cp)->control[42]))
0143 #define SNDRV_GM_EXPRESSION(cp) (((cp)->control[11]<<7)|((cp)->control[43]))
0144
0145
0146
0147 #define SNDRV_MIDI_MODE_NONE 0
0148 #define SNDRV_MIDI_MODE_GM 1
0149 #define SNDRV_MIDI_MODE_GS 2
0150 #define SNDRV_MIDI_MODE_XG 3
0151 #define SNDRV_MIDI_MODE_MT32 4
0152
0153
0154 #define SNDRV_MIDI_NOTE_OFF 0x00
0155 #define SNDRV_MIDI_NOTE_ON 0x01
0156 #define SNDRV_MIDI_NOTE_RELEASED 0x02
0157 #define SNDRV_MIDI_NOTE_SOSTENUTO 0x04
0158
0159 #define SNDRV_MIDI_PARAM_TYPE_REGISTERED 0
0160 #define SNDRV_MIDI_PARAM_TYPE_NONREGISTERED 1
0161
0162
0163 enum {
0164 SNDRV_MIDI_SYSEX_NOT_PARSED = 0,
0165 SNDRV_MIDI_SYSEX_GM_ON,
0166 SNDRV_MIDI_SYSEX_GS_ON,
0167 SNDRV_MIDI_SYSEX_GS_RESET,
0168 SNDRV_MIDI_SYSEX_GS_CHORUS_MODE,
0169 SNDRV_MIDI_SYSEX_GS_REVERB_MODE,
0170 SNDRV_MIDI_SYSEX_GS_MASTER_VOLUME,
0171 SNDRV_MIDI_SYSEX_GS_PROGRAM,
0172 SNDRV_MIDI_SYSEX_GS_DRUM_CHANNEL,
0173 SNDRV_MIDI_SYSEX_XG_ON,
0174 };
0175
0176
0177 void snd_midi_process_event(const struct snd_midi_op *ops,
0178 struct snd_seq_event *ev,
0179 struct snd_midi_channel_set *chanset);
0180 void snd_midi_channel_set_clear(struct snd_midi_channel_set *chset);
0181 struct snd_midi_channel_set *snd_midi_channel_alloc_set(int n);
0182 void snd_midi_channel_free_set(struct snd_midi_channel_set *chset);
0183
0184 #endif