DPF with Max Gen
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
4.7KB

  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. #ifndef GENLIB_COMMON_H
  24. #define GENLIB_COMMON_H 1
  25. #include "genlib_platform.h"
  26. //////////// genlib_common.h ////////////
  27. // common data structure header file -- this is the stuff required by the
  28. // common code and accessed by the export and max code
  29. #define DSP_GEN_MAX_SIGNALS 16
  30. // json is enabled by default, but can be disabled if not needed
  31. #ifndef GENLIB_USE_JSON
  32. #define GENLIB_USE_JSON 1
  33. #endif
  34. #ifdef GENLIB_USE_FLOAT32
  35. typedef float t_sample;
  36. typedef float t_param;
  37. #else
  38. typedef double t_sample;
  39. typedef double t_param;
  40. #endif
  41. typedef char *t_ptr;
  42. typedef long t_genlib_err;
  43. typedef enum {
  44. GENLIB_ERR_NONE = 0, ///< No error
  45. GENLIB_ERR_GENERIC = -1, ///< Generic error
  46. GENLIB_ERR_INVALID_PTR = -2, ///< Invalid Pointer
  47. GENLIB_ERR_DUPLICATE = -3, ///< Duplicate
  48. GENLIB_ERR_OUT_OF_MEM = -4, ///< Out of memory
  49. GENLIB_ERR_LOOP_OVERFLOW = 100, // too many iterations of loops in perform()
  50. GENLIB_ERR_NULL_BUFFER = 101 // missing signal data in perform()
  51. } e_genlib_errorcodes;
  52. typedef enum {
  53. GENLIB_PARAMTYPE_FLOAT = 0,
  54. GENLIB_PARAMTYPE_SYM = 1
  55. } e_genlib_paramtypes;
  56. struct ParamInfo
  57. {
  58. t_param defaultvalue;
  59. void *defaultref;
  60. char hasinputminmax;
  61. char hasminmax;
  62. t_param inputmin, inputmax;
  63. t_param outputmin, outputmax;
  64. const char *name;
  65. const char *units;
  66. int paramtype; // 0 -> float64, 1 -> symbol (table name)
  67. t_param exp; // future, for scaling
  68. };
  69. struct CommonState
  70. {
  71. t_sample sr;
  72. int vs;
  73. int numins;
  74. int numouts;
  75. const char **inputnames;
  76. const char **outputnames;
  77. int numparams;
  78. ParamInfo *params;
  79. void *parammap; // implementation-dependent
  80. void *api; // implementation-dependent
  81. };
  82. // opaque interface to float32 buffer:
  83. typedef struct _genlib_buffer t_genlib_buffer;
  84. typedef struct {
  85. char b_name[256]; ///< name of the buffer
  86. float *b_samples; ///< stored with interleaved channels if multi-channel
  87. long b_frames; ///< number of sample frames (each one is sizeof(float) * b_nchans bytes)
  88. long b_nchans; ///< number of channels
  89. long b_size; ///< size of buffer in floats
  90. float b_sr; ///< sampling rate of the buffer
  91. long b_modtime; ///< last modified time ("dirty" method)
  92. long b_rfu[57]; ///< reserved for future use
  93. } t_genlib_buffer_info;
  94. // opaque interface to float64 buffer:
  95. typedef struct _genlib_data t_genlib_data;
  96. typedef struct {
  97. int dim, channels;
  98. t_sample * data;
  99. } t_genlib_data_info;
  100. typedef void (*setparameter_method) (CommonState *, long, t_param, void *);
  101. typedef void (*getparameter_method) (CommonState *, long, t_param *);
  102. #endif // GENLIB_COMMON_H