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_amp_envelope_get_float(
51 unsigned int parameter
)
55 case ZYNADD_PARAMETER_FLOAT_ENV_ATTACK_DURATION
:
56 return percent_from_0_127(
57 envelope_params_ptr
->get_duration(
58 envelope_params_ptr
->m_attack_duration_index
));
59 case ZYNADD_PARAMETER_FLOAT_ENV_DECAY_DURATION
:
60 return percent_from_0_127(
61 envelope_params_ptr
->get_duration(
62 envelope_params_ptr
->m_decay_duration_index
));
63 case ZYNADD_PARAMETER_FLOAT_ENV_SUSTAIN_VALUE
:
64 return percent_from_0_127(
65 envelope_params_ptr
->get_value(
66 envelope_params_ptr
->m_sustain_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(
73 envelope_params_ptr
->m_stretch
) * 2;
75 LOG_ERROR("Unknown amplitude envelope parameter %u", parameter
);
81 zyn_component_amp_envelope_set_float(
83 unsigned int parameter
,
88 case ZYNADD_PARAMETER_FLOAT_ENV_ATTACK_DURATION
:
89 envelope_params_ptr
->set_duration(
90 envelope_params_ptr
->m_attack_duration_index
,
91 percent_to_0_127(value
));
93 case ZYNADD_PARAMETER_FLOAT_ENV_DECAY_DURATION
:
94 envelope_params_ptr
->set_duration(
95 envelope_params_ptr
->m_decay_duration_index
,
96 percent_to_0_127(value
));
98 case ZYNADD_PARAMETER_FLOAT_ENV_SUSTAIN_VALUE
:
99 envelope_params_ptr
->set_value(
100 envelope_params_ptr
->m_sustain_value_index
,
101 percent_to_0_127(value
));
103 case ZYNADD_PARAMETER_FLOAT_ENV_RELEASE_DURATION
:
104 envelope_params_ptr
->set_duration(
105 envelope_params_ptr
->m_release_duration_index
,
106 percent_to_0_127(value
));
108 case ZYNADD_PARAMETER_FLOAT_ENV_STRETCH
:
109 envelope_params_ptr
->m_stretch
= percent_to_0_127(value
/2);
112 LOG_ERROR("Unknown amplitude envelope parameter %u", parameter
);
118 zyn_component_amp_envelope_get_int(
120 unsigned int parameter
)
127 zyn_component_amp_envelope_set_int(
129 unsigned int parameter
,
136 zyn_component_amp_envelope_get_bool(
138 unsigned int parameter
)
142 case ZYNADD_PARAMETER_BOOL_ENV_FORCED_RELEASE
:
143 return envelope_params_ptr
->m_forced_release
;
144 case ZYNADD_PARAMETER_BOOL_ENV_LINEAR
:
145 return envelope_params_ptr
->m_linear
;
147 LOG_ERROR("Unknown bool amplitude envelope parameter %u", parameter
);
153 zyn_component_amp_envelope_set_bool(
155 unsigned int parameter
,
160 case ZYNADD_PARAMETER_BOOL_ENV_FORCED_RELEASE
:
161 envelope_params_ptr
->m_forced_release
= value
;
163 case ZYNADD_PARAMETER_BOOL_ENV_LINEAR
:
164 envelope_params_ptr
->m_linear
= value
;
167 LOG_ERROR("Unknown bool amplitude envelope parameter %u", parameter
);
172 #undef envelope_params_ptr
175 zyn_addsynth_component_init_amp_envelope(
176 struct zyn_component_descriptor
* component_ptr
,
177 EnvelopeParams
* envelope_params_ptr
)
179 ZYN_INIT_COMPONENT(component_ptr
, envelope_params_ptr
, zyn_component_amp_envelope_
);