Add some foaf and doap info to zynadd.ttl
[zyn.git] / addsynth_component_filter_analog.cpp
blobda702de5a01ba314c3c0cc37e6722f7e9b0b2047
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 *****************************************************************************/
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 "lfo.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"
35 #include "filter.h"
36 #include "envelope_parameters.h"
37 #include "envelope.h"
38 #include "addnote.h"
39 #include "resonance.h"
40 #include "fft.h"
41 #include "oscillator.h"
42 #include "portamento.h"
43 #include "addsynth_internal.h"
44 #include "log.h"
46 #define zyn_addsynth_ptr ((struct zyn_addsynth *)context)
48 float
49 zyn_component_filter_analog_get_float(
50 void * context,
51 unsigned int parameter)
53 switch (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);
66 assert(0);
68 return 0.0;
71 void
72 zyn_component_filter_analog_set_float(
73 void * context,
74 unsigned int parameter,
75 float value)
77 switch (parameter)
79 case ZYNADD_PARAMETER_FLOAT_FREQUNECY:
80 zyn_addsynth_ptr->m_filter_params.Pfreq = percent_to_0_127(value * 100);
81 return;
82 case ZYNADD_PARAMETER_FLOAT_Q_FACTOR:
83 zyn_addsynth_ptr->m_filter_params.Pq = percent_to_0_127(value * 100);
84 return;
85 case ZYNADD_PARAMETER_FLOAT_FREQUENCY_TRACKING:
86 zyn_addsynth_ptr->m_filter_params.m_frequency_tracking = value;
87 return;
88 case ZYNADD_PARAMETER_FLOAT_VOLUME:
89 zyn_addsynth_ptr->m_filter_params.m_gain = value;
90 return;
93 LOG_ERROR("Unknown analog filter float parameter %u", parameter);
94 assert(0);
97 signed int
98 zyn_component_filter_analog_get_int(
99 void * context,
100 unsigned int parameter)
102 switch (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);
111 assert(0);
113 return -1;
116 void
117 zyn_component_filter_analog_set_int(
118 void * context,
119 unsigned int parameter,
120 signed int value)
122 switch (parameter)
124 case ZYNADD_PARAMETER_INT_STAGES:
125 assert(value > 0);
126 assert(value <= MAX_FILTER_STAGES);
127 zyn_addsynth_ptr->m_filter_params.m_additional_stages = value - 1;
128 return;
129 case ZYNADD_PARAMETER_ENUM_FILTER_TYPE:
130 return;
133 LOG_ERROR("Unknown analog filter int/enum parameter %u", parameter);
134 assert(0);
137 bool
138 zyn_component_filter_analog_get_bool(
139 void * context,
140 unsigned int parameter)
142 LOG_ERROR("Unknown analog filter bool parameter %u", parameter);
143 assert(0);
145 return false;
148 void
149 zyn_component_filter_analog_set_bool(
150 void * context,
151 unsigned int parameter,
152 bool value)
154 LOG_ERROR("Unknown analog filter bool parameter %u", parameter);
155 assert(0);
158 #undef zyn_addsynth_ptr
160 void
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_);