ainstr_gf1.h 6.6 KB

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