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 envelope_params_ptr ((EnvelopeParams * )context)
49 zyn_component_filter_envelope_get_float(
51 unsigned int parameter
)
55 case ZYNADD_PARAMETER_FLOAT_ENV_ATTACK_VALUE
:
56 return percent_from_0_127(
57 envelope_params_ptr
->get_value(
58 envelope_params_ptr
->m_attack_value_index
));
59 case ZYNADD_PARAMETER_FLOAT_ENV_ATTACK_DURATION
:
60 return percent_from_0_127(
61 envelope_params_ptr
->get_duration(
62 envelope_params_ptr
->m_attack_duration_index
));
63 case ZYNADD_PARAMETER_FLOAT_ENV_DECAY_VALUE
:
64 return percent_from_0_127(
65 envelope_params_ptr
->get_value(
66 envelope_params_ptr
->m_decay_value_index
));
67 case ZYNADD_PARAMETER_FLOAT_ENV_DECAY_DURATION
:
68 return percent_from_0_127(
69 envelope_params_ptr
->get_duration(
70 envelope_params_ptr
->m_decay_duration_index
));
71 case ZYNADD_PARAMETER_FLOAT_ENV_RELEASE_VALUE
:
72 return percent_from_0_127(
73 envelope_params_ptr
->get_value(
74 envelope_params_ptr
->m_release_value_index
));
75 case ZYNADD_PARAMETER_FLOAT_ENV_RELEASE_DURATION
:
76 return percent_from_0_127(
77 envelope_params_ptr
->get_duration(
78 envelope_params_ptr
->m_release_duration_index
));
79 case ZYNADD_PARAMETER_FLOAT_ENV_STRETCH
:
80 return percent_from_0_127(envelope_params_ptr
->m_stretch
) * 2;
82 LOG_ERROR("Unknown filter envelope parameter %u", parameter
);
88 zyn_component_filter_envelope_set_float(
90 unsigned int parameter
,
95 case ZYNADD_PARAMETER_FLOAT_ENV_ATTACK_VALUE
:
96 envelope_params_ptr
->set_value(
97 envelope_params_ptr
->m_attack_value_index
,
98 percent_to_0_127(value
));
100 case ZYNADD_PARAMETER_FLOAT_ENV_ATTACK_DURATION
:
101 envelope_params_ptr
->set_duration(
102 envelope_params_ptr
->m_attack_duration_index
,
103 percent_to_0_127(value
));
105 case ZYNADD_PARAMETER_FLOAT_ENV_DECAY_VALUE
:
106 envelope_params_ptr
->set_value(
107 envelope_params_ptr
->m_decay_value_index
,
108 percent_to_0_127(value
));
110 case ZYNADD_PARAMETER_FLOAT_ENV_DECAY_DURATION
:
111 envelope_params_ptr
->set_duration(
112 envelope_params_ptr
->m_decay_duration_index
,
113 percent_to_0_127(value
));
115 case ZYNADD_PARAMETER_FLOAT_ENV_RELEASE_VALUE
:
116 envelope_params_ptr
->set_value(
117 envelope_params_ptr
->m_release_value_index
,
118 percent_to_0_127(value
));
120 case ZYNADD_PARAMETER_FLOAT_ENV_RELEASE_DURATION
:
121 envelope_params_ptr
->set_duration(
122 envelope_params_ptr
->m_release_duration_index
,
123 percent_to_0_127(value
));
125 case ZYNADD_PARAMETER_FLOAT_ENV_STRETCH
:
126 envelope_params_ptr
->m_stretch
= percent_to_0_127(value
/2);
129 LOG_ERROR("Unknown filter envelope parameter %u", parameter
);
135 zyn_component_filter_envelope_get_int(
137 unsigned int parameter
)
144 zyn_component_filter_envelope_set_int(
146 unsigned int parameter
,
153 zyn_component_filter_envelope_get_bool(
155 unsigned int parameter
)
159 case ZYNADD_PARAMETER_BOOL_ENV_FORCED_RELEASE
:
160 return envelope_params_ptr
->m_forced_release
;
162 LOG_ERROR("Unknown bool filter envelope parameter %u", parameter
);
168 zyn_component_filter_envelope_set_bool(
170 unsigned int parameter
,
175 case ZYNADD_PARAMETER_BOOL_ENV_FORCED_RELEASE
:
176 envelope_params_ptr
->m_forced_release
= value
;
179 LOG_ERROR("Unknown bool filter envelope parameter %u", parameter
);
184 #undef envelope_params_ptr
187 zyn_addsynth_component_init_filter_envelope(
188 struct zyn_component_descriptor
* component_ptr
,
189 EnvelopeParams
* envelope_params_ptr
)
191 ZYN_INIT_COMPONENT(component_ptr
, envelope_params_ptr
, zyn_component_filter_envelope_
);