genlib_common.h (4677B)
1 /******************************************************************************************************************* 2 Cycling '74 License for Max-Generated Code for Export 3 Copyright (c) 2016 Cycling '74 4 The code that Max generates automatically and that end users are capable of exporting and using, and any 5 associated documentation files (the “Software”) is a work of authorship for which Cycling '74 is the author 6 and owner for copyright purposes. A license is hereby granted, free of charge, to any person obtaining a 7 copy of the Software (“Licensee”) to use, copy, modify, merge, publish, and distribute copies of the Software, 8 and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 The Software is licensed to Licensee only for non-commercial use. Users who wish to make commercial use of the 10 Software must contact the copyright owner to determine if a license for commercial use is available, and the 11 terms and conditions for same, which may include fees or royalties. For commercial use, please send inquiries 12 to licensing@cycling74.com. The determination of whether a use is commercial use or non-commercial use is based 13 upon the use, not the user. The Software may be used by individuals, institutions, governments, corporations, or 14 other business whether for-profit or non-profit so long as the use itself is not a commercialization of the 15 materials or a use that generates or is intended to generate income, revenue, sales or profit. 16 The above copyright notice and this license shall be included in all copies or substantial portions of the Software. 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 18 THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 20 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 DEALINGS IN THE SOFTWARE. 22 *******************************************************************************************************************/ 23 24 #ifndef GENLIB_COMMON_H 25 #define GENLIB_COMMON_H 1 26 27 #include "genlib_platform.h" 28 29 //////////// genlib_common.h //////////// 30 // common data structure header file -- this is the stuff required by the 31 // common code and accessed by the export and max code 32 33 #define DSP_GEN_MAX_SIGNALS 128 34 35 #ifdef GENLIB_USE_FLOAT32 36 typedef float t_sample; 37 typedef float t_param; 38 #else 39 typedef double t_sample; 40 typedef double t_param; 41 #endif 42 typedef char *t_ptr; 43 44 typedef long t_genlib_err; 45 typedef enum { 46 GENLIB_ERR_NONE = 0, ///< No error 47 GENLIB_ERR_GENERIC = -1, ///< Generic error 48 GENLIB_ERR_INVALID_PTR = -2, ///< Invalid Pointer 49 GENLIB_ERR_DUPLICATE = -3, ///< Duplicate 50 GENLIB_ERR_OUT_OF_MEM = -4, ///< Out of memory 51 52 GENLIB_ERR_LOOP_OVERFLOW = 100, // too many iterations of loops in perform() 53 GENLIB_ERR_NULL_BUFFER = 101 // missing signal data in perform() 54 55 } e_genlib_errorcodes; 56 57 typedef enum { 58 GENLIB_PARAMTYPE_FLOAT = 0, 59 GENLIB_PARAMTYPE_SYM = 1 60 } e_genlib_paramtypes; 61 62 struct ParamInfo 63 { 64 t_param defaultvalue; 65 void *defaultref; 66 char hasinputminmax; 67 char hasminmax; 68 t_param inputmin, inputmax; 69 t_param outputmin, outputmax; 70 const char *name; 71 const char *units; 72 int paramtype; // 0 -> float64, 1 -> symbol (table name) 73 t_param exp; // future, for scaling 74 }; 75 76 struct CommonState 77 { 78 t_sample sr; 79 int vs; 80 int numins; 81 int numouts; 82 const char **inputnames; 83 const char **outputnames; 84 int numparams; 85 ParamInfo *params; 86 87 void *parammap; // implementation-dependent 88 void *api; // implementation-dependent 89 }; 90 91 // opaque interface to float32 buffer: 92 typedef struct _genlib_buffer t_genlib_buffer; 93 typedef struct { 94 char b_name[256]; ///< name of the buffer 95 float *b_samples; ///< stored with interleaved channels if multi-channel 96 long b_frames; ///< number of sample frames (each one is sizeof(float) * b_nchans bytes) 97 long b_nchans; ///< number of channels 98 long b_size; ///< size of buffer in floats 99 float b_sr; ///< sampling rate of the buffer 100 long b_modtime; ///< last modified time ("dirty" method) 101 long b_rfu[57]; ///< reserved for future use 102 } t_genlib_buffer_info; 103 104 // opaque interface to float64 buffer: 105 typedef struct _genlib_data t_genlib_data; 106 typedef struct { 107 int dim, channels; 108 t_sample * data; 109 } t_genlib_data_info; 110 111 typedef void (*setparameter_method) (CommonState *, long, t_param, void *); 112 typedef void (*getparameter_method) (CommonState *, long, t_param *); 113 114 #endif // GENLIB_COMMON_H 115 116 117