Expose voice detune parameter of the lv2 plugin
[zyn.git] / addsynth_component_voice_globals.cpp
blob02ae6570affd0d020206946a7543be7f13636f95
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 *****************************************************************************/
21 #include <stdbool.h>
22 #include <assert.h>
24 #include "common.h"
25 #include "globals.h"
26 #include "addsynth.h"
27 #include "lfo_parameters.h"
28 #include "filter_parameters.h"
29 #include "envelope_parameters.h"
30 #include "resonance.h"
31 #include "fft.h"
32 #include "oscillator.h"
33 #include "portamento.h"
34 #include "addsynth_internal.h"
36 #define LOG_LEVEL LOG_LEVEL_ERROR
37 #include "log.h"
39 #define voice_params_ptr ((struct zyn_addnote_voice_parameters * )context)
41 float
42 zyn_component_voice_globals_get_float(
43 void * context,
44 unsigned int parameter)
46 switch (parameter)
50 LOG_ERROR("Unknown voice global float parameter %u", parameter);
51 assert(0);
52 return 0.0;
55 void
56 zyn_component_voice_globals_set_float(
57 void * context,
58 unsigned int parameter,
59 float value)
61 switch (parameter)
65 LOG_ERROR("Unknown voice global float parameter %u", parameter);
66 assert(0);
69 signed int
70 zyn_component_voice_globals_get_int(
71 void * context,
72 unsigned int parameter)
74 switch (parameter)
78 LOG_ERROR("Unknown voice global int/enum parameter %u", parameter);
79 assert(0);
80 return 0;
83 void
84 zyn_component_voice_globals_set_int(
85 void * context,
86 unsigned int parameter,
87 signed int value)
89 switch (parameter)
93 LOG_ERROR("Unknown voice global int/enum parameter %u", parameter);
94 assert(0);
97 bool
98 zyn_component_voice_globals_get_bool(
99 void * context,
100 unsigned int parameter)
102 switch (parameter)
104 case ZYNADD_PARAMETER_BOOL_ENABLED:
105 return voice_params_ptr->enabled;
106 case ZYNADD_PARAMETER_BOOL_RESONANCE:
107 return voice_params_ptr->resonance;
108 case ZYNADD_PARAMETER_BOOL_WHITE_NOISE:
109 return voice_params_ptr->white_noise;
112 LOG_ERROR("Unknown voice global bool parameter %u", parameter);
113 assert(0);
114 return false;
117 void
118 zyn_component_voice_globals_set_bool(
119 void * context,
120 unsigned int parameter,
121 bool value)
123 switch (parameter)
125 case ZYNADD_PARAMETER_BOOL_ENABLED:
126 LOG_DEBUG("voice enabled -> %s (%p)", value ? "on" : "off", voice_params_ptr);
127 voice_params_ptr->enabled = value;
128 return;
129 case ZYNADD_PARAMETER_BOOL_RESONANCE:
130 LOG_DEBUG("voice resonance -> %s (%p)", value ? "on" : "off", voice_params_ptr);
131 voice_params_ptr->resonance = value;
132 return;
133 case ZYNADD_PARAMETER_BOOL_WHITE_NOISE:
134 LOG_DEBUG("voice white noise -> %s (%p)", value ? "on" : "off", voice_params_ptr);
135 voice_params_ptr->white_noise = value;
136 return;
139 LOG_ERROR("Unknown voice global bool parameter %u", parameter);
140 assert(0);
143 #undef voice_params_ptr
145 void
146 zyn_addsynth_component_init_voice_globals(
147 struct zyn_component_descriptor * component_ptr,
148 struct zyn_addnote_voice_parameters * voice_params_ptr)
150 //LOG_DEBUG("voice globals init (%p, %p)", component_ptr, voice_params_ptr);
151 ZYN_INIT_COMPONENT(component_ptr, voice_params_ptr, zyn_component_voice_globals_);