Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Advanced Linux Sound Architecture | |
3 | * | |
4 | * InterWave FFFF Instrument Format | |
c1017a4c | 5 | * Copyright (c) 1994-99 by Jaroslav Kysela <perex@perex.cz> |
1da177e4 LT |
6 | * |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | * | |
22 | */ | |
23 | ||
24 | #ifndef __SOUND_AINSTR_IW_H | |
25 | #define __SOUND_AINSTR_IW_H | |
26 | ||
27 | #ifndef __KERNEL__ | |
28 | #include <asm/types.h> | |
29 | #include <asm/byteorder.h> | |
30 | #endif | |
31 | ||
32 | /* | |
33 | * share types (share ID 1) | |
34 | */ | |
35 | ||
36 | #define IWFFFF_SHARE_FILE 0 | |
37 | ||
38 | /* | |
39 | * wave formats | |
40 | */ | |
41 | ||
42 | #define IWFFFF_WAVE_16BIT 0x0001 /* 16-bit wave */ | |
43 | #define IWFFFF_WAVE_UNSIGNED 0x0002 /* unsigned wave */ | |
44 | #define IWFFFF_WAVE_INVERT 0x0002 /* same as unsigned wave */ | |
45 | #define IWFFFF_WAVE_BACKWARD 0x0004 /* backward mode (maybe used for reverb or ping-ping loop) */ | |
46 | #define IWFFFF_WAVE_LOOP 0x0008 /* loop mode */ | |
47 | #define IWFFFF_WAVE_BIDIR 0x0010 /* bidirectional mode */ | |
48 | #define IWFFFF_WAVE_ULAW 0x0020 /* uLaw compressed wave */ | |
49 | #define IWFFFF_WAVE_RAM 0x0040 /* wave is _preloaded_ in RAM (it is used for ROM simulation) */ | |
50 | #define IWFFFF_WAVE_ROM 0x0080 /* wave is in ROM */ | |
51 | #define IWFFFF_WAVE_STEREO 0x0100 /* wave is stereo */ | |
52 | ||
53 | /* | |
54 | * Wavetable definitions | |
55 | */ | |
56 | ||
19ac31e8 | 57 | struct iwffff_wave { |
1da177e4 LT |
58 | unsigned int share_id[4]; /* share id - zero = no sharing */ |
59 | unsigned int format; /* wave format */ | |
60 | ||
61 | struct { | |
62 | unsigned int number; /* some other ID for this wave */ | |
63 | unsigned int memory; /* begin of waveform in onboard memory */ | |
64 | unsigned char *ptr; /* pointer to waveform in system memory */ | |
65 | } address; | |
66 | ||
67 | unsigned int size; /* size of waveform in samples */ | |
68 | unsigned int start; /* start offset in samples * 16 (lowest 4 bits - fraction) */ | |
69 | unsigned int loop_start; /* bits loop start offset in samples * 16 (lowest 4 bits - fraction) */ | |
70 | unsigned int loop_end; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */ | |
71 | unsigned short loop_repeat; /* loop repeat - 0 = forever */ | |
72 | unsigned int sample_ratio; /* sample ratio (44100 * 1024 / rate) */ | |
73 | unsigned char attenuation; /* 0 - 127 (no corresponding midi controller) */ | |
74 | unsigned char low_note; /* lower frequency range for this waveform */ | |
75 | unsigned char high_note; /* higher frequency range for this waveform */ | |
76 | unsigned char pad; | |
77 | ||
78 | struct iwffff_wave *next; | |
19ac31e8 | 79 | }; |
1da177e4 LT |
80 | |
81 | /* | |
82 | * Layer | |
83 | */ | |
84 | ||
85 | #define IWFFFF_LFO_SHAPE_TRIANGLE 0 | |
86 | #define IWFFFF_LFO_SHAPE_POSTRIANGLE 1 | |
87 | ||
19ac31e8 | 88 | struct iwffff_lfo { |
1da177e4 LT |
89 | unsigned short freq; /* (0-2047) 0.01Hz - 21.5Hz */ |
90 | signed short depth; /* volume +- (0-255) 0.48675dB/step */ | |
91 | signed short sweep; /* 0 - 950 deciseconds */ | |
92 | unsigned char shape; /* see to IWFFFF_LFO_SHAPE_XXXX */ | |
93 | unsigned char delay; /* 0 - 255 deciseconds */ | |
19ac31e8 | 94 | }; |
1da177e4 LT |
95 | |
96 | #define IWFFFF_ENV_FLAG_RETRIGGER 0x0001 /* flag - retrigger */ | |
97 | ||
98 | #define IWFFFF_ENV_MODE_ONE_SHOT 0x0001 /* mode - one shot */ | |
99 | #define IWFFFF_ENV_MODE_SUSTAIN 0x0002 /* mode - sustain */ | |
100 | #define IWFFFF_ENV_MODE_NO_SUSTAIN 0x0003 /* mode - no sustain */ | |
101 | ||
102 | #define IWFFFF_ENV_INDEX_VELOCITY 0x0001 /* index - velocity */ | |
103 | #define IWFFFF_ENV_INDEX_FREQUENCY 0x0002 /* index - frequency */ | |
104 | ||
19ac31e8 | 105 | struct iwffff_env_point { |
1da177e4 LT |
106 | unsigned short offset; |
107 | unsigned short rate; | |
19ac31e8 | 108 | }; |
1da177e4 | 109 | |
19ac31e8 | 110 | struct iwffff_env_record { |
1da177e4 LT |
111 | unsigned short nattack; |
112 | unsigned short nrelease; | |
113 | unsigned short sustain_offset; | |
114 | unsigned short sustain_rate; | |
115 | unsigned short release_rate; | |
116 | unsigned char hirange; | |
117 | unsigned char pad; | |
118 | struct iwffff_env_record *next; | |
119 | /* points are stored here */ | |
120 | /* count of points = nattack + nrelease */ | |
19ac31e8 | 121 | }; |
1da177e4 | 122 | |
19ac31e8 | 123 | struct iwffff_env { |
1da177e4 LT |
124 | unsigned char flags; |
125 | unsigned char mode; | |
126 | unsigned char index; | |
127 | unsigned char pad; | |
128 | struct iwffff_env_record *record; | |
19ac31e8 | 129 | }; |
1da177e4 LT |
130 | |
131 | #define IWFFFF_LAYER_FLAG_RETRIGGER 0x0001 /* retrigger */ | |
132 | ||
133 | #define IWFFFF_LAYER_VELOCITY_TIME 0x0000 /* velocity mode = time */ | |
134 | #define IWFFFF_LAYER_VELOCITY_RATE 0x0001 /* velocity mode = rate */ | |
135 | ||
136 | #define IWFFFF_LAYER_EVENT_KUP 0x0000 /* layer event - key up */ | |
137 | #define IWFFFF_LAYER_EVENT_KDOWN 0x0001 /* layer event - key down */ | |
138 | #define IWFFFF_LAYER_EVENT_RETRIG 0x0002 /* layer event - retrigger */ | |
139 | #define IWFFFF_LAYER_EVENT_LEGATO 0x0003 /* layer event - legato */ | |
140 | ||
19ac31e8 | 141 | struct iwffff_layer { |
1da177e4 LT |
142 | unsigned char flags; |
143 | unsigned char velocity_mode; | |
144 | unsigned char layer_event; | |
145 | unsigned char low_range; /* range for layer based */ | |
146 | unsigned char high_range; /* on either velocity or frequency */ | |
147 | unsigned char pan; /* pan offset from CC1 (0 left - 127 right) */ | |
148 | unsigned char pan_freq_scale; /* position based on frequency (0-127) */ | |
149 | unsigned char attenuation; /* 0-127 (no corresponding midi controller) */ | |
19ac31e8 TI |
150 | struct iwffff_lfo tremolo; /* tremolo effect */ |
151 | struct iwffff_lfo vibrato; /* vibrato effect */ | |
1da177e4 LT |
152 | unsigned short freq_scale; /* 0-2048, 1024 is equal to semitone scaling */ |
153 | unsigned char freq_center; /* center for keyboard frequency scaling */ | |
154 | unsigned char pad; | |
19ac31e8 TI |
155 | struct iwffff_env penv; /* pitch envelope */ |
156 | struct iwffff_env venv; /* volume envelope */ | |
1da177e4 | 157 | |
19ac31e8 | 158 | struct iwffff_wave *wave; |
1da177e4 | 159 | struct iwffff_layer *next; |
19ac31e8 | 160 | }; |
1da177e4 LT |
161 | |
162 | /* | |
163 | * Instrument | |
164 | */ | |
165 | ||
166 | #define IWFFFF_EXCLUDE_NONE 0x0000 /* exclusion mode - none */ | |
167 | #define IWFFFF_EXCLUDE_SINGLE 0x0001 /* exclude single - single note from the instrument group */ | |
168 | #define IWFFFF_EXCLUDE_MULTIPLE 0x0002 /* exclude multiple - stop only same note from this instrument */ | |
169 | ||
170 | #define IWFFFF_LAYER_NONE 0x0000 /* not layered */ | |
171 | #define IWFFFF_LAYER_ON 0x0001 /* layered */ | |
172 | #define IWFFFF_LAYER_VELOCITY 0x0002 /* layered by velocity */ | |
173 | #define IWFFFF_LAYER_FREQUENCY 0x0003 /* layered by frequency */ | |
174 | ||
175 | #define IWFFFF_EFFECT_NONE 0 | |
176 | #define IWFFFF_EFFECT_REVERB 1 | |
177 | #define IWFFFF_EFFECT_CHORUS 2 | |
178 | #define IWFFFF_EFFECT_ECHO 3 | |
179 | ||
19ac31e8 | 180 | struct iwffff_instrument { |
1da177e4 LT |
181 | unsigned short exclusion; |
182 | unsigned short layer_type; | |
183 | unsigned short exclusion_group; /* 0 - none, 1-65535 */ | |
184 | ||
185 | unsigned char effect1; /* effect 1 */ | |
186 | unsigned char effect1_depth; /* 0-127 */ | |
187 | unsigned char effect2; /* effect 2 */ | |
188 | unsigned char effect2_depth; /* 0-127 */ | |
189 | ||
19ac31e8 TI |
190 | struct iwffff_layer *layer; /* first layer */ |
191 | }; | |
1da177e4 LT |
192 | |
193 | /* | |
194 | * | |
195 | * Kernel <-> user space | |
196 | * Hardware (CPU) independent section | |
197 | * | |
198 | * * = zero or more | |
199 | * + = one or more | |
200 | * | |
201 | * iwffff_xinstrument IWFFFF_STRU_INSTR | |
202 | * +iwffff_xlayer IWFFFF_STRU_LAYER | |
203 | * *iwffff_xenv_record IWFFFF_STRU_ENV_RECT (tremolo) | |
204 | * *iwffff_xenv_record IWFFFF_STRU_EVN_RECT (vibrato) | |
205 | * +iwffff_xwave IWFFFF_STRU_WAVE | |
206 | * | |
207 | */ | |
208 | ||
209 | #define IWFFFF_STRU_WAVE __cpu_to_be32(('W'<<24)|('A'<<16)|('V'<<8)|'E') | |
210 | #define IWFFFF_STRU_ENV_RECP __cpu_to_be32(('E'<<24)|('N'<<16)|('R'<<8)|'P') | |
211 | #define IWFFFF_STRU_ENV_RECV __cpu_to_be32(('E'<<24)|('N'<<16)|('R'<<8)|'V') | |
212 | #define IWFFFF_STRU_LAYER __cpu_to_be32(('L'<<24)|('A'<<16)|('Y'<<8)|'R') | |
213 | #define IWFFFF_STRU_INSTR __cpu_to_be32(('I'<<24)|('N'<<16)|('S'<<8)|'T') | |
214 | ||
215 | /* | |
216 | * Wavetable definitions | |
217 | */ | |
218 | ||
19ac31e8 | 219 | struct iwffff_xwave { |
1da177e4 LT |
220 | __u32 stype; /* structure type */ |
221 | ||
222 | __u32 share_id[4]; /* share id - zero = no sharing */ | |
223 | ||
224 | __u32 format; /* wave format */ | |
225 | __u32 offset; /* offset to ROM (address) */ | |
226 | ||
227 | __u32 size; /* size of waveform in samples */ | |
228 | __u32 start; /* start offset in samples * 16 (lowest 4 bits - fraction) */ | |
229 | __u32 loop_start; /* bits loop start offset in samples * 16 (lowest 4 bits - fraction) */ | |
230 | __u32 loop_end; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */ | |
231 | __u16 loop_repeat; /* loop repeat - 0 = forever */ | |
232 | __u32 sample_ratio; /* sample ratio (44100 * 1024 / rate) */ | |
233 | __u8 attenuation; /* 0 - 127 (no corresponding midi controller) */ | |
234 | __u8 low_note; /* lower frequency range for this waveform */ | |
235 | __u8 high_note; /* higher frequency range for this waveform */ | |
236 | __u8 pad; | |
19ac31e8 | 237 | }; |
1da177e4 LT |
238 | |
239 | /* | |
240 | * Layer | |
241 | */ | |
242 | ||
19ac31e8 | 243 | struct iwffff_xlfo { |
1da177e4 LT |
244 | __u16 freq; /* (0-2047) 0.01Hz - 21.5Hz */ |
245 | __s16 depth; /* volume +- (0-255) 0.48675dB/step */ | |
246 | __s16 sweep; /* 0 - 950 deciseconds */ | |
247 | __u8 shape; /* see to ULTRA_IW_LFO_SHAPE_XXXX */ | |
248 | __u8 delay; /* 0 - 255 deciseconds */ | |
19ac31e8 | 249 | }; |
1da177e4 | 250 | |
19ac31e8 | 251 | struct iwffff_xenv_point { |
1da177e4 LT |
252 | __u16 offset; |
253 | __u16 rate; | |
19ac31e8 | 254 | }; |
1da177e4 | 255 | |
19ac31e8 | 256 | struct iwffff_xenv_record { |
1da177e4 LT |
257 | __u32 stype; |
258 | __u16 nattack; | |
259 | __u16 nrelease; | |
260 | __u16 sustain_offset; | |
261 | __u16 sustain_rate; | |
262 | __u16 release_rate; | |
263 | __u8 hirange; | |
264 | __u8 pad; | |
265 | /* points are stored here.. */ | |
266 | /* count of points = nattack + nrelease */ | |
19ac31e8 | 267 | }; |
1da177e4 | 268 | |
19ac31e8 | 269 | struct iwffff_xenv { |
1da177e4 LT |
270 | __u8 flags; |
271 | __u8 mode; | |
272 | __u8 index; | |
273 | __u8 pad; | |
19ac31e8 | 274 | }; |
1da177e4 | 275 | |
19ac31e8 | 276 | struct iwffff_xlayer { |
1da177e4 LT |
277 | __u32 stype; |
278 | __u8 flags; | |
279 | __u8 velocity_mode; | |
280 | __u8 layer_event; | |
281 | __u8 low_range; /* range for layer based */ | |
282 | __u8 high_range; /* on either velocity or frequency */ | |
283 | __u8 pan; /* pan offset from CC1 (0 left - 127 right) */ | |
284 | __u8 pan_freq_scale; /* position based on frequency (0-127) */ | |
285 | __u8 attenuation; /* 0-127 (no corresponding midi controller) */ | |
19ac31e8 TI |
286 | struct iwffff_xlfo tremolo; /* tremolo effect */ |
287 | struct iwffff_xlfo vibrato; /* vibrato effect */ | |
1da177e4 LT |
288 | __u16 freq_scale; /* 0-2048, 1024 is equal to semitone scaling */ |
289 | __u8 freq_center; /* center for keyboard frequency scaling */ | |
290 | __u8 pad; | |
19ac31e8 TI |
291 | struct iwffff_xenv penv; /* pitch envelope */ |
292 | struct iwffff_xenv venv; /* volume envelope */ | |
293 | }; | |
1da177e4 LT |
294 | |
295 | /* | |
296 | * Instrument | |
297 | */ | |
298 | ||
19ac31e8 | 299 | struct iwffff_xinstrument { |
1da177e4 LT |
300 | __u32 stype; |
301 | ||
302 | __u16 exclusion; | |
303 | __u16 layer_type; | |
304 | __u16 exclusion_group; /* 0 - none, 1-65535 */ | |
305 | ||
306 | __u8 effect1; /* effect 1 */ | |
307 | __u8 effect1_depth; /* 0-127 */ | |
308 | __u8 effect2; /* effect 2 */ | |
309 | __u8 effect2_depth; /* 0-127 */ | |
19ac31e8 | 310 | }; |
1da177e4 LT |
311 | |
312 | /* | |
313 | * ROM support | |
314 | * InterWave ROMs are Little-Endian (x86) | |
315 | */ | |
316 | ||
317 | #define IWFFFF_ROM_HDR_SIZE 512 | |
318 | ||
19ac31e8 | 319 | struct iwffff_rom_header { |
1da177e4 LT |
320 | __u8 iwave[8]; |
321 | __u8 revision; | |
322 | __u8 series_number; | |
323 | __u8 series_name[16]; | |
324 | __u8 date[10]; | |
325 | __u16 vendor_revision_major; | |
326 | __u16 vendor_revision_minor; | |
327 | __u32 rom_size; | |
328 | __u8 copyright[128]; | |
329 | __u8 vendor_name[64]; | |
330 | __u8 description[128]; | |
19ac31e8 | 331 | }; |
1da177e4 LT |
332 | |
333 | /* | |
334 | * Instrument info | |
335 | */ | |
336 | ||
337 | #define IWFFFF_INFO_LFO_VIBRATO (1<<0) | |
338 | #define IWFFFF_INFO_LFO_VIBRATO_SHAPE (1<<1) | |
339 | #define IWFFFF_INFO_LFO_TREMOLO (1<<2) | |
340 | #define IWFFFF_INFO_LFO_TREMOLO_SHAPE (1<<3) | |
341 | ||
19ac31e8 | 342 | struct iwffff_info { |
1da177e4 LT |
343 | unsigned int format; /* supported format bits */ |
344 | unsigned int effects; /* supported effects (1 << IWFFFF_EFFECT*) */ | |
345 | unsigned int lfos; /* LFO effects */ | |
346 | unsigned int max8_len; /* maximum 8-bit wave length */ | |
347 | unsigned int max16_len; /* maximum 16-bit wave length */ | |
19ac31e8 | 348 | }; |
1da177e4 LT |
349 | |
350 | #ifdef __KERNEL__ | |
351 | ||
352 | #include "seq_instr.h" | |
353 | ||
19ac31e8 | 354 | struct snd_iwffff_ops { |
1da177e4 | 355 | void *private_data; |
19ac31e8 TI |
356 | int (*info)(void *private_data, struct iwffff_info *info); |
357 | int (*put_sample)(void *private_data, struct iwffff_wave *wave, | |
1da177e4 | 358 | char __user *data, long len, int atomic); |
19ac31e8 | 359 | int (*get_sample)(void *private_data, struct iwffff_wave *wave, |
1da177e4 | 360 | char __user *data, long len, int atomic); |
19ac31e8 | 361 | int (*remove_sample)(void *private_data, struct iwffff_wave *wave, |
1da177e4 | 362 | int atomic); |
19ac31e8 TI |
363 | void (*notify)(void *private_data, struct snd_seq_kinstr *instr, int what); |
364 | struct snd_seq_kinstr_ops kops; | |
365 | }; | |
1da177e4 | 366 | |
19ac31e8 | 367 | int snd_seq_iwffff_init(struct snd_iwffff_ops *ops, |
1da177e4 | 368 | void *private_data, |
19ac31e8 | 369 | struct snd_seq_kinstr_ops *next); |
1da177e4 LT |
370 | |
371 | #endif | |
372 | ||
19ac31e8 TI |
373 | /* typedefs for compatibility to user-space */ |
374 | typedef struct iwffff_xwave iwffff_xwave_t; | |
375 | typedef struct iwffff_xlfo iwffff_xlfo_t; | |
376 | typedef struct iwffff_xenv_point iwffff_xenv_point_t; | |
377 | typedef struct iwffff_xenv_record iwffff_xenv_record_t; | |
378 | typedef struct iwffff_xenv iwffff_xenv_t; | |
379 | typedef struct iwffff_xlayer iwffff_xlayer_t; | |
380 | typedef struct iwffff_xinstrument iwffff_xinstrument_t; | |
381 | typedef struct iwffff_rom_header iwffff_rom_header_t; | |
382 | typedef struct iwffff_info iwffff_info_t; | |
383 | ||
1da177e4 | 384 | #endif /* __SOUND_AINSTR_IW_H */ |