2 * Advanced Linux Sound Architecture
4 * InterWave FFFF Instrument Format
5 * Copyright (c) 1994-99 by Jaroslav Kysela <perex@perex.cz>
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.
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.
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
24 #ifndef __SOUND_AINSTR_IW_H
25 #define __SOUND_AINSTR_IW_H
28 #include <asm/types.h>
29 #include <asm/byteorder.h>
33 * share types (share ID 1)
36 #define IWFFFF_SHARE_FILE 0
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 */
54 * Wavetable definitions
58 unsigned int share_id
[4]; /* share id - zero = no sharing */
59 unsigned int format
; /* wave format */
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 */
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 */
78 struct iwffff_wave
*next
;
85 #define IWFFFF_LFO_SHAPE_TRIANGLE 0
86 #define IWFFFF_LFO_SHAPE_POSTRIANGLE 1
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 */
96 #define IWFFFF_ENV_FLAG_RETRIGGER 0x0001 /* flag - retrigger */
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 */
102 #define IWFFFF_ENV_INDEX_VELOCITY 0x0001 /* index - velocity */
103 #define IWFFFF_ENV_INDEX_FREQUENCY 0x0002 /* index - frequency */
105 struct iwffff_env_point
{
106 unsigned short offset
;
110 struct iwffff_env_record
{
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
;
118 struct iwffff_env_record
*next
;
119 /* points are stored here */
120 /* count of points = nattack + nrelease */
128 struct iwffff_env_record
*record
;
131 #define IWFFFF_LAYER_FLAG_RETRIGGER 0x0001 /* retrigger */
133 #define IWFFFF_LAYER_VELOCITY_TIME 0x0000 /* velocity mode = time */
134 #define IWFFFF_LAYER_VELOCITY_RATE 0x0001 /* velocity mode = rate */
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 */
141 struct iwffff_layer
{
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) */
150 struct iwffff_lfo tremolo
; /* tremolo effect */
151 struct iwffff_lfo vibrato
; /* vibrato effect */
152 unsigned short freq_scale
; /* 0-2048, 1024 is equal to semitone scaling */
153 unsigned char freq_center
; /* center for keyboard frequency scaling */
155 struct iwffff_env penv
; /* pitch envelope */
156 struct iwffff_env venv
; /* volume envelope */
158 struct iwffff_wave
*wave
;
159 struct iwffff_layer
*next
;
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 */
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 */
175 #define IWFFFF_EFFECT_NONE 0
176 #define IWFFFF_EFFECT_REVERB 1
177 #define IWFFFF_EFFECT_CHORUS 2
178 #define IWFFFF_EFFECT_ECHO 3
180 struct iwffff_instrument
{
181 unsigned short exclusion
;
182 unsigned short layer_type
;
183 unsigned short exclusion_group
; /* 0 - none, 1-65535 */
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 */
190 struct iwffff_layer
*layer
; /* first layer */
195 * Kernel <-> user space
196 * Hardware (CPU) independent section
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
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')
216 * Wavetable definitions
219 struct iwffff_xwave
{
220 __u32 stype
; /* structure type */
222 __u32 share_id
[4]; /* share id - zero = no sharing */
224 __u32 format
; /* wave format */
225 __u32 offset
; /* offset to ROM (address) */
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 */
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 */
251 struct iwffff_xenv_point
{
256 struct iwffff_xenv_record
{
260 __u16 sustain_offset
;
265 /* points are stored here.. */
266 /* count of points = nattack + nrelease */
276 struct iwffff_xlayer
{
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) */
286 struct iwffff_xlfo tremolo
; /* tremolo effect */
287 struct iwffff_xlfo vibrato
; /* vibrato effect */
288 __u16 freq_scale
; /* 0-2048, 1024 is equal to semitone scaling */
289 __u8 freq_center
; /* center for keyboard frequency scaling */
291 struct iwffff_xenv penv
; /* pitch envelope */
292 struct iwffff_xenv venv
; /* volume envelope */
299 struct iwffff_xinstrument
{
304 __u16 exclusion_group
; /* 0 - none, 1-65535 */
306 __u8 effect1
; /* effect 1 */
307 __u8 effect1_depth
; /* 0-127 */
308 __u8 effect2
; /* effect 2 */
309 __u8 effect2_depth
; /* 0-127 */
314 * InterWave ROMs are Little-Endian (x86)
317 #define IWFFFF_ROM_HDR_SIZE 512
319 struct iwffff_rom_header
{
323 __u8 series_name
[16];
325 __u16 vendor_revision_major
;
326 __u16 vendor_revision_minor
;
329 __u8 vendor_name
[64];
330 __u8 description
[128];
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)
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 */
352 #include "seq_instr.h"
354 struct snd_iwffff_ops
{
356 int (*info
)(void *private_data
, struct iwffff_info
*info
);
357 int (*put_sample
)(void *private_data
, struct iwffff_wave
*wave
,
358 char __user
*data
, long len
, int atomic
);
359 int (*get_sample
)(void *private_data
, struct iwffff_wave
*wave
,
360 char __user
*data
, long len
, int atomic
);
361 int (*remove_sample
)(void *private_data
, struct iwffff_wave
*wave
,
363 void (*notify
)(void *private_data
, struct snd_seq_kinstr
*instr
, int what
);
364 struct snd_seq_kinstr_ops kops
;
367 int snd_seq_iwffff_init(struct snd_iwffff_ops
*ops
,
369 struct snd_seq_kinstr_ops
*next
);
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
;
384 #endif /* __SOUND_AINSTR_IW_H */