sfnt_info.h 7.3 KB

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