sfnt_info.h 6.6 KB

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