Minot coding style fix
[zyn.git] / addsynth_component_lfo.cpp
blob8776da31fcd14cc51e4dbeb84f978947a608fc8f
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 #include <stdbool.h>
22 #include <assert.h>
24 #include "common.h"
25 #include "globals.h"
26 #include "addsynth.h"
27 #include "lfo_parameters.h"
28 #include "filter_parameters.h"
29 #include "envelope_parameters.h"
30 #include "resonance.h"
31 #include "fft.h"
32 #include "oscillator.h"
33 #include "portamento.h"
34 #include "addsynth_internal.h"
35 #include "log.h"
37 #define lfo_params_ptr ((struct zyn_lfo_parameters * )context)
39 float
40 zyn_component_lfo_get_float(
41 void * context,
42 unsigned int parameter)
44 switch (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;
60 default:
61 LOG_ERROR("Unknown LFO parameter %u", parameter);
62 assert(0);
66 void
67 zyn_component_lfo_set_float(
68 void * context,
69 unsigned int parameter,
70 float value)
72 switch (parameter)
74 case ZYNADD_PARAMETER_FLOAT_LFO_FREQUENCY:
75 lfo_params_ptr->frequency = value;
76 return;
77 case ZYNADD_PARAMETER_FLOAT_LFO_DEPTH:
78 lfo_params_ptr->depth = value / 100;
79 return;
80 case ZYNADD_PARAMETER_FLOAT_LFO_START_PHASE:
81 lfo_params_ptr->start_phase = value;
82 return;
83 case ZYNADD_PARAMETER_FLOAT_LFO_DELAY:
84 lfo_params_ptr->delay = value;
85 return;
86 case ZYNADD_PARAMETER_FLOAT_LFO_STRETCH:
87 lfo_params_ptr->stretch = value;
88 return;
89 case ZYNADD_PARAMETER_FLOAT_LFO_DEPTH_RANDOMNESS:
90 lfo_params_ptr->depth_randomness = value / 100;
91 return;
92 case ZYNADD_PARAMETER_FLOAT_LFO_FREQUENCY_RANDOMNESS:
93 lfo_params_ptr->frequency_randomness = value / 100;
94 return;
95 default:
96 LOG_ERROR("Unknown LFO parameter %u", parameter);
97 assert(0);
101 signed int
102 zyn_component_lfo_get_int(
103 void * context,
104 unsigned int parameter)
106 switch (parameter)
108 case ZYNADD_PARAMETER_ENUM_LFO_SHAPE:
109 return lfo_params_ptr->shape;
112 LOG_ERROR("Unknown int LFO parameter %u", parameter);
113 assert(0);
114 return -1;
117 void
118 zyn_component_lfo_set_int(
119 void * context,
120 unsigned int parameter,
121 signed int value)
123 switch (parameter)
125 case ZYNADD_PARAMETER_ENUM_LFO_SHAPE:
126 lfo_params_ptr->shape = value;
127 return;
130 LOG_ERROR("Unknown int LFO parameter %u", parameter);
131 assert(0);
134 bool
135 zyn_component_lfo_get_bool(
136 void * context,
137 unsigned int parameter)
139 switch (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;
147 default:
148 LOG_ERROR("Unknown bool LFO parameter %u", parameter);
149 assert(0);
153 void
154 zyn_component_lfo_set_bool(
155 void * context,
156 unsigned int parameter,
157 bool value)
159 switch (parameter)
161 case ZYNADD_PARAMETER_BOOL_LFO_RANDOM_START_PHASE:
162 lfo_params_ptr->random_start_phase = value;
163 return;
164 case ZYNADD_PARAMETER_BOOL_LFO_RANDOM_DEPTH:
165 lfo_params_ptr->depth_randomness_enabled = value;
166 return;
167 case ZYNADD_PARAMETER_BOOL_LFO_RANDOM_FREQUENCY:
168 lfo_params_ptr->frequency_randomness_enabled = value;
169 return;
170 default:
171 LOG_ERROR("Unknown bool LFO parameter %u", parameter);
172 assert(0);
176 #undef lfo_params_ptr
178 void
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_);