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 zyn_addsynth_ptr ((struct zyn_addsynth *)context)
40 zyn_component_filter_analog_get_float(
42 unsigned int parameter
)
46 case ZYNADD_PARAMETER_FLOAT_FREQUNECY
:
47 return percent_from_0_127(zyn_addsynth_ptr
->m_filter_params
.Pfreq
) / 100;
48 case ZYNADD_PARAMETER_FLOAT_Q_FACTOR
:
49 return percent_from_0_127(zyn_addsynth_ptr
->m_filter_params
.Pq
) / 100;
50 case ZYNADD_PARAMETER_FLOAT_FREQUENCY_TRACKING
:
51 return zyn_addsynth_ptr
->m_filter_params
.m_frequency_tracking
;
52 case ZYNADD_PARAMETER_FLOAT_VOLUME
:
53 return zyn_addsynth_ptr
->m_filter_params
.m_gain
;
56 LOG_ERROR("Unknown analog filter float parameter %u", parameter
);
63 zyn_component_filter_analog_set_float(
65 unsigned int parameter
,
70 case ZYNADD_PARAMETER_FLOAT_FREQUNECY
:
71 zyn_addsynth_ptr
->m_filter_params
.Pfreq
= percent_to_0_127(value
* 100);
73 case ZYNADD_PARAMETER_FLOAT_Q_FACTOR
:
74 zyn_addsynth_ptr
->m_filter_params
.Pq
= percent_to_0_127(value
* 100);
76 case ZYNADD_PARAMETER_FLOAT_FREQUENCY_TRACKING
:
77 zyn_addsynth_ptr
->m_filter_params
.m_frequency_tracking
= value
;
79 case ZYNADD_PARAMETER_FLOAT_VOLUME
:
80 zyn_addsynth_ptr
->m_filter_params
.m_gain
= value
;
84 LOG_ERROR("Unknown analog filter float parameter %u", parameter
);
89 zyn_component_filter_analog_get_int(
91 unsigned int parameter
)
95 case ZYNADD_PARAMETER_INT_STAGES
:
96 return zyn_addsynth_ptr
->m_filter_params
.m_additional_stages
+ 1;
97 case ZYNADD_PARAMETER_ENUM_FILTER_TYPE
:
98 return ZYN_FILTER_ANALOG_TYPE_LPF1
;
101 LOG_ERROR("Unknown analog filter int/enum parameter %u", parameter
);
108 zyn_component_filter_analog_set_int(
110 unsigned int parameter
,
115 case ZYNADD_PARAMETER_INT_STAGES
:
117 assert(value
<= MAX_FILTER_STAGES
);
118 zyn_addsynth_ptr
->m_filter_params
.m_additional_stages
= value
- 1;
120 case ZYNADD_PARAMETER_ENUM_FILTER_TYPE
:
124 LOG_ERROR("Unknown analog filter int/enum parameter %u", parameter
);
129 zyn_component_filter_analog_get_bool(
131 unsigned int parameter
)
133 LOG_ERROR("Unknown analog filter bool parameter %u", parameter
);
140 zyn_component_filter_analog_set_bool(
142 unsigned int parameter
,
145 LOG_ERROR("Unknown analog filter bool parameter %u", parameter
);
149 #undef zyn_addsynth_ptr
152 zyn_addsynth_component_init_filter_analog(
153 struct zyn_component_descriptor
* component_ptr
,
154 struct zyn_addsynth
* zyn_addsynth_ptr
)
156 ZYN_INIT_COMPONENT(component_ptr
, zyn_addsynth_ptr
, zyn_component_filter_analog_
);