xref: /linux/include/uapi/sound/sfnt_info.h (revision 8e07e0e3964ca4e23ce7b68e2096fe660a888942)
1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2 #ifndef __SOUND_SFNT_INFO_H
3 #define __SOUND_SFNT_INFO_H
4 
5 /*
6  *  Patch record compatible with AWE driver on OSS
7  *
8  *  Copyright (C) 1999-2000 Takashi Iwai
9  */
10 
11 #include <sound/asound.h>
12 
13 /*
14  * patch information record
15  */
16 
17 #ifdef SNDRV_BIG_ENDIAN
18 #define SNDRV_OSS_PATCHKEY(id) (0xfd00|id)
19 #else
20 #define SNDRV_OSS_PATCHKEY(id) ((id<<8)|0xfd)
21 #endif
22 
23 /* patch interface header: 16 bytes */
24 struct soundfont_patch_info {
25 	unsigned short key;		/* use the key below */
26 #define SNDRV_OSS_SOUNDFONT_PATCH		SNDRV_OSS_PATCHKEY(0x07)
27 
28 	short device_no;		/* synthesizer number */
29 	unsigned short sf_id;		/* file id (should be zero) */
30 	short optarg;			/* optional argument */
31 	int len;			/* data length (without this header) */
32 
33 	short type;			/* patch operation type */
34 #define SNDRV_SFNT_LOAD_INFO		0	/* awe_voice_rec */
35 #define SNDRV_SFNT_LOAD_DATA		1	/* awe_sample_info */
36 #define SNDRV_SFNT_OPEN_PATCH	2	/* awe_open_parm */
37 #define SNDRV_SFNT_CLOSE_PATCH	3	/* none */
38 	/* 4 is obsolete */
39 #define SNDRV_SFNT_REPLACE_DATA	5	/* awe_sample_info (optarg=#channels)*/
40 #define SNDRV_SFNT_MAP_PRESET	6	/* awe_voice_map */
41 	/* 7 is not used */
42 #define SNDRV_SFNT_PROBE_DATA		8	/* optarg=sample */
43 #define SNDRV_SFNT_REMOVE_INFO		9	/* optarg=(bank<<8)|instr */
44 
45 	short reserved;			/* word alignment data */
46 
47 	/* the actual patch data begins after this */
48 };
49 
50 
51 /*
52  * open patch
53  */
54 
55 #define SNDRV_SFNT_PATCH_NAME_LEN	32
56 
57 struct soundfont_open_parm {
58 	unsigned short type;		/* sample type */
59 #define SNDRV_SFNT_PAT_TYPE_MISC	0
60 #define SNDRV_SFNT_PAT_TYPE_GUS	6
61 #define SNDRV_SFNT_PAT_TYPE_MAP	7
62 #define SNDRV_SFNT_PAT_LOCKED	0x100	/* lock the samples */
63 #define SNDRV_SFNT_PAT_SHARED	0x200	/* sample is shared */
64 
65 	short reserved;
66 	char name[SNDRV_SFNT_PATCH_NAME_LEN];
67 };
68 
69 
70 /*
71  * raw voice information record
72  */
73 
74 /* wave table envelope & effect parameters to control EMU8000 */
75 struct soundfont_voice_parm {
76 	unsigned short moddelay;	/* modulation delay (0x8000) */
77 	unsigned short modatkhld;	/* modulation attack & hold time (0x7f7f) */
78 	unsigned short moddcysus;	/* modulation decay & sustain (0x7f7f) */
79 	unsigned short modrelease;	/* modulation release time (0x807f) */
80 	short modkeyhold, modkeydecay;	/* envelope change per key (not used) */
81 	unsigned short voldelay;	/* volume delay (0x8000) */
82 	unsigned short volatkhld;	/* volume attack & hold time (0x7f7f) */
83 	unsigned short voldcysus;	/* volume decay & sustain (0x7f7f) */
84 	unsigned short volrelease;	/* volume release time (0x807f) */
85 	short volkeyhold, volkeydecay;	/* envelope change per key (not used) */
86 	unsigned short lfo1delay;	/* LFO1 delay (0x8000) */
87 	unsigned short lfo2delay;	/* LFO2 delay (0x8000) */
88 	unsigned short pefe;		/* modulation pitch & cutoff (0x0000) */
89 	unsigned short fmmod;		/* LFO1 pitch & cutoff (0x0000) */
90 	unsigned short tremfrq;		/* LFO1 volume & freq (0x0000) */
91 	unsigned short fm2frq2;		/* LFO2 pitch & freq (0x0000) */
92 	unsigned char cutoff;		/* initial cutoff (0xff) */
93 	unsigned char filterQ;		/* initial filter Q [0-15] (0x0) */
94 	unsigned char chorus;		/* chorus send (0x00) */
95 	unsigned char reverb;		/* reverb send (0x00) */
96 	unsigned short reserved[4];	/* not used */
97 };
98 
99 
100 /* wave table parameters: 92 bytes */
101 struct soundfont_voice_info {
102 	unsigned short sf_id;		/* file id (should be zero) */
103 	unsigned short sample;		/* sample id */
104 	int start, end;			/* sample offset correction */
105 	int loopstart, loopend;		/* loop offset correction */
106 	short rate_offset;		/* sample rate pitch offset */
107 	unsigned short mode;		/* sample mode */
108 #define SNDRV_SFNT_MODE_ROMSOUND		0x8000
109 #define SNDRV_SFNT_MODE_STEREO		1
110 #define SNDRV_SFNT_MODE_LOOPING		2
111 #define SNDRV_SFNT_MODE_NORELEASE		4	/* obsolete */
112 #define SNDRV_SFNT_MODE_INIT_PARM		8
113 
114 	short root;			/* midi root key */
115 	short tune;			/* pitch tuning (in cents) */
116 	unsigned char low, high;	/* key note range */
117 	unsigned char vellow, velhigh;	/* velocity range */
118 	signed char fixkey, fixvel;	/* fixed key, velocity */
119 	signed char pan, fixpan;	/* panning, fixed panning */
120 	short exclusiveClass;		/* exclusive class (0 = none) */
121 	unsigned char amplitude;	/* sample volume (127 max) */
122 	unsigned char attenuation;	/* attenuation (0.375dB) */
123 	short scaleTuning;		/* pitch scale tuning(%), normally 100 */
124 	struct soundfont_voice_parm parm;	/* voice envelope parameters */
125 	unsigned short sample_mode;	/* sample mode_flag (set by driver) */
126 };
127 
128 
129 /* instrument info header: 4 bytes */
130 struct soundfont_voice_rec_hdr {
131 	unsigned char bank;		/* midi bank number */
132 	unsigned char instr;		/* midi preset number */
133 	char nvoices;			/* number of voices */
134 	char write_mode;		/* write mode; normally 0 */
135 #define SNDRV_SFNT_WR_APPEND		0	/* append anyway */
136 #define SNDRV_SFNT_WR_EXCLUSIVE		1	/* skip if already exists */
137 #define SNDRV_SFNT_WR_REPLACE		2	/* replace if already exists */
138 };
139 
140 
141 /*
142  * sample wave information
143  */
144 
145 /* wave table sample header: 32 bytes */
146 struct soundfont_sample_info {
147 	unsigned short sf_id;		/* file id (should be zero) */
148 	unsigned short sample;		/* sample id */
149 	int start, end;			/* start & end offset */
150 	int loopstart, loopend;		/* loop start & end offset */
151 	int size;			/* size (0 = ROM) */
152 	short dummy;			/* not used */
153 	unsigned short mode_flags;	/* mode flags */
154 #define SNDRV_SFNT_SAMPLE_8BITS		1	/* wave data is 8bits */
155 #define SNDRV_SFNT_SAMPLE_UNSIGNED	2	/* wave data is unsigned */
156 #define SNDRV_SFNT_SAMPLE_NO_BLANK	4	/* no blank loop is attached */
157 #define SNDRV_SFNT_SAMPLE_SINGLESHOT	8	/* single-shot w/o loop */
158 #define SNDRV_SFNT_SAMPLE_BIDIR_LOOP	16	/* bidirectional looping */
159 #define SNDRV_SFNT_SAMPLE_STEREO_LEFT	32	/* stereo left sound */
160 #define SNDRV_SFNT_SAMPLE_STEREO_RIGHT	64	/* stereo right sound */
161 #define SNDRV_SFNT_SAMPLE_REVERSE_LOOP	128	/* reverse looping */
162 	unsigned int truesize;		/* used memory size (set by driver) */
163 };
164 
165 
166 /*
167  * voice preset mapping (aliasing)
168  */
169 
170 struct soundfont_voice_map {
171 	int map_bank, map_instr, map_key;	/* key = -1 means all keys */
172 	int src_bank, src_instr, src_key;
173 };
174 
175 
176 /*
177  * ioctls for hwdep
178  */
179 
180 #define SNDRV_EMUX_HWDEP_NAME	"Emux WaveTable"
181 
182 #define SNDRV_EMUX_VERSION	((1 << 16) | (0 << 8) | 0)	/* 1.0.0 */
183 
184 struct snd_emux_misc_mode {
185 	int port;	/* -1 = all */
186 	int mode;
187 	int value;
188 	int value2;	/* reserved */
189 };
190 
191 #define SNDRV_EMUX_IOCTL_VERSION	_IOR('H', 0x80, unsigned int)
192 #define SNDRV_EMUX_IOCTL_LOAD_PATCH	_IOWR('H', 0x81, struct soundfont_patch_info)
193 #define SNDRV_EMUX_IOCTL_RESET_SAMPLES	_IO('H', 0x82)
194 #define SNDRV_EMUX_IOCTL_REMOVE_LAST_SAMPLES _IO('H', 0x83)
195 #define SNDRV_EMUX_IOCTL_MEM_AVAIL	_IOW('H', 0x84, int)
196 #define SNDRV_EMUX_IOCTL_MISC_MODE	_IOWR('H', 0x84, struct snd_emux_misc_mode)
197 
198 #endif /* __SOUND_SFNT_INFO_H */
199