use the same licensing statements in all the headers
[ng-jackspa.git] / control.h
blob2ca793088283a890f511683112a3a21dc24b4e65
1 /* control.h - API for interfaces to the controls of a jackspa plugin instance
2 * Copyright © 2013 Géraud Meyer <graud@gmx.com>
4 * This file is part of ng-jackspa.
6 * ng-jackspa is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License version 2 as published by the
8 * Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
15 * You should have received a copy of the GNU General Public License along
16 * with ng-jackspa. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef CONTROL_H
20 #define CONTROL_H
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
25 #include <glib.h>
26 #include <ladspa.h>
27 #include "jackspa.h"
29 enum ctype {
30 JACKSPA_FLOAT,
31 JACKSPA_INT,
32 JACKSPA_TOGGLE
35 typedef struct {
36 unsigned long port;
37 unsigned long ctrl;
38 const char *name;
39 const LADSPA_PortDescriptor *desc;
40 const LADSPA_PortRangeHint *hint;
41 /* value in the plugin */
42 LADSPA_Data *val;
43 /* values selected in the interface */
44 LADSPA_Data sel;
45 /* value range */
46 LADSPA_Data min;
47 LADSPA_Data max;
48 LADSPA_Data *def;
49 enum ctype type;
50 struct { LADSPA_Data fine; LADSPA_Data coarse; } inc;
51 } control_t;
54 /* Return a value close to val that is valid for the given control */
55 /* val is supposed to be inside the min/max of control */
56 LADSPA_Data control_rounding(const control_t *control, LADSPA_Data val);
58 /* Exchange the selected and the active values */
59 void control_exchange(control_t *control);
61 /* Interpret the given command to obtain a value depending of the control
62 * parameters.
63 * Return 0 if the value was set, 1 if the command was to skip, -1 otherwise
64 * (invalid command or error) */
65 int control_set_value(LADSPA_Data *dest, char *cmd, control_t *control);
68 /* Initial config (command line switches) */
69 extern const GOptionEntry control_entries[];
71 /* Compute the type, the bounds, the default value and the increments */
72 int control_init(control_t *control, state_t *state, unsigned long port,
73 unsigned long ctrl);
75 void control_fini(control_t *control);
78 /* Array of pointers */
79 /* Using an array type would be invalid C++ */
80 typedef control_t **controls_t;
82 /* Allocate an array *controls and initialise it with allocated controls (and
83 * set *count to the number of controls) */
84 int control_buildall(unsigned long *count, controls_t *controls, state_t *state);
86 /* Deallocate the array *controls */
87 void control_cleanupall(unsigned long count, controls_t *controls);
89 #ifdef __cplusplus
90 } /* extern "C" */
91 #endif
92 #endif