home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 November / CMCD1104.ISO / Software / Complet / ZynAddFX / Setup_ZynAddSubFX-2.1.1.exe / globals.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-07-15  |  4.7 KB  |  214 lines

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