1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * Copyright (C) 2006,2007,2008,2009 Nedko Arnaudov <nedko@arnaudov.name>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License
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 for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *****************************************************************************/
21 #ifndef ADDSYNTH_INTERNAL_H__9870368A_F1C9_4F0D_ADC1_B07ECFF2F9C7__INCLUDED
22 #define ADDSYNTH_INTERNAL_H__9870368A_F1C9_4F0D_ADC1_B07ECFF2F9C7__INCLUDED
24 #include "filter_common.h"
25 #include "filter_sv.h"
29 #define ZYN_FM_TYPE_NONE 0
30 #define ZYN_FM_TYPE_MORPH 1
31 #define ZYN_FM_TYPE_RING_MOD 2
32 #define ZYN_FM_TYPE_PHASE_MOD 3
33 #define ZYN_FM_TYPE_FREQ_MOD 4
34 #define ZYN_FM_TYPE_PITCH_MOD 5 /* code for this is disabled for some reason */
36 struct zyn_fixed_detune
38 int mode
; /* One of ZYN_DETUNE_MODE_XXX */
41 /* at 64, 1 MIDI halftone -> 1 frequency halftone */
42 unsigned char equal_temperate
;
47 signed int type
; /* Detune type, one of ZYN_DETUNE_TYPE_XXX */
48 signed int octave
; /* Octave, -8..7 */
49 signed int coarse
; /* Coarse detune, -64 .. 63 */
50 float fine
; /* Fine detune, -1..1 */
53 /***********************************************************/
54 /* VOICE PARAMETERS */
55 /***********************************************************/
56 struct zyn_addnote_voice_parameters
58 /* whether voice is enabled */
61 /* Type of the voice (false = Sound, true = White Noise)*/
67 /* whether resonance is enabled for this voice */
70 // What external oscil should I use, -1 for internal OscilSmp&FMSmp
71 short int Pextoscil
,PextFMoscil
;
72 // it is not allowed that the externoscil,externFMoscil => current voice
75 unsigned char Poscilphase
,PFMoscilphase
;
78 unsigned char Pfilterbypass
;
80 /* Voice oscillator */
81 struct zyn_oscillator oscillator
;
83 /**********************************
84 * FREQUENCY PARAMETERS *
85 **********************************/
87 struct zyn_detune detune
;
88 struct zyn_fixed_detune fixed_detune
;
90 /* Frequency Envelope */
91 unsigned char PFreqEnvelopeEnabled
;
92 EnvelopeParams m_frequency_envelope_params
;
95 unsigned char PFreqLfoEnabled
;
96 struct zyn_lfo_parameters frequency_lfo_params
;
98 /***************************
99 * AMPLITUDE PARAMETERS *
100 ***************************/
102 /* Panning 0 - random
106 The Panning is ignored if the instrument is mono */
107 unsigned char PPanning
;
110 unsigned char PVolume
;
112 /* If the Volume negative */
113 unsigned char PVolumeminus
;
115 /* Velocity sensing */
116 unsigned char PAmpVelocityScaleFunction
;
118 /* Amplitude Envelope */
119 unsigned char PAmpEnvelopeEnabled
;
120 EnvelopeParams m_amplitude_envelope_params
;
123 unsigned char PAmpLfoEnabled
;
124 struct zyn_lfo_parameters amplitude_lfo_params
;
126 /*************************
127 * FILTER PARAMETERS *
128 *************************/
131 unsigned char PFilterEnabled
;
132 FilterParams m_filter_params
;
134 /* Filter Envelope */
135 unsigned char PFilterEnvelopeEnabled
;
136 EnvelopeParams m_filter_envelope_params
;
139 unsigned char PFilterLfoEnabled
;
140 struct zyn_lfo_parameters filter_lfo_params
;
142 /****************************
143 * MODULLATOR PARAMETERS *
144 ****************************/
146 /* Modullator Parameters, one of ZYN_FM_TYPE_XXX */
147 unsigned int fm_type
;
149 /* Voice that I use as modullator instead of FMSmp.
150 It is -1 if I use FMSmp(default).
151 It maynot be equal or bigger than current voice */
154 /* Modullator oscillator */
155 struct zyn_oscillator modulator_oscillator
;
157 /* Modullator Volume */
158 unsigned char PFMVolume
;
160 /* Modullator damping at higher frequencies */
161 unsigned char PFMVolumeDamp
;
163 /* Modullator Velocity Sensing */
164 unsigned char PFMVelocityScaleFunction
;
166 /* Detune of the Modullator */
167 struct zyn_detune fm_detune
;
169 /* Frequency Envelope of the Modullator */
170 unsigned char PFMFreqEnvelopeEnabled
;
171 EnvelopeParams m_fm_frequency_envelope_params
;
173 /* Frequency Envelope of the Modullator */
174 unsigned char PFMAmpEnvelopeEnabled
;
175 EnvelopeParams m_fm_amplitude_envelope_params
;
178 #include "addsynth_component.h"
183 unsigned int polyphony
;
184 struct note_channel
* notes_array
;
187 unsigned char velsns
; // velocity sensing (amplitude velocity scale)
188 zyn_sample_type oldfreq
; // this is used for portamento
190 bool random_panorama
; // whether panorama is random for each note
191 float panorama
; // -1.0 for left, 0.0 for center, 1.0 for right
193 /* The instrument type - MONO/STEREO
194 If the mode is MONO, the panning of voices are not used
195 Stereo=true, Mono=false. */
196 bool stereo
; // stereo or mono
198 // How the Harmonic Amplitude is applied to voices that use the same oscillator
199 bool random_grouping
;
202 struct zyn_resonance resonance
;
204 // 0-127, Master volume
205 unsigned char PVolume
;
207 // 0-127, velocity sensing
208 unsigned char PAmpVelocityScaleFunction
;
211 unsigned char PPunchStrength
;
214 unsigned char PPunchTime
;
217 unsigned char PPunchStretch
;
220 unsigned char PPunchVelocitySensing
;
222 // Amplitude LFO parameters
223 struct zyn_lfo_parameters amplitude_lfo_params
;
225 EnvelopeParams m_amplitude_envelope_params
;
227 int filter_type
; /* filter category/supertype, one of ZYN_FILTER_TYPE_XXX */
228 FilterParams m_filter_params
;
229 zyn_filter_sv_handle filter_sv
;
231 // Velocity sensing amount of the Filter, 0 .. 1
232 float m_filter_velocity_sensing_amount
;
234 // Velocity sensing function of the Filter, 1 .. -1
235 float m_filter_velocity_scale_function
;
237 // Filter LFO parameters
238 struct zyn_lfo_parameters filter_lfo_params
;
240 EnvelopeParams m_filter_envelope_params
;
242 struct zyn_detune detune
;
244 /* how much the relative fine detunes of the voices are changed */
246 float detune_bandwidth
;
248 // Frequency LFO parameters
249 struct zyn_lfo_parameters frequency_lfo_params
;
251 EnvelopeParams m_frequency_envelope_params
;
253 zyn_portamento portamento
;
255 float pitch_bend_range
;
257 float pitch_bend_relative_frequency
;
260 int bandwidth_exponential
;
261 float bandwidth_relbw
;
264 int modwheel_exponential
;
265 float modwheel_relmod
;
267 zyn_sample_type
* temporary_samples_ptr
; // this array stores some termporary data and it has OSCIL_SIZE elements
268 struct zyn_fft_freqs oscillator_fft_frequencies
;
270 unsigned int voices_count
;
272 struct zyn_addnote_voice_parameters
* voices_params_ptr
; /* array with one entry per voice */
274 struct zyn_component_descriptor global_components
[ZYNADD_GLOBAL_COMPONENTS_COUNT
];
276 struct zyn_component_descriptor
* voices_components
;
283 } /* Adjust editor indent */
286 float percent_from_0_127(unsigned char value
);
287 unsigned char percent_to_0_127(float value
);
289 void zyn_addsynth_set_bandwidth(struct zyn_addsynth
* zyn_addsynth_ptr
, int value
);
290 void zyn_addsynth_set_modwheel(struct zyn_addsynth
* zyn_addsynth_ptr
, int value
);
293 { /* Adjust editor indent */
299 #define ZYN_UPDATE_PITCH_BEND(zyn_addsynth_ptr) \
300 (zyn_addsynth_ptr)->pitch_bend_relative_frequency = \
301 pow(2, (zyn_addsynth_ptr)->pitch_bend * \
302 (zyn_addsynth_ptr)->pitch_bend_range / \
305 #endif /* #ifndef ADDSYNTH_INTERNAL_H__9870368A_F1C9_4F0D_ADC1_B07ECFF2F9C7__INCLUDED */