Linux v2.6.15-rc7
[pohmelfs.git] / include / sound / ainstr_gf1.h
blobae2ddda63971f7bba5fbec4703e02e86838649f6
1 /*
2 * Advanced Linux Sound Architecture
4 * GF1 (GUS) Patch Instrument Format
5 * Copyright (c) 1994-99 by Jaroslav Kysela <perex@suse.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_GF1_H
25 #define __SOUND_AINSTR_GF1_H
27 #ifndef __KERNEL__
28 #include <asm/types.h>
29 #include <asm/byteorder.h>
30 #endif
33 * share types (share ID 1)
36 #define GF1_SHARE_FILE 0
39 * wave formats
42 #define GF1_WAVE_16BIT 0x0001 /* 16-bit wave */
43 #define GF1_WAVE_UNSIGNED 0x0002 /* unsigned wave */
44 #define GF1_WAVE_INVERT 0x0002 /* same as unsigned wave */
45 #define GF1_WAVE_BACKWARD 0x0004 /* backward mode (maybe used for reverb or ping-ping loop) */
46 #define GF1_WAVE_LOOP 0x0008 /* loop mode */
47 #define GF1_WAVE_BIDIR 0x0010 /* bidirectional mode */
48 #define GF1_WAVE_STEREO 0x0100 /* stereo mode */
49 #define GF1_WAVE_ULAW 0x0200 /* uLaw compression mode */
52 * Wavetable definitions
55 typedef struct gf1_wave {
56 unsigned int share_id[4]; /* share id - zero = no sharing */
57 unsigned int format; /* wave format */
59 struct {
60 unsigned int number; /* some other ID for this instrument */
61 unsigned int memory; /* begin of waveform in onboard memory */
62 unsigned char *ptr; /* pointer to waveform in system memory */
63 } address;
65 unsigned int size; /* size of waveform in samples */
66 unsigned int start; /* start offset in samples * 16 (lowest 4 bits - fraction) */
67 unsigned int loop_start; /* bits loop start offset in samples * 16 (lowest 4 bits - fraction) */
68 unsigned int loop_end; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */
69 unsigned short loop_repeat; /* loop repeat - 0 = forever */
71 unsigned char flags; /* GF1 patch flags */
72 unsigned char pad;
73 unsigned int sample_rate; /* sample rate in Hz */
74 unsigned int low_frequency; /* low frequency range */
75 unsigned int high_frequency; /* high frequency range */
76 unsigned int root_frequency; /* root frequency range */
77 signed short tune;
78 unsigned char balance;
79 unsigned char envelope_rate[6];
80 unsigned char envelope_offset[6];
81 unsigned char tremolo_sweep;
82 unsigned char tremolo_rate;
83 unsigned char tremolo_depth;
84 unsigned char vibrato_sweep;
85 unsigned char vibrato_rate;
86 unsigned char vibrato_depth;
87 unsigned short scale_frequency;
88 unsigned short scale_factor; /* 0-2048 or 0-2 */
90 struct gf1_wave *next;
91 } gf1_wave_t;
94 * Instrument
97 #define IWFFFF_EXCLUDE_NONE 0x0000 /* exclusion mode - none */
98 #define IWFFFF_EXCLUDE_SINGLE 0x0001 /* exclude single - single note from the instrument group */
99 #define IWFFFF_EXCLUDE_MULTIPLE 0x0002 /* exclude multiple - stop only same note from this instrument */
101 #define IWFFFF_EFFECT_NONE 0
102 #define IWFFFF_EFFECT_REVERB 1
103 #define IWFFFF_EFFECT_CHORUS 2
104 #define IWFFFF_EFFECT_ECHO 3
106 typedef struct {
107 unsigned short exclusion;
108 unsigned short exclusion_group; /* 0 - none, 1-65535 */
110 unsigned char effect1; /* effect 1 */
111 unsigned char effect1_depth; /* 0-127 */
112 unsigned char effect2; /* effect 2 */
113 unsigned char effect2_depth; /* 0-127 */
115 gf1_wave_t *wave; /* first waveform */
116 } gf1_instrument_t;
120 * Kernel <-> user space
121 * Hardware (CPU) independent section
123 * * = zero or more
124 * + = one or more
126 * gf1_xinstrument IWFFFF_STRU_INSTR
127 * +gf1_xwave IWFFFF_STRU_WAVE
131 #define GF1_STRU_WAVE __cpu_to_be32(('W'<<24)|('A'<<16)|('V'<<8)|'E')
132 #define GF1_STRU_INSTR __cpu_to_be32(('I'<<24)|('N'<<16)|('S'<<8)|'T')
135 * Wavetable definitions
138 typedef struct gf1_xwave {
139 __u32 stype; /* structure type */
141 __u32 share_id[4]; /* share id - zero = no sharing */
142 __u32 format; /* wave format */
144 __u32 size; /* size of waveform in samples */
145 __u32 start; /* start offset in samples * 16 (lowest 4 bits - fraction) */
146 __u32 loop_start; /* bits loop start offset in samples * 16 (lowest 4 bits - fraction) */
147 __u32 loop_end; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */
148 __u16 loop_repeat; /* loop repeat - 0 = forever */
150 __u8 flags; /* GF1 patch flags */
151 __u8 pad;
152 __u32 sample_rate; /* sample rate in Hz */
153 __u32 low_frequency; /* low frequency range */
154 __u32 high_frequency; /* high frequency range */
155 __u32 root_frequency; /* root frequency range */
156 __s16 tune;
157 __u8 balance;
158 __u8 envelope_rate[6];
159 __u8 envelope_offset[6];
160 __u8 tremolo_sweep;
161 __u8 tremolo_rate;
162 __u8 tremolo_depth;
163 __u8 vibrato_sweep;
164 __u8 vibrato_rate;
165 __u8 vibrato_depth;
166 __u16 scale_frequency;
167 __u16 scale_factor; /* 0-2048 or 0-2 */
168 } gf1_xwave_t;
171 * Instrument
174 typedef struct gf1_xinstrument {
175 __u32 stype;
177 __u16 exclusion;
178 __u16 exclusion_group; /* 0 - none, 1-65535 */
180 __u8 effect1; /* effect 1 */
181 __u8 effect1_depth; /* 0-127 */
182 __u8 effect2; /* effect 2 */
183 __u8 effect2_depth; /* 0-127 */
184 } gf1_xinstrument_t;
187 * Instrument info
190 #define GF1_INFO_ENVELOPE (1<<0)
191 #define GF1_INFO_TREMOLO (1<<1)
192 #define GF1_INFO_VIBRATO (1<<2)
194 typedef struct gf1_info {
195 unsigned char flags; /* supported wave flags */
196 unsigned char pad[3];
197 unsigned int features; /* supported features */
198 unsigned int max8_len; /* maximum 8-bit wave length */
199 unsigned int max16_len; /* maximum 16-bit wave length */
200 } gf1_info_t;
202 #ifdef __KERNEL__
204 #include "seq_instr.h"
206 typedef struct {
207 void *private_data;
208 int (*info)(void *private_data, gf1_info_t *info);
209 int (*put_sample)(void *private_data, gf1_wave_t *wave,
210 char __user *data, long len, int atomic);
211 int (*get_sample)(void *private_data, gf1_wave_t *wave,
212 char __user *data, long len, int atomic);
213 int (*remove_sample)(void *private_data, gf1_wave_t *wave,
214 int atomic);
215 void (*notify)(void *private_data, snd_seq_kinstr_t *instr, int what);
216 snd_seq_kinstr_ops_t kops;
217 } snd_gf1_ops_t;
219 int snd_seq_gf1_init(snd_gf1_ops_t *ops,
220 void *private_data,
221 snd_seq_kinstr_ops_t *next);
223 #endif
225 #endif /* __SOUND_AINSTR_GF1_H */