blob: 47726fe0f46d7c087571e88b3278f194f3e3bdab [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Takashi Iwai19ac31e2005-11-17 14:04:44 +010055struct gf1_wave {
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 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;
Takashi Iwai19ac31e2005-11-17 14:04:44 +010091};
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
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
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100106struct gf1_instrument {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 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
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100115 struct gf1_wave *wave; /* first waveform */
116};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
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
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100138struct gf1_xwave {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 __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 */
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100168};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
170/*
171 * Instrument
172 */
173
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100174struct gf1_xinstrument {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 __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 */
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100184};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
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
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100194struct gf1_info {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 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 */
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100200};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
202#ifdef __KERNEL__
203
204#include "seq_instr.h"
205
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100206struct snd_gf1_ops {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 void *private_data;
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100208 int (*info)(void *private_data, struct gf1_info *info);
209 int (*put_sample)(void *private_data, struct gf1_wave *wave,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 char __user *data, long len, int atomic);
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100211 int (*get_sample)(void *private_data, struct gf1_wave *wave,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 char __user *data, long len, int atomic);
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100213 int (*remove_sample)(void *private_data, struct gf1_wave *wave,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 int atomic);
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100215 void (*notify)(void *private_data, struct snd_seq_kinstr *instr, int what);
216 struct snd_seq_kinstr_ops kops;
217};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100219int snd_seq_gf1_init(struct snd_gf1_ops *ops,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 void *private_data,
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100221 struct snd_seq_kinstr_ops *next);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
223#endif
224
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100225/* typedefs for compatibility to user-space */
226typedef struct gf1_xwave gf1_xwave_t;
227typedef struct gf1_xinstrument gf1_xinstrument_t;
228
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229#endif /* __SOUND_AINSTR_GF1_H */