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_frequency_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_RELEASE_VALUE
:
64 return percent_from_0_127(
65 envelope_params_ptr
->get_value(
66 envelope_params_ptr
->m_release_value_index
));
67 case ZYNADD_PARAMETER_FLOAT_ENV_RELEASE_DURATION
:
68 return percent_from_0_127(
69 envelope_params_ptr
->get_duration(
70 envelope_params_ptr
->m_release_duration_index
));
71 case ZYNADD_PARAMETER_FLOAT_ENV_STRETCH
:
72 return percent_from_0_127(envelope_params_ptr
->m_stretch
) * 2;
74 LOG_ERROR("Unknown frequency envelope parameter %u", parameter
);
80 zyn_component_frequency_envelope_set_float(
82 unsigned int parameter
,
87 case ZYNADD_PARAMETER_FLOAT_ENV_ATTACK_VALUE
:
88 envelope_params_ptr
->set_value(
89 envelope_params_ptr
->m_attack_value_index
,
90 percent_to_0_127(value
));
92 case ZYNADD_PARAMETER_FLOAT_ENV_ATTACK_DURATION
:
93 envelope_params_ptr
->set_duration(
94 envelope_params_ptr
->m_attack_duration_index
,
95 percent_to_0_127(value
));
97 case ZYNADD_PARAMETER_FLOAT_ENV_RELEASE_VALUE
:
98 envelope_params_ptr
->set_value(
99 envelope_params_ptr
->m_release_value_index
,
100 percent_to_0_127(value
));
102 case ZYNADD_PARAMETER_FLOAT_ENV_RELEASE_DURATION
:
103 envelope_params_ptr
->set_duration(
104 envelope_params_ptr
->m_release_duration_index
,
105 percent_to_0_127(value
));
107 case ZYNADD_PARAMETER_FLOAT_ENV_STRETCH
:
108 envelope_params_ptr
->m_stretch
= percent_to_0_127(value
/2);
111 LOG_ERROR("Unknown frequency envelope parameter %u", parameter
);
117 zyn_component_frequency_envelope_get_int(
119 unsigned int parameter
)
126 zyn_component_frequency_envelope_set_int(
128 unsigned int parameter
,
135 zyn_component_frequency_envelope_get_bool(
137 unsigned int parameter
)
141 case ZYNADD_PARAMETER_BOOL_ENV_FORCED_RELEASE
:
142 return envelope_params_ptr
->m_forced_release
;
144 LOG_ERROR("Unknown bool frequency envelope parameter %u", parameter
);
150 zyn_component_frequency_envelope_set_bool(
152 unsigned int parameter
,
157 case ZYNADD_PARAMETER_BOOL_ENV_FORCED_RELEASE
:
158 envelope_params_ptr
->m_forced_release
= value
;
161 LOG_ERROR("Unknown bool frequency envelope parameter %u", parameter
);
166 #undef envelope_params_ptr
169 zyn_addsynth_component_init_frequency_envelope(
170 struct zyn_component_descriptor
* component_ptr
,
171 EnvelopeParams
* envelope_params_ptr
)
173 ZYN_INIT_COMPONENT(component_ptr
, envelope_params_ptr
, zyn_component_frequency_envelope_
);