Add some foaf and doap info to zynadd.ttl
[zyn.git] / oscillator_access.c
blob0e717aeeeec4770fd9181ac4513d7176f67e6d5e
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * Copyright (C) 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 *****************************************************************************/
21 #include <stdbool.h>
22 #include <assert.h>
24 #include "globals.h"
25 #include "fft.h"
26 #include "resonance.h"
27 #include "oscillator.h"
28 #include "addsynth.h"
29 #include "portamento.h"
30 #include "addsynth_component.h"
31 #include "log.h"
33 #define oscillator_ptr ((struct zyn_oscillator * )context)
35 float
36 zyn_oscillator_get_float(
37 void * context,
38 unsigned int parameter)
40 switch (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);
51 assert(0);
52 return 0.0;
55 void
56 zyn_oscillator_set_float(
57 void * context,
58 unsigned int parameter,
59 float value)
61 switch (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;
67 return;
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;
73 return;
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;
78 return;
81 LOG_ERROR("Unknown oscillator float parameter %u", parameter);
82 assert(0);
85 signed int
86 zyn_oscillator_get_int(
87 void * context,
88 unsigned int parameter)
90 switch (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);
101 assert(0);
102 return 0;
105 void
106 zyn_oscillator_set_int(
107 void * context,
108 unsigned int parameter,
109 signed int value)
111 switch (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;
118 return;
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;
123 return;
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;
128 return;
131 LOG_ERROR("Unknown oscillator int/enum parameter %u", parameter);
132 assert(0);
135 bool
136 zyn_oscillator_get_bool(
137 void * context,
138 unsigned int parameter)
140 switch (parameter)
144 LOG_ERROR("Unknown oscillator bool parameter %u", parameter);
145 assert(0);
148 void
149 zyn_oscillator_set_bool(
150 void * context,
151 unsigned int parameter,
152 bool value)
154 switch (parameter)
158 LOG_ERROR("Unknown oscillator bool parameter %u", parameter);
159 assert(0);
162 #undef oscillator_ptr
164 void
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_);