Expose voice detune parameter of the lv2 plugin
[zyn.git] / addsynth_component_amp_globals.cpp
blob4fb41a66ea0213a622d81930ab2c23aef5a1e695
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * Copyright (C) 2006,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 *****************************************************************************/
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 "filter_parameters.h"
30 #include "envelope_parameters.h"
31 #include "resonance.h"
32 #include "fft.h"
33 #include "oscillator.h"
34 #include "portamento.h"
35 #include "addsynth_internal.h"
36 #include "log.h"
38 #define zyn_addsynth_ptr ((struct zyn_addsynth *)context)
40 float
41 zyn_component_amp_globals_get_float(
42 void * context,
43 unsigned int parameter)
45 switch (parameter)
47 case ZYNADD_PARAMETER_FLOAT_PANORAMA:
48 return zyn_addsynth_ptr->panorama;
49 case ZYNADD_PARAMETER_FLOAT_VOLUME:
50 return percent_from_0_127(zyn_addsynth_ptr->PVolume);
51 case ZYNADD_PARAMETER_FLOAT_VELOCITY_SENSING:
52 return percent_from_0_127(zyn_addsynth_ptr->PAmpVelocityScaleFunction);
53 case ZYNADD_PARAMETER_FLOAT_PUNCH_STRENGTH:
54 return percent_from_0_127(zyn_addsynth_ptr->PPunchStrength);
55 case ZYNADD_PARAMETER_FLOAT_PUNCH_TIME:
56 return percent_from_0_127(zyn_addsynth_ptr->PPunchTime);
57 case ZYNADD_PARAMETER_FLOAT_PUNCH_STRETCH:
58 return percent_from_0_127(zyn_addsynth_ptr->PPunchStretch);
59 case ZYNADD_PARAMETER_FLOAT_PUNCH_VELOCITY_SENSING:
60 return percent_from_0_127(zyn_addsynth_ptr->PPunchVelocitySensing);
61 case ZYNADD_PARAMETER_FLOAT_PITCH_BEND_RANGE:
62 return zyn_addsynth_ptr->pitch_bend_range;
63 case ZYNADD_PARAMETER_FLOAT_PITCH_BEND:
64 return zyn_addsynth_ptr->pitch_bend;
65 default:
66 LOG_ERROR("Unknown float amplitude global parameter %u", parameter);
67 assert(0);
71 void
72 zyn_component_amp_globals_set_float(
73 void * context,
74 unsigned int parameter,
75 float value)
77 switch (parameter)
79 case ZYNADD_PARAMETER_FLOAT_PANORAMA:
80 zyn_addsynth_ptr->panorama = value;
81 return;
82 case ZYNADD_PARAMETER_FLOAT_VOLUME:
83 zyn_addsynth_ptr->PVolume = percent_to_0_127(value);
84 return;
85 case ZYNADD_PARAMETER_FLOAT_VELOCITY_SENSING:
86 zyn_addsynth_ptr->PAmpVelocityScaleFunction = percent_to_0_127(value);
87 return;
88 case ZYNADD_PARAMETER_FLOAT_PUNCH_STRENGTH:
89 zyn_addsynth_ptr->PPunchStrength = percent_to_0_127(value);
90 return;
91 case ZYNADD_PARAMETER_FLOAT_PUNCH_TIME:
92 zyn_addsynth_ptr->PPunchTime = percent_to_0_127(value);
93 return;
94 case ZYNADD_PARAMETER_FLOAT_PUNCH_STRETCH:
95 zyn_addsynth_ptr->PPunchStretch = percent_to_0_127(value);
96 return;
97 case ZYNADD_PARAMETER_FLOAT_PUNCH_VELOCITY_SENSING:
98 zyn_addsynth_ptr->PPunchVelocitySensing = percent_to_0_127(value);
99 return;
100 case ZYNADD_PARAMETER_FLOAT_PITCH_BEND_RANGE:
101 zyn_addsynth_ptr->pitch_bend_range = value;
102 ZYN_UPDATE_PITCH_BEND(zyn_addsynth_ptr);
103 return;
104 case ZYNADD_PARAMETER_FLOAT_PITCH_BEND:
105 zyn_addsynth_ptr->pitch_bend = value;
106 ZYN_UPDATE_PITCH_BEND(zyn_addsynth_ptr);
107 return;
108 default:
109 LOG_ERROR("Unknown float amplitude global parameter %u", parameter);
110 assert(0);
114 signed int
115 zyn_component_amp_globals_get_int(
116 void * context,
117 unsigned int parameter)
119 assert(0);
120 return 0;
123 void
124 zyn_component_amp_globals_set_int(
125 void * context,
126 unsigned int parameter,
127 signed int value)
129 assert(0);
132 bool
133 zyn_component_amp_globals_get_bool(
134 void * context,
135 unsigned int parameter)
137 switch (parameter)
139 case ZYNADD_PARAMETER_BOOL_RANDOM_PANORAMA:
140 return zyn_addsynth_ptr->random_panorama;
141 case ZYNADD_PARAMETER_BOOL_STEREO:
142 return zyn_addsynth_ptr->stereo;
143 case ZYNADD_PARAMETER_BOOL_RANDOM_GROUPING:
144 return zyn_addsynth_ptr->random_grouping;
145 default:
146 LOG_ERROR("Unknown bool amplitude global parameter %u", parameter);
147 assert(0);
151 void
152 zyn_component_amp_globals_set_bool(
153 void * context,
154 unsigned int parameter,
155 bool value)
157 switch (parameter)
159 case ZYNADD_PARAMETER_BOOL_RANDOM_PANORAMA:
160 zyn_addsynth_ptr->random_panorama = value;
161 return;
162 case ZYNADD_PARAMETER_BOOL_STEREO:
163 zyn_addsynth_ptr->stereo = value;
164 return;
165 case ZYNADD_PARAMETER_BOOL_RANDOM_GROUPING:
166 zyn_addsynth_ptr->random_grouping = value;
167 return;
168 default:
169 LOG_ERROR("Unknown bool amplitude global parameter %u", parameter);
170 assert(0);
174 #undef zyn_addsynth_ptr
176 void
177 zyn_addsynth_component_init_amp_globals(
178 struct zyn_component_descriptor * component_ptr,
179 struct zyn_addsynth * zyn_addsynth_ptr)
181 ZYN_INIT_COMPONENT(component_ptr, zyn_addsynth_ptr, zyn_component_amp_globals_);