Update copyright years
[zyn.git] / zynadd_dynparam_value_changed_callbacks.c
blob3bab6e1590c45dc008c29e0e92560507e14f7d3a
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 <lv2.h>
24 #include "common.h"
25 #include "list.h"
26 #include "addsynth.h"
27 #include "lv2dynparam/lv2dynparam.h"
28 #include "lv2dynparam/plugin.h"
29 #include "zynadd_internal.h"
30 #include "zynadd_dynparam_value_changed_callbacks.h"
32 #define LOG_LEVEL LOG_LEVEL_ERROR
33 #include "log.h"
35 #define parameter_ptr ((struct zynadd_parameter *)context)
37 bool
38 zynadd_bool_parameter_changed(
39 void * context,
40 bool value)
42 bool current_value;
44 LOG_DEBUG("bool parameter \"%s\" changed to \"%s\"", parameter_ptr->name_ptr, value ? "true" : "false");
46 if (parameter_ptr->scope == LV2DYNPARAM_PARAMETER_SCOPE_TYPE_HIDE_OTHER ||
47 parameter_ptr->scope == LV2DYNPARAM_PARAMETER_SCOPE_TYPE_SHOW_OTHER)
49 current_value = zyn_addsynth_get_bool_parameter(
50 parameter_ptr->addsynth_component,
51 parameter_ptr->addsynth_parameter);
53 if ((current_value && value) ||
54 (!current_value && !value))
56 /* value not changed */
57 return true;
60 if ((parameter_ptr->scope == LV2DYNPARAM_PARAMETER_SCOPE_TYPE_HIDE_OTHER && value) ||
61 (parameter_ptr->scope == LV2DYNPARAM_PARAMETER_SCOPE_TYPE_SHOW_OTHER && !value))
63 LOG_DEBUG("Removing parameter \"%s\" with semi scope", parameter_ptr->other_parameter->name_ptr);
65 /* enabling randomize -> remove panorama parameter */
66 if (!lv2dynparam_plugin_param_remove(
67 parameter_ptr->synth_ptr->dynparams,
68 parameter_ptr->other_parameter->lv2parameter))
70 return false;
73 else
75 LOG_DEBUG("Appearing parameter \"%s\" with semi scope", parameter_ptr->other_parameter->name_ptr);
77 if (!zynadd_appear_parameter(parameter_ptr->synth_ptr, parameter_ptr->other_parameter))
79 return false;
84 zyn_addsynth_set_bool_parameter(
85 parameter_ptr->addsynth_component,
86 parameter_ptr->addsynth_parameter,
87 value);
89 return true;
92 bool
93 zynadd_float_parameter_changed(
94 void * context,
95 float value)
97 zyn_addsynth_set_float_parameter(
98 parameter_ptr->addsynth_component,
99 parameter_ptr->addsynth_parameter,
100 value);
102 return true;
105 bool
106 zynadd_int_parameter_changed(
107 void * context,
108 signed int value)
110 // LOG_ERROR("int parameter changed to value %d", value);
112 zyn_addsynth_set_int_parameter(
113 parameter_ptr->addsynth_component,
114 parameter_ptr->addsynth_parameter,
115 value);
117 return true;
120 bool
121 zynadd_enum_parameter_changed(
122 void * context,
123 const char * value,
124 unsigned int value_index)
126 zyn_addsynth_set_int_parameter(
127 parameter_ptr->addsynth_component,
128 parameter_ptr->addsynth_parameter,
129 value_index);
131 return true;