control: define and export GOption related entities
[ng-jackspa.git] / control.h
blobb8037ddf8039d9f9426366e6808683520faac15d
1 /* control.h - API for interfaces to the controls of a jackspa plugin instance
2 * Copyright © 2013 Géraud Meyer <graud@gmx.com>
4 * control.h 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
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program. 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 const char *name;
38 const LADSPA_PortDescriptor *desc;
39 const LADSPA_PortRangeHint *hint;
40 /* value in the plugin */
41 LADSPA_Data *val;
42 /* values selected in the interface */
43 LADSPA_Data sel;
44 /* value range */
45 LADSPA_Data min;
46 LADSPA_Data max;
47 LADSPA_Data *def;
48 enum ctype type;
49 struct { LADSPA_Data fine; LADSPA_Data coarse; } inc;
50 } control_t;
53 /* Return a value close to val that is valid for the given control */
54 /* val is supposed to be inside the min/max of control */
55 LADSPA_Data control_rounding(const control_t *control, LADSPA_Data val);
57 /* Exchange the selected and the active values */
58 void control_exchange(control_t *control);
61 /* Initial config (command line switches) */
62 extern const GOptionEntry control_entries[];
64 /* Compute the type, the bounds, the default value and the increments */
65 int control_init(control_t *control, state_t *state, unsigned long port);
68 /* Array of pointers */
69 /* Using an array type would be invalid C++ */
70 typedef control_t **controls_t;
72 /* Allocate an array *controls and initialise it with allocated controls (and
73 * set *count to the number of controls) */
74 int control_buildall(unsigned long *count, controls_t *controls, state_t *state);
76 /* Deallocate the array *controls */
77 void control_cleanupall(unsigned long count, controls_t *controls);
79 #ifdef __cplusplus
80 } /* extern "C" */
81 #endif
82 #endif