Add some foaf and doap info to zynadd.ttl
[zyn.git] / addsynth_component_amp_globals.cpp
blob9e86a4f4ef87a42007ab7893a45d42ae40d94341
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 *****************************************************************************/
21 #include <stdbool.h>
22 #include <assert.h>
23 #include <math.h>
25 #include "common.h"
26 #include "globals.h"
27 #include "addsynth.h"
28 #include "lfo_parameters.h"
29 #include "lfo.h"
30 #include "filter_parameters.h"
31 #include "filter_base.h"
32 #include "filter_common.h"
33 #include "analog_filter.h"
34 #include "sv_filter.h"
35 #include "formant_filter.h"
36 #include "filter.h"
37 #include "envelope_parameters.h"
38 #include "envelope.h"
39 #include "addnote.h"
40 #include "resonance.h"
41 #include "fft.h"
42 #include "oscillator.h"
43 #include "portamento.h"
44 #include "addsynth_internal.h"
45 #include "log.h"
47 #define zyn_addsynth_ptr ((struct zyn_addsynth *)context)
49 float
50 zyn_component_amp_globals_get_float(
51 void * context,
52 unsigned int parameter)
54 switch (parameter)
56 case ZYNADD_PARAMETER_FLOAT_PANORAMA:
57 return zyn_addsynth_ptr->panorama;
58 case ZYNADD_PARAMETER_FLOAT_VOLUME:
59 return percent_from_0_127(zyn_addsynth_ptr->GlobalPar.PVolume);
60 case ZYNADD_PARAMETER_FLOAT_VELOCITY_SENSING:
61 return percent_from_0_127(zyn_addsynth_ptr->GlobalPar.PAmpVelocityScaleFunction);
62 case ZYNADD_PARAMETER_FLOAT_PUNCH_STRENGTH:
63 return percent_from_0_127(zyn_addsynth_ptr->GlobalPar.PPunchStrength);
64 case ZYNADD_PARAMETER_FLOAT_PUNCH_TIME:
65 return percent_from_0_127(zyn_addsynth_ptr->GlobalPar.PPunchTime);
66 case ZYNADD_PARAMETER_FLOAT_PUNCH_STRETCH:
67 return percent_from_0_127(zyn_addsynth_ptr->GlobalPar.PPunchStretch);
68 case ZYNADD_PARAMETER_FLOAT_PUNCH_VELOCITY_SENSING:
69 return percent_from_0_127(zyn_addsynth_ptr->GlobalPar.PPunchVelocitySensing);
70 case ZYNADD_PARAMETER_FLOAT_PITCH_BEND_RANGE:
71 return zyn_addsynth_ptr->pitch_bend_range;
72 case ZYNADD_PARAMETER_FLOAT_PITCH_BEND:
73 return zyn_addsynth_ptr->pitch_bend;
74 default:
75 LOG_ERROR("Unknown float amplitude global parameter %u", parameter);
76 assert(0);
80 void
81 zyn_component_amp_globals_set_float(
82 void * context,
83 unsigned int parameter,
84 float value)
86 switch (parameter)
88 case ZYNADD_PARAMETER_FLOAT_PANORAMA:
89 zyn_addsynth_ptr->panorama = value;
90 return;
91 case ZYNADD_PARAMETER_FLOAT_VOLUME:
92 zyn_addsynth_ptr->GlobalPar.PVolume = percent_to_0_127(value);
93 return;
94 case ZYNADD_PARAMETER_FLOAT_VELOCITY_SENSING:
95 zyn_addsynth_ptr->GlobalPar.PAmpVelocityScaleFunction = percent_to_0_127(value);
96 return;
97 case ZYNADD_PARAMETER_FLOAT_PUNCH_STRENGTH:
98 zyn_addsynth_ptr->GlobalPar.PPunchStrength = percent_to_0_127(value);
99 return;
100 case ZYNADD_PARAMETER_FLOAT_PUNCH_TIME:
101 zyn_addsynth_ptr->GlobalPar.PPunchTime = percent_to_0_127(value);
102 return;
103 case ZYNADD_PARAMETER_FLOAT_PUNCH_STRETCH:
104 zyn_addsynth_ptr->GlobalPar.PPunchStretch = percent_to_0_127(value);
105 return;
106 case ZYNADD_PARAMETER_FLOAT_PUNCH_VELOCITY_SENSING:
107 zyn_addsynth_ptr->GlobalPar.PPunchVelocitySensing = percent_to_0_127(value);
108 return;
109 case ZYNADD_PARAMETER_FLOAT_PITCH_BEND_RANGE:
110 zyn_addsynth_ptr->pitch_bend_range = value;
111 ZYN_UPDATE_PITCH_BEND(zyn_addsynth_ptr);
112 return;
113 case ZYNADD_PARAMETER_FLOAT_PITCH_BEND:
114 zyn_addsynth_ptr->pitch_bend = value;
115 ZYN_UPDATE_PITCH_BEND(zyn_addsynth_ptr);
116 return;
117 default:
118 LOG_ERROR("Unknown float amplitude global parameter %u", parameter);
119 assert(0);
123 signed int
124 zyn_component_amp_globals_get_int(
125 void * context,
126 unsigned int parameter)
128 assert(0);
129 return 0;
132 void
133 zyn_component_amp_globals_set_int(
134 void * context,
135 unsigned int parameter,
136 signed int value)
138 assert(0);
141 bool
142 zyn_component_amp_globals_get_bool(
143 void * context,
144 unsigned int parameter)
146 switch (parameter)
148 case ZYNADD_PARAMETER_BOOL_RANDOM_PANORAMA:
149 return zyn_addsynth_ptr->random_panorama;
150 case ZYNADD_PARAMETER_BOOL_STEREO:
151 return zyn_addsynth_ptr->stereo;
152 case ZYNADD_PARAMETER_BOOL_RANDOM_GROUPING:
153 return zyn_addsynth_ptr->random_grouping;
154 default:
155 LOG_ERROR("Unknown bool amplitude global parameter %u", parameter);
156 assert(0);
160 void
161 zyn_component_amp_globals_set_bool(
162 void * context,
163 unsigned int parameter,
164 bool value)
166 switch (parameter)
168 case ZYNADD_PARAMETER_BOOL_RANDOM_PANORAMA:
169 zyn_addsynth_ptr->random_panorama = value;
170 return;
171 case ZYNADD_PARAMETER_BOOL_STEREO:
172 zyn_addsynth_ptr->stereo = value;
173 return;
174 case ZYNADD_PARAMETER_BOOL_RANDOM_GROUPING:
175 zyn_addsynth_ptr->random_grouping = value;
176 return;
177 default:
178 LOG_ERROR("Unknown bool amplitude global parameter %u", parameter);
179 assert(0);
183 #undef zyn_addsynth_ptr
185 void
186 zyn_addsynth_component_init_amp_globals(
187 struct zyn_component_descriptor * component_ptr,
188 struct zyn_addsynth * zyn_addsynth_ptr)
190 ZYN_INIT_COMPONENT(component_ptr, zyn_addsynth_ptr, zyn_component_amp_globals_);