blob: 1bce7fd1725f6b4d5a0237fd2410173d6da46344 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __SOUND_SFNT_INFO_H
2#define __SOUND_SFNT_INFO_H
3
4/*
5 * Patch record compatible with AWE driver on OSS
6 *
7 * Copyright (C) 1999-2000 Takashi Iwai
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25#include <sound/asound.h>
26
27/*
28 * patch information record
29 */
30
31#ifdef SNDRV_BIG_ENDIAN
32#define SNDRV_OSS_PATCHKEY(id) (0xfd00|id)
33#else
34#define SNDRV_OSS_PATCHKEY(id) ((id<<8)|0xfd)
35#endif
36
37/* patch interface header: 16 bytes */
Takashi Iwai03da3122005-11-17 14:24:47 +010038struct soundfont_patch_info {
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 unsigned short key; /* use the key below */
40#define SNDRV_OSS_SOUNDFONT_PATCH SNDRV_OSS_PATCHKEY(0x07)
41
42 short device_no; /* synthesizer number */
43 unsigned short sf_id; /* file id (should be zero) */
44 short optarg; /* optional argument */
45 int len; /* data length (without this header) */
46
47 short type; /* patch operation type */
48#define SNDRV_SFNT_LOAD_INFO 0 /* awe_voice_rec */
49#define SNDRV_SFNT_LOAD_DATA 1 /* awe_sample_info */
50#define SNDRV_SFNT_OPEN_PATCH 2 /* awe_open_parm */
51#define SNDRV_SFNT_CLOSE_PATCH 3 /* none */
52 /* 4 is obsolete */
53#define SNDRV_SFNT_REPLACE_DATA 5 /* awe_sample_info (optarg=#channels)*/
54#define SNDRV_SFNT_MAP_PRESET 6 /* awe_voice_map */
55 /* 7 is not used */
56#define SNDRV_SFNT_PROBE_DATA 8 /* optarg=sample */
57#define SNDRV_SFNT_REMOVE_INFO 9 /* optarg=(bank<<8)|instr */
58
59 short reserved; /* word alignment data */
60
61 /* the actual patch data begins after this */
Takashi Iwai03da3122005-11-17 14:24:47 +010062};
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64
65/*
66 * open patch
67 */
68
69#define SNDRV_SFNT_PATCH_NAME_LEN 32
70
Takashi Iwai03da3122005-11-17 14:24:47 +010071struct soundfont_open_parm {
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 unsigned short type; /* sample type */
73#define SNDRV_SFNT_PAT_TYPE_MISC 0
74#define SNDRV_SFNT_PAT_TYPE_GUS 6
75#define SNDRV_SFNT_PAT_TYPE_MAP 7
76#define SNDRV_SFNT_PAT_LOCKED 0x100 /* lock the samples */
77#define SNDRV_SFNT_PAT_SHARED 0x200 /* sample is shared */
78
79 short reserved;
80 char name[SNDRV_SFNT_PATCH_NAME_LEN];
Takashi Iwai03da3122005-11-17 14:24:47 +010081};
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83
84/*
85 * raw voice information record
86 */
87
88/* wave table envelope & effect parameters to control EMU8000 */
Takashi Iwai03da3122005-11-17 14:24:47 +010089struct soundfont_voice_parm {
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 unsigned short moddelay; /* modulation delay (0x8000) */
91 unsigned short modatkhld; /* modulation attack & hold time (0x7f7f) */
92 unsigned short moddcysus; /* modulation decay & sustain (0x7f7f) */
93 unsigned short modrelease; /* modulation release time (0x807f) */
94 short modkeyhold, modkeydecay; /* envelope change per key (not used) */
95 unsigned short voldelay; /* volume delay (0x8000) */
96 unsigned short volatkhld; /* volume attack & hold time (0x7f7f) */
97 unsigned short voldcysus; /* volume decay & sustain (0x7f7f) */
98 unsigned short volrelease; /* volume release time (0x807f) */
99 short volkeyhold, volkeydecay; /* envelope change per key (not used) */
100 unsigned short lfo1delay; /* LFO1 delay (0x8000) */
101 unsigned short lfo2delay; /* LFO2 delay (0x8000) */
102 unsigned short pefe; /* modulation pitch & cutoff (0x0000) */
103 unsigned short fmmod; /* LFO1 pitch & cutoff (0x0000) */
104 unsigned short tremfrq; /* LFO1 volume & freq (0x0000) */
105 unsigned short fm2frq2; /* LFO2 pitch & freq (0x0000) */
106 unsigned char cutoff; /* initial cutoff (0xff) */
107 unsigned char filterQ; /* initial filter Q [0-15] (0x0) */
108 unsigned char chorus; /* chorus send (0x00) */
109 unsigned char reverb; /* reverb send (0x00) */
110 unsigned short reserved[4]; /* not used */
Takashi Iwai03da3122005-11-17 14:24:47 +0100111};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
113
114/* wave table parameters: 92 bytes */
Takashi Iwai03da3122005-11-17 14:24:47 +0100115struct soundfont_voice_info {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 unsigned short sf_id; /* file id (should be zero) */
117 unsigned short sample; /* sample id */
118 int start, end; /* sample offset correction */
119 int loopstart, loopend; /* loop offset correction */
120 short rate_offset; /* sample rate pitch offset */
121 unsigned short mode; /* sample mode */
122#define SNDRV_SFNT_MODE_ROMSOUND 0x8000
123#define SNDRV_SFNT_MODE_STEREO 1
124#define SNDRV_SFNT_MODE_LOOPING 2
125#define SNDRV_SFNT_MODE_NORELEASE 4 /* obsolete */
126#define SNDRV_SFNT_MODE_INIT_PARM 8
127
128 short root; /* midi root key */
129 short tune; /* pitch tuning (in cents) */
130 unsigned char low, high; /* key note range */
131 unsigned char vellow, velhigh; /* velocity range */
132 signed char fixkey, fixvel; /* fixed key, velocity */
133 signed char pan, fixpan; /* panning, fixed panning */
134 short exclusiveClass; /* exclusive class (0 = none) */
135 unsigned char amplitude; /* sample volume (127 max) */
136 unsigned char attenuation; /* attenuation (0.375dB) */
137 short scaleTuning; /* pitch scale tuning(%), normally 100 */
Takashi Iwai03da3122005-11-17 14:24:47 +0100138 struct soundfont_voice_parm parm; /* voice envelope parameters */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 unsigned short sample_mode; /* sample mode_flag (set by driver) */
Takashi Iwai03da3122005-11-17 14:24:47 +0100140};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
142
143/* instrument info header: 4 bytes */
Takashi Iwai03da3122005-11-17 14:24:47 +0100144struct soundfont_voice_rec_hdr {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 unsigned char bank; /* midi bank number */
146 unsigned char instr; /* midi preset number */
147 char nvoices; /* number of voices */
148 char write_mode; /* write mode; normally 0 */
149#define SNDRV_SFNT_WR_APPEND 0 /* append anyway */
150#define SNDRV_SFNT_WR_EXCLUSIVE 1 /* skip if already exists */
151#define SNDRV_SFNT_WR_REPLACE 2 /* replace if already exists */
Takashi Iwai03da3122005-11-17 14:24:47 +0100152};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
154
155/*
156 * sample wave information
157 */
158
159/* wave table sample header: 32 bytes */
Takashi Iwai03da3122005-11-17 14:24:47 +0100160struct soundfont_sample_info {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 unsigned short sf_id; /* file id (should be zero) */
162 unsigned short sample; /* sample id */
163 int start, end; /* start & end offset */
164 int loopstart, loopend; /* loop start & end offset */
165 int size; /* size (0 = ROM) */
166 short dummy; /* not used */
167 unsigned short mode_flags; /* mode flags */
168#define SNDRV_SFNT_SAMPLE_8BITS 1 /* wave data is 8bits */
169#define SNDRV_SFNT_SAMPLE_UNSIGNED 2 /* wave data is unsigned */
170#define SNDRV_SFNT_SAMPLE_NO_BLANK 4 /* no blank loop is attached */
171#define SNDRV_SFNT_SAMPLE_SINGLESHOT 8 /* single-shot w/o loop */
172#define SNDRV_SFNT_SAMPLE_BIDIR_LOOP 16 /* bidirectional looping */
173#define SNDRV_SFNT_SAMPLE_STEREO_LEFT 32 /* stereo left sound */
174#define SNDRV_SFNT_SAMPLE_STEREO_RIGHT 64 /* stereo right sound */
175#define SNDRV_SFNT_SAMPLE_REVERSE_LOOP 128 /* reverse looping */
176 unsigned int truesize; /* used memory size (set by driver) */
Takashi Iwai03da3122005-11-17 14:24:47 +0100177};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
179
180/*
181 * voice preset mapping (aliasing)
182 */
183
Takashi Iwai03da3122005-11-17 14:24:47 +0100184struct soundfont_voice_map {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 int map_bank, map_instr, map_key; /* key = -1 means all keys */
186 int src_bank, src_instr, src_key;
Takashi Iwai03da3122005-11-17 14:24:47 +0100187};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
189
190/*
191 * ioctls for hwdep
192 */
193
194#define SNDRV_EMUX_HWDEP_NAME "Emux WaveTable"
195
196#define SNDRV_EMUX_VERSION ((1 << 16) | (0 << 8) | 0) /* 1.0.0 */
197
Takashi Iwai03da3122005-11-17 14:24:47 +0100198struct snd_emux_misc_mode {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 int port; /* -1 = all */
200 int mode;
201 int value;
202 int value2; /* reserved */
203};
204
Takashi Iwai78a05b52009-03-11 09:52:28 +0100205#define SNDRV_EMUX_IOCTL_VERSION _IOR('H', 0x80, unsigned int)
206#define SNDRV_EMUX_IOCTL_LOAD_PATCH _IOWR('H', 0x81, struct soundfont_patch_info)
207#define SNDRV_EMUX_IOCTL_RESET_SAMPLES _IO('H', 0x82)
208#define SNDRV_EMUX_IOCTL_REMOVE_LAST_SAMPLES _IO('H', 0x83)
209#define SNDRV_EMUX_IOCTL_MEM_AVAIL _IOW('H', 0x84, int)
210#define SNDRV_EMUX_IOCTL_MISC_MODE _IOWR('H', 0x84, struct snd_emux_misc_mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211
212#endif /* __SOUND_SFNT_INFO_H */