ainstr_iw.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. /*
  2. * Advanced Linux Sound Architecture
  3. *
  4. * InterWave FFFF 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. #ifndef __SOUND_AINSTR_IW_H
  24. #define __SOUND_AINSTR_IW_H
  25. #ifndef __KERNEL__
  26. #include <asm/types.h>
  27. #include <asm/byteorder.h>
  28. #endif
  29. /*
  30. * share types (share ID 1)
  31. */
  32. #define IWFFFF_SHARE_FILE 0
  33. /*
  34. * wave formats
  35. */
  36. #define IWFFFF_WAVE_16BIT 0x0001 /* 16-bit wave */
  37. #define IWFFFF_WAVE_UNSIGNED 0x0002 /* unsigned wave */
  38. #define IWFFFF_WAVE_INVERT 0x0002 /* same as unsigned wave */
  39. #define IWFFFF_WAVE_BACKWARD 0x0004 /* backward mode (maybe used for reverb or ping-ping loop) */
  40. #define IWFFFF_WAVE_LOOP 0x0008 /* loop mode */
  41. #define IWFFFF_WAVE_BIDIR 0x0010 /* bidirectional mode */
  42. #define IWFFFF_WAVE_ULAW 0x0020 /* uLaw compressed wave */
  43. #define IWFFFF_WAVE_RAM 0x0040 /* wave is _preloaded_ in RAM (it is used for ROM simulation) */
  44. #define IWFFFF_WAVE_ROM 0x0080 /* wave is in ROM */
  45. #define IWFFFF_WAVE_STEREO 0x0100 /* wave is stereo */
  46. /*
  47. * Wavetable definitions
  48. */
  49. struct iwffff_wave {
  50. unsigned int share_id[4]; /* share id - zero = no sharing */
  51. unsigned int format; /* wave format */
  52. struct {
  53. unsigned int number; /* some other ID for this wave */
  54. unsigned int memory; /* begin of waveform in onboard memory */
  55. unsigned char *ptr; /* pointer to waveform in system memory */
  56. } address;
  57. unsigned int size; /* size of waveform in samples */
  58. unsigned int start; /* start offset in samples * 16 (lowest 4 bits - fraction) */
  59. unsigned int loop_start; /* bits loop start offset in samples * 16 (lowest 4 bits - fraction) */
  60. unsigned int loop_end; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */
  61. unsigned short loop_repeat; /* loop repeat - 0 = forever */
  62. unsigned int sample_ratio; /* sample ratio (44100 * 1024 / rate) */
  63. unsigned char attenuation; /* 0 - 127 (no corresponding midi controller) */
  64. unsigned char low_note; /* lower frequency range for this waveform */
  65. unsigned char high_note; /* higher frequency range for this waveform */
  66. unsigned char pad;
  67. struct iwffff_wave *next;
  68. };
  69. /*
  70. * Layer
  71. */
  72. #define IWFFFF_LFO_SHAPE_TRIANGLE 0
  73. #define IWFFFF_LFO_SHAPE_POSTRIANGLE 1
  74. struct iwffff_lfo {
  75. unsigned short freq; /* (0-2047) 0.01Hz - 21.5Hz */
  76. signed short depth; /* volume +- (0-255) 0.48675dB/step */
  77. signed short sweep; /* 0 - 950 deciseconds */
  78. unsigned char shape; /* see to IWFFFF_LFO_SHAPE_XXXX */
  79. unsigned char delay; /* 0 - 255 deciseconds */
  80. };
  81. #define IWFFFF_ENV_FLAG_RETRIGGER 0x0001 /* flag - retrigger */
  82. #define IWFFFF_ENV_MODE_ONE_SHOT 0x0001 /* mode - one shot */
  83. #define IWFFFF_ENV_MODE_SUSTAIN 0x0002 /* mode - sustain */
  84. #define IWFFFF_ENV_MODE_NO_SUSTAIN 0x0003 /* mode - no sustain */
  85. #define IWFFFF_ENV_INDEX_VELOCITY 0x0001 /* index - velocity */
  86. #define IWFFFF_ENV_INDEX_FREQUENCY 0x0002 /* index - frequency */
  87. struct iwffff_env_point {
  88. unsigned short offset;
  89. unsigned short rate;
  90. };
  91. struct iwffff_env_record {
  92. unsigned short nattack;
  93. unsigned short nrelease;
  94. unsigned short sustain_offset;
  95. unsigned short sustain_rate;
  96. unsigned short release_rate;
  97. unsigned char hirange;
  98. unsigned char pad;
  99. struct iwffff_env_record *next;
  100. /* points are stored here */
  101. /* count of points = nattack + nrelease */
  102. };
  103. struct iwffff_env {
  104. unsigned char flags;
  105. unsigned char mode;
  106. unsigned char index;
  107. unsigned char pad;
  108. struct iwffff_env_record *record;
  109. };
  110. #define IWFFFF_LAYER_FLAG_RETRIGGER 0x0001 /* retrigger */
  111. #define IWFFFF_LAYER_VELOCITY_TIME 0x0000 /* velocity mode = time */
  112. #define IWFFFF_LAYER_VELOCITY_RATE 0x0001 /* velocity mode = rate */
  113. #define IWFFFF_LAYER_EVENT_KUP 0x0000 /* layer event - key up */
  114. #define IWFFFF_LAYER_EVENT_KDOWN 0x0001 /* layer event - key down */
  115. #define IWFFFF_LAYER_EVENT_RETRIG 0x0002 /* layer event - retrigger */
  116. #define IWFFFF_LAYER_EVENT_LEGATO 0x0003 /* layer event - legato */
  117. struct iwffff_layer {
  118. unsigned char flags;
  119. unsigned char velocity_mode;
  120. unsigned char layer_event;
  121. unsigned char low_range; /* range for layer based */
  122. unsigned char high_range; /* on either velocity or frequency */
  123. unsigned char pan; /* pan offset from CC1 (0 left - 127 right) */
  124. unsigned char pan_freq_scale; /* position based on frequency (0-127) */
  125. unsigned char attenuation; /* 0-127 (no corresponding midi controller) */
  126. struct iwffff_lfo tremolo; /* tremolo effect */
  127. struct iwffff_lfo vibrato; /* vibrato effect */
  128. unsigned short freq_scale; /* 0-2048, 1024 is equal to semitone scaling */
  129. unsigned char freq_center; /* center for keyboard frequency scaling */
  130. unsigned char pad;
  131. struct iwffff_env penv; /* pitch envelope */
  132. struct iwffff_env venv; /* volume envelope */
  133. struct iwffff_wave *wave;
  134. struct iwffff_layer *next;
  135. };
  136. /*
  137. * Instrument
  138. */
  139. #define IWFFFF_EXCLUDE_NONE 0x0000 /* exclusion mode - none */
  140. #define IWFFFF_EXCLUDE_SINGLE 0x0001 /* exclude single - single note from the instrument group */
  141. #define IWFFFF_EXCLUDE_MULTIPLE 0x0002 /* exclude multiple - stop only same note from this instrument */
  142. #define IWFFFF_LAYER_NONE 0x0000 /* not layered */
  143. #define IWFFFF_LAYER_ON 0x0001 /* layered */
  144. #define IWFFFF_LAYER_VELOCITY 0x0002 /* layered by velocity */
  145. #define IWFFFF_LAYER_FREQUENCY 0x0003 /* layered by frequency */
  146. #define IWFFFF_EFFECT_NONE 0
  147. #define IWFFFF_EFFECT_REVERB 1
  148. #define IWFFFF_EFFECT_CHORUS 2
  149. #define IWFFFF_EFFECT_ECHO 3
  150. struct iwffff_instrument {
  151. unsigned short exclusion;
  152. unsigned short layer_type;
  153. unsigned short exclusion_group; /* 0 - none, 1-65535 */
  154. unsigned char effect1; /* effect 1 */
  155. unsigned char effect1_depth; /* 0-127 */
  156. unsigned char effect2; /* effect 2 */
  157. unsigned char effect2_depth; /* 0-127 */
  158. struct iwffff_layer *layer; /* first layer */
  159. };
  160. /*
  161. *
  162. * Kernel <-> user space
  163. * Hardware (CPU) independent section
  164. *
  165. * * = zero or more
  166. * + = one or more
  167. *
  168. * iwffff_xinstrument IWFFFF_STRU_INSTR
  169. * +iwffff_xlayer IWFFFF_STRU_LAYER
  170. * *iwffff_xenv_record IWFFFF_STRU_ENV_RECT (tremolo)
  171. * *iwffff_xenv_record IWFFFF_STRU_EVN_RECT (vibrato)
  172. * +iwffff_xwave IWFFFF_STRU_WAVE
  173. *
  174. */
  175. #define IWFFFF_STRU_WAVE __cpu_to_be32(('W'<<24)|('A'<<16)|('V'<<8)|'E')
  176. #define IWFFFF_STRU_ENV_RECP __cpu_to_be32(('E'<<24)|('N'<<16)|('R'<<8)|'P')
  177. #define IWFFFF_STRU_ENV_RECV __cpu_to_be32(('E'<<24)|('N'<<16)|('R'<<8)|'V')
  178. #define IWFFFF_STRU_LAYER __cpu_to_be32(('L'<<24)|('A'<<16)|('Y'<<8)|'R')
  179. #define IWFFFF_STRU_INSTR __cpu_to_be32(('I'<<24)|('N'<<16)|('S'<<8)|'T')
  180. /*
  181. * Wavetable definitions
  182. */
  183. struct iwffff_xwave {
  184. __u32 stype; /* structure type */
  185. __u32 share_id[4]; /* share id - zero = no sharing */
  186. __u32 format; /* wave format */
  187. __u32 offset; /* offset to ROM (address) */
  188. __u32 size; /* size of waveform in samples */
  189. __u32 start; /* start offset in samples * 16 (lowest 4 bits - fraction) */
  190. __u32 loop_start; /* bits loop start offset in samples * 16 (lowest 4 bits - fraction) */
  191. __u32 loop_end; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */
  192. __u16 loop_repeat; /* loop repeat - 0 = forever */
  193. __u32 sample_ratio; /* sample ratio (44100 * 1024 / rate) */
  194. __u8 attenuation; /* 0 - 127 (no corresponding midi controller) */
  195. __u8 low_note; /* lower frequency range for this waveform */
  196. __u8 high_note; /* higher frequency range for this waveform */
  197. __u8 pad;
  198. };
  199. /*
  200. * Layer
  201. */
  202. struct iwffff_xlfo {
  203. __u16 freq; /* (0-2047) 0.01Hz - 21.5Hz */
  204. __s16 depth; /* volume +- (0-255) 0.48675dB/step */
  205. __s16 sweep; /* 0 - 950 deciseconds */
  206. __u8 shape; /* see to ULTRA_IW_LFO_SHAPE_XXXX */
  207. __u8 delay; /* 0 - 255 deciseconds */
  208. };
  209. struct iwffff_xenv_point {
  210. __u16 offset;
  211. __u16 rate;
  212. };
  213. struct iwffff_xenv_record {
  214. __u32 stype;
  215. __u16 nattack;
  216. __u16 nrelease;
  217. __u16 sustain_offset;
  218. __u16 sustain_rate;
  219. __u16 release_rate;
  220. __u8 hirange;
  221. __u8 pad;
  222. /* points are stored here.. */
  223. /* count of points = nattack + nrelease */
  224. };
  225. struct iwffff_xenv {
  226. __u8 flags;
  227. __u8 mode;
  228. __u8 index;
  229. __u8 pad;
  230. };
  231. struct iwffff_xlayer {
  232. __u32 stype;
  233. __u8 flags;
  234. __u8 velocity_mode;
  235. __u8 layer_event;
  236. __u8 low_range; /* range for layer based */
  237. __u8 high_range; /* on either velocity or frequency */
  238. __u8 pan; /* pan offset from CC1 (0 left - 127 right) */
  239. __u8 pan_freq_scale; /* position based on frequency (0-127) */
  240. __u8 attenuation; /* 0-127 (no corresponding midi controller) */
  241. struct iwffff_xlfo tremolo; /* tremolo effect */
  242. struct iwffff_xlfo vibrato; /* vibrato effect */
  243. __u16 freq_scale; /* 0-2048, 1024 is equal to semitone scaling */
  244. __u8 freq_center; /* center for keyboard frequency scaling */
  245. __u8 pad;
  246. struct iwffff_xenv penv; /* pitch envelope */
  247. struct iwffff_xenv venv; /* volume envelope */
  248. };
  249. /*
  250. * Instrument
  251. */
  252. struct iwffff_xinstrument {
  253. __u32 stype;
  254. __u16 exclusion;
  255. __u16 layer_type;
  256. __u16 exclusion_group; /* 0 - none, 1-65535 */
  257. __u8 effect1; /* effect 1 */
  258. __u8 effect1_depth; /* 0-127 */
  259. __u8 effect2; /* effect 2 */
  260. __u8 effect2_depth; /* 0-127 */
  261. };
  262. /*
  263. * ROM support
  264. * InterWave ROMs are Little-Endian (x86)
  265. */
  266. #define IWFFFF_ROM_HDR_SIZE 512
  267. struct iwffff_rom_header {
  268. __u8 iwave[8];
  269. __u8 revision;
  270. __u8 series_number;
  271. __u8 series_name[16];
  272. __u8 date[10];
  273. __u16 vendor_revision_major;
  274. __u16 vendor_revision_minor;
  275. __u32 rom_size;
  276. __u8 copyright[128];
  277. __u8 vendor_name[64];
  278. __u8 description[128];
  279. };
  280. /*
  281. * Instrument info
  282. */
  283. #define IWFFFF_INFO_LFO_VIBRATO (1<<0)
  284. #define IWFFFF_INFO_LFO_VIBRATO_SHAPE (1<<1)
  285. #define IWFFFF_INFO_LFO_TREMOLO (1<<2)
  286. #define IWFFFF_INFO_LFO_TREMOLO_SHAPE (1<<3)
  287. struct iwffff_info {
  288. unsigned int format; /* supported format bits */
  289. unsigned int effects; /* supported effects (1 << IWFFFF_EFFECT*) */
  290. unsigned int lfos; /* LFO effects */
  291. unsigned int max8_len; /* maximum 8-bit wave length */
  292. unsigned int max16_len; /* maximum 16-bit wave length */
  293. };
  294. #ifdef __KERNEL__
  295. #include "seq_instr.h"
  296. struct snd_iwffff_ops {
  297. void *private_data;
  298. int (*info)(void *private_data, struct iwffff_info *info);
  299. int (*put_sample)(void *private_data, struct iwffff_wave *wave,
  300. char __user *data, long len, int atomic);
  301. int (*get_sample)(void *private_data, struct iwffff_wave *wave,
  302. char __user *data, long len, int atomic);
  303. int (*remove_sample)(void *private_data, struct iwffff_wave *wave,
  304. int atomic);
  305. void (*notify)(void *private_data, struct snd_seq_kinstr *instr, int what);
  306. struct snd_seq_kinstr_ops kops;
  307. };
  308. int snd_seq_iwffff_init(struct snd_iwffff_ops *ops,
  309. void *private_data,
  310. struct snd_seq_kinstr_ops *next);
  311. #endif
  312. /* typedefs for compatibility to user-space */
  313. typedef struct iwffff_xwave iwffff_xwave_t;
  314. typedef struct iwffff_xlfo iwffff_xlfo_t;
  315. typedef struct iwffff_xenv_point iwffff_xenv_point_t;
  316. typedef struct iwffff_xenv_record iwffff_xenv_record_t;
  317. typedef struct iwffff_xenv iwffff_xenv_t;
  318. typedef struct iwffff_xlayer iwffff_xlayer_t;
  319. typedef struct iwffff_xinstrument iwffff_xinstrument_t;
  320. typedef struct iwffff_rom_header iwffff_rom_header_t;
  321. typedef struct iwffff_info iwffff_info_t;
  322. #endif /* __SOUND_AINSTR_IW_H */