Fix use of uninitialized struct member. (caused crash)
[zyn.git] / addsynth_component_voice_globals.cpp
blob26d4cffb40089db200846e08ea5bfa4baee1ff54
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_RESONANCE:
105 return voice_params_ptr->resonance;
106 case ZYNADD_PARAMETER_BOOL_WHITE_NOISE:
107 return voice_params_ptr->white_noise;
110 LOG_ERROR("Unknown voice global bool parameter %u", parameter);
111 assert(0);
112 return false;
115 void
116 zyn_component_voice_globals_set_bool(
117 void * context,
118 unsigned int parameter,
119 bool value)
121 switch (parameter)
123 case ZYNADD_PARAMETER_BOOL_RESONANCE:
124 LOG_DEBUG("voice resonance -> %s (%p)", value ? "on" : "off", voice_params_ptr);
125 voice_params_ptr->resonance = value;
126 return;
127 case ZYNADD_PARAMETER_BOOL_WHITE_NOISE:
128 LOG_DEBUG("voice white noise -> %s (%p)", value ? "on" : "off", voice_params_ptr);
129 voice_params_ptr->white_noise = value;
130 return;
133 LOG_ERROR("Unknown voice global bool parameter %u", parameter);
134 assert(0);
137 #undef voice_params_ptr
139 void
140 zyn_addsynth_component_init_voice_globals(
141 struct zyn_component_descriptor * component_ptr,
142 struct zyn_addnote_voice_parameters * voice_params_ptr)
144 //LOG_DEBUG("voice globals init (%p, %p)", component_ptr, voice_params_ptr);
145 ZYN_INIT_COMPONENT(component_ptr, voice_params_ptr, zyn_component_voice_globals_);