JackUtils 0.5
Provides simplified Jack API for clients :)
Loading...
Searching...
No Matches
ju_vars.h
Go to the documentation of this file.
1/* Jack Utils Variables API
2 * Copyright (C) UtoECat 2022. All rights Reserved!
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
23#pragma once
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <unistd.h>
29#include <jackgui.h>
30
49typedef struct ju_var_s ju_var_t;
50
66 void (*render) (jg_ctx_t* gui, ju_var_t* v);
79 int (*parse ) (FILE* f, ju_var_t* v);
93 int (*write ) (FILE* f, ju_var_t* v);
98};
99
107struct ju_var_s {
108 const struct ju_varclass* _vp;
109 union {
110 void* p;
111 int i;
112 ju_sample_t f;
113 } data[5];
117};
118
123JU_API ju_var_t ju_var_nil();
124
132JU_API ju_var_t ju_var_float_rw(ju_cstr_t name, float* val, float min, float max);
133
141JU_API ju_var_t ju_var_float_ro(ju_cstr_t name, float* val);
142
153JU_API void ju_vars_lock();
154
158JU_API void ju_vars_unlock();
159
166JU_API int ju_vars_save(ju_cstr_t filename, ju_var_t* vararr);
167
174JU_API int ju_vars_load(ju_cstr_t filename, ju_var_t* vararr);
175
183JU_API int ju_vars_draw(jg_ctx_t* u, ju_var_t* vararr, int eh);
184
const char * ju_cstr_t
Informative type definition.
Definition: jackutils.h:64
jack_default_audio_sample_t ju_sample_t
Sample type.
Definition: jackutils.h:68
JU_API void ju_vars_unlock()
See ju_vars_lock()! It is important!
Definition: jackutilsvars.c:46
JU_API ju_var_t ju_var_float_rw(ju_cstr_t name, float *val, float min, float max)
Creates modifyable float variable :)
Definition: jackutilsvars.c:158
JU_API int ju_vars_draw(jg_ctx_t *u, ju_var_t *vararr, int eh)
Renders (and probably processes) your variables.
Definition: jackwidgets.c:231
JU_API ju_var_t ju_var_float_ro(ju_cstr_t name, float *val)
Creates readonly float variable :) It will not be saved/parsed and changed anyhow!
Definition: jackutilsvars.c:184
JU_API ju_var_t ju_var_nil()
Creates ZERO variable to show end of variables array.
Definition: jackutilsvars.c:23
JU_API int ju_vars_save(ju_cstr_t filename, ju_var_t *vararr)
Saves your variables into the file.
Definition: jackutilsvars.c:50
JU_API int ju_vars_load(ju_cstr_t filename, ju_var_t *vararr)
Loads your variables from the file.
Definition: jackutilsvars.c:93
JU_API void ju_vars_lock()
A common way to protect your variables in multithread world :) ONLY in space between calling ju_vars_...
Definition: jackutilsvars.c:37
GUI and window creation extension for JackUtils :)
Variable shared structure.
Definition: ju_vars.h:107
const struct ju_varclass * _vp
pointer to the class
Definition: ju_vars.h:108
ju_cstr_t name
more than enough...
Definition: ju_vars.h:114
class of variable.
Definition: ju_vars.h:54
float widthratio
Specifies ratio width/height (optional).
Definition: ju_vars.h:97
int(* parse)(FILE *f, ju_var_t *v)
Parses (reads) variable from a file.
Definition: ju_vars.h:79
void(* render)(jg_ctx_t *gui, ju_var_t *v)
function (method) to render this variable, and maybe even process and change it with the user input :...
Definition: ju_vars.h:66
int(* write)(FILE *f, ju_var_t *v)
Serializes (writes) variable to the file.
Definition: ju_vars.h:93