sfnt_info.h 7.3 KB

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