1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * Copyright (C) 2006,2007 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"
29 #include "filter_parameters.h"
30 #include "filter_base.h"
31 #include "filter_common.h"
32 #include "analog_filter.h"
33 #include "sv_filter.h"
34 #include "formant_filter.h"
36 #include "envelope_parameters.h"
39 #include "resonance.h"
41 #include "oscillator.h"
42 #include "portamento.h"
43 #include "addsynth_internal.h"
46 #define zyn_addsynth_ptr ((struct zyn_addsynth *)context)
49 zyn_component_filter_analog_get_float(
51 unsigned int parameter
)
55 case ZYNADD_PARAMETER_FLOAT_FREQUNECY
:
56 return percent_from_0_127(zyn_addsynth_ptr
->m_filter_params
.Pfreq
) / 100;
57 case ZYNADD_PARAMETER_FLOAT_Q_FACTOR
:
58 return percent_from_0_127(zyn_addsynth_ptr
->m_filter_params
.Pq
) / 100;
59 case ZYNADD_PARAMETER_FLOAT_FREQUENCY_TRACKING
:
60 return zyn_addsynth_ptr
->m_filter_params
.m_frequency_tracking
;
61 case ZYNADD_PARAMETER_FLOAT_VOLUME
:
62 return zyn_addsynth_ptr
->m_filter_params
.m_gain
;
65 LOG_ERROR("Unknown analog filter float parameter %u", parameter
);
72 zyn_component_filter_analog_set_float(
74 unsigned int parameter
,
79 case ZYNADD_PARAMETER_FLOAT_FREQUNECY
:
80 zyn_addsynth_ptr
->m_filter_params
.Pfreq
= percent_to_0_127(value
* 100);
82 case ZYNADD_PARAMETER_FLOAT_Q_FACTOR
:
83 zyn_addsynth_ptr
->m_filter_params
.Pq
= percent_to_0_127(value
* 100);
85 case ZYNADD_PARAMETER_FLOAT_FREQUENCY_TRACKING
:
86 zyn_addsynth_ptr
->m_filter_params
.m_frequency_tracking
= value
;
88 case ZYNADD_PARAMETER_FLOAT_VOLUME
:
89 zyn_addsynth_ptr
->m_filter_params
.m_gain
= value
;
93 LOG_ERROR("Unknown analog filter float parameter %u", parameter
);
98 zyn_component_filter_analog_get_int(
100 unsigned int parameter
)
104 case ZYNADD_PARAMETER_INT_STAGES
:
105 return zyn_addsynth_ptr
->m_filter_params
.m_additional_stages
+ 1;
106 case ZYNADD_PARAMETER_ENUM_FILTER_TYPE
:
107 return ZYN_FILTER_ANALOG_TYPE_LPF1
;
110 LOG_ERROR("Unknown analog filter int/enum parameter %u", parameter
);
117 zyn_component_filter_analog_set_int(
119 unsigned int parameter
,
124 case ZYNADD_PARAMETER_INT_STAGES
:
126 assert(value
<= MAX_FILTER_STAGES
);
127 zyn_addsynth_ptr
->m_filter_params
.m_additional_stages
= value
- 1;
129 case ZYNADD_PARAMETER_ENUM_FILTER_TYPE
:
133 LOG_ERROR("Unknown analog filter int/enum parameter %u", parameter
);
138 zyn_component_filter_analog_get_bool(
140 unsigned int parameter
)
142 LOG_ERROR("Unknown analog filter bool parameter %u", parameter
);
149 zyn_component_filter_analog_set_bool(
151 unsigned int parameter
,
154 LOG_ERROR("Unknown analog filter bool parameter %u", parameter
);
158 #undef zyn_addsynth_ptr
161 zyn_addsynth_component_init_filter_analog(
162 struct zyn_component_descriptor
* component_ptr
,
163 struct zyn_addsynth
* zyn_addsynth_ptr
)
165 ZYN_INIT_COMPONENT(component_ptr
, zyn_addsynth_ptr
, zyn_component_filter_analog_
);