aboutsummaryrefslogtreecommitdiff
path: root/jit_api.h.in
blob: c799dfe6fb41a869f3aaad1b933883150c95b94b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
 * Copyright (c) 2019 Hanspeter Portner (dev@open-music-kontrollers.ch)
 *
 * This is free software: you can redistribute it and/or modify
 * it under the terms of the Artistic License 2.0 as published by
 * The Perl Foundation.
 *
 * This source is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * Artistic License 2.0 for more details.
 *
 * You should have received a copy of the Artistic License 2.0
 * along the source as a COPYING file. If not, obtain it from
 * http://www.perlfoundation.org/artistic_license_2_0.
 */

#ifndef _JIT_API_H
#define _JIT_API_H

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>

#define JIT_UNUSED   __attribute__((unused))
#define JIT_EXPORT   __attribute__((visibility("default")))

#define JIT_VERSION_MAJOR @MAJOR_VERSION@
#define JIT_VERSION_MINOR @MINOR_VERSION@
#define JIT_VERSION_MICRO @MICRO_VERSION@

#define JIT_MAX_VOICES 64

#if 0
#if ( \
		(@MAJOR_VERSION@ > JIT_VERSION_MAJOR) \
	) || ( \
		(@MAJOR_VERSION@ == JIT_VERSION_MAJOR) \
		&& (@MINOR_VERSION@ > JIT_VERSION_MINOR) \
	) || ( \
		(@MAJOR_VERSION@ == JIT_VERSION_MAJOR) \
		&& (@MINOR_VERSION@ == JIT_VERSION_MINOR) \
		&& (@MICRO_VERSION@ > JIT_VERSION_MICRO) \
	)
#	error "Your installed version of jit.lv2 is too old for this script"
#endif
#endif

typedef enum _jit_ev_type_t {
	JIT_EVENT_ON,
	JIT_EVENT_OFF,
	JIT_EVENT_SET
} jit_ev_type_t ;

typedef enum _jit_mask_t {
	JIT_MASK_NONE           = 0,

	JIT_MASK_SRATE          = (1 << 0),
	JIT_MASK_NCHANNELS      = (1 << 1),
	JIT_MASK_NCONTROLS      = (1 << 2),

	JIT_MASK_NSAMPLES       = (1 << 3),
	JIT_MASK_AUDIO_IN       = (1 << 4),
	JIT_MASK_AUDIO_OUT      = (1 << 5),
	JIT_MASK_CONTROL        = (1 << 6),

	JIT_MASK_ASSERT         = (1 << 7),
	JIT_MASK_VPRINTF        = (1 << 8),
	JIT_MASK_WORK_WRITE_REQ = (1 << 9),
	JIT_MASK_WORK_WRITE_ADV = (1 << 10),
	JIT_MASK_WORK_READ_REQ  = (1 << 11),
	JIT_MASK_WORK_READ_ADV  = (1 << 12),

	JIT_MASK_MAX            = (1 << 13)
} jit_mask_t ;

#define JIT_MASK_ALL (JIT_MASK_MAX - 1)

typedef struct _jit_assert_t jit_assert_t;
typedef struct _jit_print_t jit_print_t;
typedef struct _jit_work_write_request_t jit_work_write_request_t;
typedef struct _jit_work_write_advance_t jit_work_write_advance_t;
typedef struct _jit_work_read_request_t jit_work_read_request_t;
typedef struct _jit_work_read_advance_t jit_work_read_advance_t;

typedef struct _jit_t jit_t;
typedef struct _jit_ev_t jit_ev_t;
typedef struct _jit_desc_t jit_desc_t;

typedef void *(*jit_init_t)(jit_t *const jit);
typedef void  (*jit_deinit_t)(jit_t *const, void *data);
typedef void  (*jit_run_t)(jit_t *const jit, void *const data);
typedef void  (*jit_event_t)(jit_t *const jit, void *data,
	jit_ev_t const *const ev);
typedef void  (*jit_work_t)(jit_t *const jit, void *data);

typedef int   (*jit_print_func_t)(void *const data, const char *fmt);
typedef void  (*jit_assert_func_t)(void *const data);
typedef void *(*jit_work_write_request_func_t)(void *const data, size_t len);
typedef void  (*jit_work_write_advance_func_t)(void *const data, size_t len);
typedef void const*(*jit_work_read_request_func_t)(void *const data, size_t *len);
typedef void  (*jit_work_read_advance_func_t)(void *const data);

struct _jit_assert_t {
	void *const data;
	jit_assert_func_t func;
};

struct _jit_print_t {
	void *const data;
	jit_print_func_t func;
};

struct _jit_work_write_request_t {
	void *const data;
	jit_work_write_request_func_t func;
};

struct _jit_work_write_advance_t {
	void *const data;
	jit_work_write_advance_func_t func;
};

struct _jit_work_read_request_t {
	void *const data;
	jit_work_read_request_func_t func;
};

struct _jit_work_read_advance_t {
	void *const data;
	jit_work_read_advance_func_t func;
};

struct _jit_t {
	// public data
	uint32_t mask;

	uint32_t srate;
	uint32_t nchannels;
	uint32_t ncontrols;

	uint32_t nsamples;
	float const *const *const audio_in;
	float *const *const audio_out;
	float const *const control;

	// private data
	jit_assert_t _assert;
	jit_print_t _print;
	jit_work_write_request_t _work_write_request;
	jit_work_write_advance_t _work_write_advance;
	jit_work_read_request_t _work_read_request;
	jit_work_read_advance_t _work_read_advance;
};

struct _jit_ev_t {
	uint32_t etype;
	uint32_t index;
	float gain;
	float freq;
	float pressure;
	float timbre;
};

struct _jit_desc_t {
	jit_init_t init;
	jit_deinit_t deinit;
	jit_run_t run;
	jit_event_t event;
	jit_work_t work;
};

#endif // _JIT_API_H