Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

251 lines
6.2KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. globals.h - it contains program settings and the program capabilities
  4. like number of parts, of effects
  5. Copyright (C) 2002-2005 Nasca Octavian Paul
  6. Author: Nasca Octavian Paul
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of version 2 of the GNU General Public License
  9. as published by the Free Software Foundation.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License (version 2 or later) for more details.
  14. You should have received a copy of the GNU General Public License (version 2)
  15. along with this program; if not, write to the Free Software Foundation,
  16. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef GLOBALS_H
  19. #define GLOBALS_H
  20. #include <stdint.h>
  21. /**
  22. * The number of harmonics of additive synth
  23. * This must be smaller than OSCIL_SIZE/2
  24. */
  25. #define MAX_AD_HARMONICS 128
  26. /**
  27. * The number of harmonics of substractive
  28. */
  29. #define MAX_SUB_HARMONICS 64
  30. /*
  31. * The maximum number of samples that are used for 1 PADsynth instrument(or item)
  32. */
  33. #define PAD_MAX_SAMPLES 64
  34. /*
  35. * Number of parts
  36. */
  37. #define NUM_MIDI_PARTS 16
  38. /*
  39. * Number of Midi channes
  40. */
  41. #define NUM_MIDI_CHANNELS 16
  42. /*
  43. * The number of voices of additive synth for a single note
  44. */
  45. #define NUM_VOICES 8
  46. /*
  47. * The poliphony (notes)
  48. */
  49. #define POLIPHONY 60
  50. /*
  51. * Number of system effects
  52. */
  53. #define NUM_SYS_EFX 4
  54. /*
  55. * Number of insertion effects
  56. */
  57. #define NUM_INS_EFX 8
  58. /*
  59. * Number of part's insertion effects
  60. */
  61. #define NUM_PART_EFX 3
  62. /*
  63. * Maximum number of the instrument on a part
  64. */
  65. #define NUM_KIT_ITEMS 16
  66. /*
  67. * How is applied the velocity sensing
  68. */
  69. #define VELOCITY_MAX_SCALE 8.0f
  70. /*
  71. * The maximum length of instrument's name
  72. */
  73. #define PART_MAX_NAME_LEN 30
  74. /*
  75. * The maximum number of bands of the equaliser
  76. */
  77. #define MAX_EQ_BANDS 8
  78. #if (MAX_EQ_BANDS >= 20)
  79. #error "Too many EQ bands in globals.h"
  80. #endif
  81. /*
  82. * Maximum filter stages
  83. */
  84. #define MAX_FILTER_STAGES 5
  85. /*
  86. * Formant filter (FF) limits
  87. */
  88. #define FF_MAX_VOWELS 6
  89. #define FF_MAX_FORMANTS 12
  90. #define FF_MAX_SEQUENCE 8
  91. #define LOG_2 0.693147181f
  92. #define PI 3.1415926536f
  93. #define LOG_10 2.302585093f
  94. /*
  95. * The threshold for the amplitude interpolation used if the amplitude
  96. * is changed (by LFO's or Envelope's). If the change of the amplitude
  97. * is below this, the amplitude is not interpolated
  98. */
  99. #define AMPLITUDE_INTERPOLATION_THRESHOLD 0.0001f
  100. /*
  101. * How the amplitude threshold is computed
  102. */
  103. #define ABOVE_AMPLITUDE_THRESHOLD(a, b) ((2.0f * fabs((b) - (a)) \
  104. / (fabs((b) + (a) \
  105. + 0.0000000001f))) > \
  106. AMPLITUDE_INTERPOLATION_THRESHOLD)
  107. /*
  108. * Interpolate Amplitude
  109. */
  110. #define INTERPOLATE_AMPLITUDE(a, b, x, size) ((a) \
  111. + ((b) \
  112. - (a)) * (float)(x) \
  113. / (float) (size))
  114. /*
  115. * dB
  116. */
  117. #define dB2rap(dB) ((expf((dB) * LOG_10 / 20.0f)))
  118. #define rap2dB(rap) ((20 * logf(rap) / LOG_10))
  119. #define ZERO(data, size) {char *data_ = (char *) data; for(int i = 0; \
  120. i < size; \
  121. i++) \
  122. data_[i] = 0; }
  123. #define ZERO_float(data, size) {float *data_ = (float *) data; \
  124. for(int i = 0; \
  125. i < size; \
  126. i++) \
  127. data_[i] = 0.0f; }
  128. enum ONOFFTYPE {
  129. OFF = 0, ON = 1
  130. };
  131. enum MidiControllers {
  132. C_bankselectmsb = 0, C_pitchwheel = 1000, C_NULL = 1001,
  133. C_expression = 11, C_panning = 10, C_bankselectlsb = 32,
  134. C_filtercutoff = 74, C_filterq = 71, C_bandwidth = 75, C_modwheel = 1,
  135. C_fmamp = 76,
  136. C_volume = 7, C_sustain = 64, C_allnotesoff = 123, C_allsoundsoff = 120,
  137. C_resetallcontrollers = 121,
  138. C_portamento = 65, C_resonance_center = 77, C_resonance_bandwidth = 78,
  139. C_dataentryhi = 0x06, C_dataentrylo = 0x26, C_nrpnhi = 99, C_nrpnlo = 98
  140. };
  141. enum LegatoMsg {
  142. LM_Norm, LM_FadeIn, LM_FadeOut, LM_CatchUp, LM_ToNorm
  143. };
  144. //is like i=(int)(floor(f))
  145. #ifdef ASM_F2I_YES
  146. #define F2I(f, \
  147. i) __asm__ __volatile__ ("fistpl %0" : "=m" (i) : "t" (f \
  148. - \
  149. 0.49999999f) \
  150. : "st");
  151. #else
  152. #define F2I(f, i) (i) = ((f > 0) ? ((int)(f)) : ((int)(f - 1.0f)));
  153. #endif
  154. #ifndef O_BINARY
  155. #define O_BINARY 0
  156. #endif
  157. //temporary include for synth->{samplerate/buffersize} members
  158. struct SYNTH_T {
  159. SYNTH_T(void)
  160. :samplerate(44100), buffersize(256), oscilsize(1024)
  161. {
  162. alias();
  163. }
  164. /**Sampling rate*/
  165. unsigned int samplerate;
  166. /**
  167. * The size of a sound buffer (or the granularity)
  168. * All internal transfer of sound data use buffer of this size
  169. * All parameters are constant during this period of time, exception
  170. * some parameters(like amplitudes) which are linear interpolated.
  171. * If you increase this you'll ecounter big latencies, but if you
  172. * decrease this the CPU requirements gets high.
  173. */
  174. int buffersize;
  175. /**
  176. * The size of ADnote Oscillator
  177. * Decrease this => poor quality
  178. * Increase this => CPU requirements gets high (only at start of the note)
  179. */
  180. int oscilsize;
  181. //Alias for above terms
  182. float samplerate_f;
  183. float halfsamplerate_f;
  184. float buffersize_f;
  185. int bufferbytes;
  186. float oscilsize_f;
  187. inline void alias(void)
  188. {
  189. halfsamplerate_f = (samplerate_f = samplerate) / 2.0f;
  190. buffersize_f = buffersize;
  191. bufferbytes = buffersize * sizeof(float);
  192. oscilsize_f = oscilsize;
  193. }
  194. static float numRandom(void); //defined in Util.cpp for now
  195. };
  196. extern SYNTH_T *synth;
  197. #endif