Expose all 8 voices
[zyn.git] / addsynth_component_filter_analog.cpp
blobd795d362e055dc4e9c4e72171018680ca712204c
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 zyn_addsynth_ptr ((struct zyn_addsynth *)context)
39 float
40 zyn_component_filter_analog_get_float(
41 void * context,
42 unsigned int parameter)
44 switch (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);
57 assert(0);
59 return 0.0;
62 void
63 zyn_component_filter_analog_set_float(
64 void * context,
65 unsigned int parameter,
66 float value)
68 switch (parameter)
70 case ZYNADD_PARAMETER_FLOAT_FREQUNECY:
71 zyn_addsynth_ptr->m_filter_params.Pfreq = percent_to_0_127(value * 100);
72 return;
73 case ZYNADD_PARAMETER_FLOAT_Q_FACTOR:
74 zyn_addsynth_ptr->m_filter_params.Pq = percent_to_0_127(value * 100);
75 return;
76 case ZYNADD_PARAMETER_FLOAT_FREQUENCY_TRACKING:
77 zyn_addsynth_ptr->m_filter_params.m_frequency_tracking = value;
78 return;
79 case ZYNADD_PARAMETER_FLOAT_VOLUME:
80 zyn_addsynth_ptr->m_filter_params.m_gain = value;
81 return;
84 LOG_ERROR("Unknown analog filter float parameter %u", parameter);
85 assert(0);
88 signed int
89 zyn_component_filter_analog_get_int(
90 void * context,
91 unsigned int parameter)
93 switch (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);
102 assert(0);
104 return -1;
107 void
108 zyn_component_filter_analog_set_int(
109 void * context,
110 unsigned int parameter,
111 signed int value)
113 switch (parameter)
115 case ZYNADD_PARAMETER_INT_STAGES:
116 assert(value > 0);
117 assert(value <= MAX_FILTER_STAGES);
118 zyn_addsynth_ptr->m_filter_params.m_additional_stages = value - 1;
119 return;
120 case ZYNADD_PARAMETER_ENUM_FILTER_TYPE:
121 return;
124 LOG_ERROR("Unknown analog filter int/enum parameter %u", parameter);
125 assert(0);
128 bool
129 zyn_component_filter_analog_get_bool(
130 void * context,
131 unsigned int parameter)
133 LOG_ERROR("Unknown analog filter bool parameter %u", parameter);
134 assert(0);
136 return false;
139 void
140 zyn_component_filter_analog_set_bool(
141 void * context,
142 unsigned int parameter,
143 bool value)
145 LOG_ERROR("Unknown analog filter bool parameter %u", parameter);
146 assert(0);
149 #undef zyn_addsynth_ptr
151 void
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_);