]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/sound/ainstr_gf1.h
Linux-2.6.12-rc2
[mirror_ubuntu-artful-kernel.git] / include / sound / ainstr_gf1.h
1 /*
2 * Advanced Linux Sound Architecture
3 *
4 * GF1 (GUS) Patch Instrument Format
5 * Copyright (c) 1994-99 by Jaroslav Kysela <perex@suse.cz>
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_GF1_H
25 #define __SOUND_AINSTR_GF1_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 GF1_SHARE_FILE 0
37
38 /*
39 * wave formats
40 */
41
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 */
50
51 /*
52 * Wavetable definitions
53 */
54
55 typedef struct gf1_wave {
56 unsigned int share_id[4]; /* share id - zero = no sharing */
57 unsigned int format; /* wave format */
58
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;
64
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 */
70
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 */
89
90 struct gf1_wave *next;
91 } gf1_wave_t;
92
93 /*
94 * Instrument
95 */
96
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 */
100
101 #define IWFFFF_EFFECT_NONE 0
102 #define IWFFFF_EFFECT_REVERB 1
103 #define IWFFFF_EFFECT_CHORUS 2
104 #define IWFFFF_EFFECT_ECHO 3
105
106 typedef struct {
107 unsigned short exclusion;
108 unsigned short exclusion_group; /* 0 - none, 1-65535 */
109
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 */
114
115 gf1_wave_t *wave; /* first waveform */
116 } gf1_instrument_t;
117
118 /*
119 *
120 * Kernel <-> user space
121 * Hardware (CPU) independent section
122 *
123 * * = zero or more
124 * + = one or more
125 *
126 * gf1_xinstrument IWFFFF_STRU_INSTR
127 * +gf1_xwave IWFFFF_STRU_WAVE
128 *
129 */
130
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')
133
134 /*
135 * Wavetable definitions
136 */
137
138 typedef struct gf1_xwave {
139 __u32 stype; /* structure type */
140
141 __u32 share_id[4]; /* share id - zero = no sharing */
142 __u32 format; /* wave format */
143
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 */
149
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;
169
170 /*
171 * Instrument
172 */
173
174 typedef struct gf1_xinstrument {
175 __u32 stype;
176
177 __u16 exclusion;
178 __u16 exclusion_group; /* 0 - none, 1-65535 */
179
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;
185
186 /*
187 * Instrument info
188 */
189
190 #define GF1_INFO_ENVELOPE (1<<0)
191 #define GF1_INFO_TREMOLO (1<<1)
192 #define GF1_INFO_VIBRATO (1<<2)
193
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;
201
202 #ifdef __KERNEL__
203
204 #include "seq_instr.h"
205
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;
218
219 int snd_seq_gf1_init(snd_gf1_ops_t *ops,
220 void *private_data,
221 snd_seq_kinstr_ops_t *next);
222
223 #endif
224
225 #endif /* __SOUND_AINSTR_GF1_H */