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