1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * Copyright (C) 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 *****************************************************************************/
26 #include "resonance.h"
27 #include "oscillator.h"
29 #include "portamento.h"
30 #include "addsynth_component.h"
33 #define oscillator_ptr ((struct zyn_oscillator * )context)
36 zyn_oscillator_get_float(
38 unsigned int parameter
)
42 case ZYNADD_PARAMETER_FLOAT_OSCILLATOR_WAVESHAPE_DRIVE
:
43 return oscillator_ptr
->waveshaping_drive
;
44 case ZYNADD_PARAMETER_FLOAT_OSCILLATOR_BASE_FUNCTION_ADJUST
:
45 return oscillator_ptr
->base_function_adjust
;
46 case ZYNADD_PARAMETER_FLOAT_OSCILLATOR_SPECTRUM_ADJUST
:
47 return oscillator_ptr
->spectrum_adjust
;
50 LOG_ERROR("Unknown oscillator float parameter %u", parameter
);
56 zyn_oscillator_set_float(
58 unsigned int parameter
,
63 case ZYNADD_PARAMETER_FLOAT_OSCILLATOR_WAVESHAPE_DRIVE
:
64 assert(value
>= 0.0 && value
<= 100.0);
65 oscillator_ptr
->waveshaping_drive
= value
;
66 oscillator_ptr
->prepared
= false;
68 case ZYNADD_PARAMETER_FLOAT_OSCILLATOR_BASE_FUNCTION_ADJUST
:
69 assert(value
>= 0.0 && value
<= 1.0);
70 oscillator_ptr
->base_function_adjust
= value
;
71 oscillator_ptr
->prepared
= false;
72 oscillator_ptr
->base_function_needs_prepare
= true;
74 case ZYNADD_PARAMETER_FLOAT_OSCILLATOR_SPECTRUM_ADJUST
:
75 assert(value
>= 0.0 && value
<= 100.0);
76 oscillator_ptr
->spectrum_adjust
= value
;
77 oscillator_ptr
->prepared
= false;
81 LOG_ERROR("Unknown oscillator float parameter %u", parameter
);
86 zyn_oscillator_get_int(
88 unsigned int parameter
)
92 case ZYNADD_PARAMETER_ENUM_OSCILLATOR_BASE_FUNCTION
:
93 return oscillator_ptr
->base_function
;
94 case ZYNADD_PARAMETER_ENUM_OSCILLATOR_WAVESHAPE_TYPE
:
95 return oscillator_ptr
->waveshaping_function
;
96 case ZYNADD_PARAMETER_ENUM_OSCILLATOR_SPECTRUM_ADJUST_TYPE
:
97 return oscillator_ptr
->spectrum_adjust_type
;
100 LOG_ERROR("Unknown oscillator int/enum parameter %u", parameter
);
106 zyn_oscillator_set_int(
108 unsigned int parameter
,
113 case ZYNADD_PARAMETER_ENUM_OSCILLATOR_BASE_FUNCTION
:
114 assert(value
>= 0 && value
< ZYN_OSCILLATOR_BASE_FUNCTIONS_COUNT
);
115 oscillator_ptr
->base_function
= value
;
116 oscillator_ptr
->prepared
= false;
117 oscillator_ptr
->base_function_needs_prepare
= true;
119 case ZYNADD_PARAMETER_ENUM_OSCILLATOR_WAVESHAPE_TYPE
:
120 assert(value
>= 0 && value
< ZYN_OSCILLATOR_WAVESHAPE_TYPES_COUNT
);
121 oscillator_ptr
->waveshaping_function
= value
;
122 oscillator_ptr
->prepared
= false;
124 case ZYNADD_PARAMETER_ENUM_OSCILLATOR_SPECTRUM_ADJUST_TYPE
:
125 assert(value
>= 0 && value
< ZYN_OSCILLATOR_SPECTRUM_ADJUST_TYPES_COUNT
);
126 oscillator_ptr
->spectrum_adjust_type
= value
;
127 oscillator_ptr
->prepared
= false;
131 LOG_ERROR("Unknown oscillator int/enum parameter %u", parameter
);
136 zyn_oscillator_get_bool(
138 unsigned int parameter
)
144 LOG_ERROR("Unknown oscillator bool parameter %u", parameter
);
149 zyn_oscillator_set_bool(
151 unsigned int parameter
,
158 LOG_ERROR("Unknown oscillator bool parameter %u", parameter
);
162 #undef oscillator_ptr
165 zyn_addsynth_component_init_oscillator(
166 struct zyn_component_descriptor
* component_ptr
,
167 struct zyn_oscillator
* oscillator_ptr
)
169 ZYN_INIT_COMPONENT(component_ptr
, oscillator_ptr
, zyn_oscillator_
);