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 *****************************************************************************/
27 #include "lfo_parameters.h"
28 #include "filter_parameters.h"
29 #include "envelope_parameters.h"
30 #include "resonance.h"
32 #include "oscillator.h"
33 #include "portamento.h"
34 #include "addsynth_internal.h"
37 #define lfo_params_ptr ((struct zyn_lfo_parameters * )context)
40 zyn_component_lfo_get_float(
42 unsigned int parameter
)
46 case ZYNADD_PARAMETER_FLOAT_LFO_FREQUENCY
:
47 return lfo_params_ptr
->frequency
;
48 case ZYNADD_PARAMETER_FLOAT_LFO_DEPTH
:
49 return lfo_params_ptr
->depth
* 100;
50 case ZYNADD_PARAMETER_FLOAT_LFO_START_PHASE
:
51 return lfo_params_ptr
->start_phase
;
52 case ZYNADD_PARAMETER_FLOAT_LFO_DELAY
:
53 return lfo_params_ptr
->delay
;
54 case ZYNADD_PARAMETER_FLOAT_LFO_STRETCH
:
55 return lfo_params_ptr
->stretch
;
56 case ZYNADD_PARAMETER_FLOAT_LFO_DEPTH_RANDOMNESS
:
57 return lfo_params_ptr
->depth_randomness
* 100;
58 case ZYNADD_PARAMETER_FLOAT_LFO_FREQUENCY_RANDOMNESS
:
59 return lfo_params_ptr
->frequency_randomness
* 100;
61 LOG_ERROR("Unknown LFO parameter %u", parameter
);
67 zyn_component_lfo_set_float(
69 unsigned int parameter
,
74 case ZYNADD_PARAMETER_FLOAT_LFO_FREQUENCY
:
75 lfo_params_ptr
->frequency
= value
;
77 case ZYNADD_PARAMETER_FLOAT_LFO_DEPTH
:
78 lfo_params_ptr
->depth
= value
/ 100;
80 case ZYNADD_PARAMETER_FLOAT_LFO_START_PHASE
:
81 lfo_params_ptr
->start_phase
= value
;
83 case ZYNADD_PARAMETER_FLOAT_LFO_DELAY
:
84 lfo_params_ptr
->delay
= value
;
86 case ZYNADD_PARAMETER_FLOAT_LFO_STRETCH
:
87 lfo_params_ptr
->stretch
= value
;
89 case ZYNADD_PARAMETER_FLOAT_LFO_DEPTH_RANDOMNESS
:
90 lfo_params_ptr
->depth_randomness
= value
/ 100;
92 case ZYNADD_PARAMETER_FLOAT_LFO_FREQUENCY_RANDOMNESS
:
93 lfo_params_ptr
->frequency_randomness
= value
/ 100;
96 LOG_ERROR("Unknown LFO parameter %u", parameter
);
102 zyn_component_lfo_get_int(
104 unsigned int parameter
)
108 case ZYNADD_PARAMETER_ENUM_LFO_SHAPE
:
109 return lfo_params_ptr
->shape
;
112 LOG_ERROR("Unknown int LFO parameter %u", parameter
);
118 zyn_component_lfo_set_int(
120 unsigned int parameter
,
125 case ZYNADD_PARAMETER_ENUM_LFO_SHAPE
:
126 lfo_params_ptr
->shape
= value
;
130 LOG_ERROR("Unknown int LFO parameter %u", parameter
);
135 zyn_component_lfo_get_bool(
137 unsigned int parameter
)
141 case ZYNADD_PARAMETER_BOOL_LFO_RANDOM_START_PHASE
:
142 return lfo_params_ptr
->random_start_phase
;
143 case ZYNADD_PARAMETER_BOOL_LFO_RANDOM_DEPTH
:
144 return lfo_params_ptr
->depth_randomness_enabled
;
145 case ZYNADD_PARAMETER_BOOL_LFO_RANDOM_FREQUENCY
:
146 return lfo_params_ptr
->frequency_randomness_enabled
;
148 LOG_ERROR("Unknown bool LFO parameter %u", parameter
);
154 zyn_component_lfo_set_bool(
156 unsigned int parameter
,
161 case ZYNADD_PARAMETER_BOOL_LFO_RANDOM_START_PHASE
:
162 lfo_params_ptr
->random_start_phase
= value
;
164 case ZYNADD_PARAMETER_BOOL_LFO_RANDOM_DEPTH
:
165 lfo_params_ptr
->depth_randomness_enabled
= value
;
167 case ZYNADD_PARAMETER_BOOL_LFO_RANDOM_FREQUENCY
:
168 lfo_params_ptr
->frequency_randomness_enabled
= value
;
171 LOG_ERROR("Unknown bool LFO parameter %u", parameter
);
176 #undef lfo_params_ptr
179 zyn_addsynth_component_init_lfo(
180 struct zyn_component_descriptor
* component_ptr
,
181 struct zyn_lfo_parameters
* lfo_params_ptr
)
183 ZYN_INIT_COMPONENT(component_ptr
, lfo_params_ptr
, zyn_component_lfo_
);