annotate CloneChannel/plugins/common/gen_dsp/genlib_common.h @ 14:49dd434149cd

README.md immposiblerush
author prymula <prymula76@outlook.com>
date Sat, 10 Feb 2024 20:40:34 +0100
parents 24d60bdea349
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
1 /*******************************************************************************************************************
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
2 Copyright (c) 2012 Cycling '74
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
3
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
4 Permission is hereby granted, free of charge, to any person obtaining a copy of this software
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
5 and associated documentation files (the "Software"), to deal in the Software without restriction,
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
6 including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
7 and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
8 subject to the following conditions:
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
9
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
10 The above copyright notice and this permission notice shall be included in all copies
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
11 or substantial portions of the Software.
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
12
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
14 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
15 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
16 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
17 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
18 *******************************************************************************************************************/
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
19
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
20
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
21 #ifndef GENLIB_COMMON_H
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
22 #define GENLIB_COMMON_H 1
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
23
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
24 //////////// genlib_common.h ////////////
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
25 // common data structure header file -- this is the stuff required by the
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
26 // common code and accessed by the export and max code
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
27
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
28 #define DSP_GEN_MAX_SIGNALS 16
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
29
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
30 typedef float t_sample;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
31 typedef float t_param;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
32 typedef char *t_ptr;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
33
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
34 typedef long t_genlib_err;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
35 typedef enum {
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
36 GENLIB_ERR_NONE = 0, ///< No error
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
37 GENLIB_ERR_GENERIC = -1, ///< Generic error
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
38 GENLIB_ERR_INVALID_PTR = -2, ///< Invalid Pointer
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
39 GENLIB_ERR_DUPLICATE = -3, ///< Duplicate
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
40 GENLIB_ERR_OUT_OF_MEM = -4, ///< Out of memory
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
41
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
42 GENLIB_ERR_LOOP_OVERFLOW = 100, // too many iterations of loops in perform()
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
43 GENLIB_ERR_NULL_BUFFER = 101 // missing signal data in perform()
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
44
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
45 } e_genlib_errorcodes;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
46
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
47 typedef enum {
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
48 GENLIB_PARAMTYPE_FLOAT = 0,
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
49 GENLIB_PARAMTYPE_SYM = 1
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
50 } e_genlib_paramtypes;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
51
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
52 struct ParamInfo
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
53 {
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
54 t_param defaultvalue;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
55 void * defaultref;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
56 char hasinputminmax;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
57 char hasminmax;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
58 t_param inputmin, inputmax;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
59 t_param outputmin, outputmax;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
60 const char *name;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
61 const char *units;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
62 int paramtype; // 0 -> float64, 1 -> symbol (table name)
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
63 t_param exp; // future, for scaling
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
64 };
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
65
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
66 struct CommonState
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
67 {
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
68 t_sample sr;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
69 int vs;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
70 int numins;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
71 int numouts;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
72 const char **inputnames;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
73 const char **outputnames;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
74 int numparams;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
75 ParamInfo *params;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
76
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
77 void * parammap; // implementation-dependent
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
78 void * api; // implementation-dependent
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
79 };
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
80
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
81 // opaque interface to float32 buffer:
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
82 typedef struct _genlib_buffer t_genlib_buffer;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
83 typedef struct {
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
84 char b_name[256]; ///< name of the buffer
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
85 float *b_samples; ///< stored with interleaved channels if multi-channel
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
86 long b_frames; ///< number of sample frames (each one is sizeof(float) * b_nchans bytes)
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
87 long b_nchans; ///< number of channels
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
88 long b_size; ///< size of buffer in floats
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
89 float b_sr; ///< sampling rate of the buffer
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
90 long b_modtime; ///< last modified time ("dirty" method)
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
91 long b_rfu[57]; ///< reserved for future use
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
92 } t_genlib_buffer_info;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
93
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
94 // opaque interface to float64 buffer:
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
95 typedef struct _genlib_data t_genlib_data;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
96 typedef struct {
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
97 int dim, channels;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
98 t_sample * data;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
99 } t_genlib_data_info;
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
100
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
101 typedef void (*setparameter_method) (CommonState *, long, t_param, void *);
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
102 typedef void (*getparameter_method) (CommonState *, long, t_param *);
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
103
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
104 #endif // GENLIB_COMMON_H
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
105
24d60bdea349 ClonneChannel
prymula <prymula76@outlook.com>
parents:
diff changeset
106