Nu:Tekt NTS-1 digital SDK  v1.1-0
userprg.h
Go to the documentation of this file.
1 /*
2  BSD 3-Clause License
3 
4  Copyright (c) 2018, KORG INC.
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without
8  modification, are permitted provided that the following conditions are met:
9 
10  * Redistributions of source code must retain the above copyright notice, this
11  list of conditions and the following disclaimer.
12 
13  * Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17  * Neither the name of the copyright holder nor the names of its
18  contributors may be used to endorse or promote products derived from
19  this software without specific prior written permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 //*/
32 
41 #ifndef __userprg_h
42 #define __userprg_h
43 
44 #include <stdint.h>
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
53  enum {
64  k_num_user_modules,
65  };
66 
70  enum {
71  k_user_target_prologue = (1U<<8),
72  k_user_target_prologue_global = (1U<<8) | k_user_module_global,
73  k_user_target_prologue_modfx = (1U<<8) | k_user_module_modfx,
74  k_user_target_prologue_delfx = (1U<<8) | k_user_module_delfx,
75  k_user_target_prologue_revfx = (1U<<8) | k_user_module_revfx,
76  k_user_target_prologue_osc = (1U<<8) | k_user_module_osc,
77  };
78 
82  enum {
83  k_user_target_miniloguexd = (2U<<8),
84  k_user_target_miniloguexd_global = (2U<<8) | k_user_module_global,
85  k_user_target_miniloguexd_modfx = (2U<<8) | k_user_module_modfx,
86  k_user_target_miniloguexd_delfx = (2U<<8) | k_user_module_delfx,
87  k_user_target_miniloguexd_revfx = (2U<<8) | k_user_module_revfx,
88  k_user_target_miniloguexd_osc = (2U<<8) | k_user_module_osc,
89  };
90 
94  enum {
95  k_user_target_nutektdigital = (3U<<8),
96  k_user_target_nutektdigital_global = (3U<<8) | k_user_module_global,
97  k_user_target_nutektdigital_modfx = (3U<<8) | k_user_module_modfx,
98  k_user_target_nutektdigital_delfx = (3U<<8) | k_user_module_delfx,
99  k_user_target_nutektdigital_revfx = (3U<<8) | k_user_module_revfx,
100  k_user_target_nutektdigital_osc = (3U<<8) | k_user_module_osc,
101  };
102 
104 #define USER_TARGET_PLATFORM (k_user_target_nutektdigital)
105 #define USER_TARGET_PLATFORM_MASK (0x7F<<8)
106 #define USER_TARGET_MODULE_MASK (0x7F)
107 
109 #define USER_TARGET_PLATFORM_IS_COMPAT(tgt) \
110  ((((tgt)&USER_TARGET_PLATFORM_MASK)==k_user_target_prologue) \
111  || (((tgt)&USER_TARGET_PLATFORM_MASK)==k_user_target_miniloguexd) \
112  || (((tgt)&USER_TARGET_PLATFORM_MASK)==k_user_target_nutektdigital))
113 
121  enum {
122  k_user_api_1_0_0 = ((1U<<16) | (0U<<8) | (0U)),
123  k_user_api_1_1_0 = ((1U<<16) | (1U<<8) | (0U))
124  };
125 
127 #define USER_API_VERSION (k_user_api_1_1_0)
128 #define USER_API_MAJOR_MASK (0x7F<<16)
129 #define USER_API_MINOR_MASK (0x7F<<8)
130 #define USER_API_PATCH_MASK (0x7F)
131 #define USER_API_MAJOR(v) ((v)>>16 & 0x7F)
132 #define USER_API_MINOR(v) ((v)>>8 & 0x7F)
133 #define USER_API_PATCH(v) ((v) & 0x7F)
134 
136 #define USER_API_IS_COMPAT(api) \
137  ((((api) & USER_API_MAJOR_MASK) == (USER_API_VERSION & USER_API_MAJOR_MASK)) \
138  && (((api) & USER_API_MINOR_MASK) <= (USER_API_VERSION & USER_API_MINOR_MASK)))
139 
141 #define USER_PRG_HEADER_SIZE (0x400) // 1KB
142 
144 #define USER_PRG_SIG_SIZE (0x84) // 132B - can fit ECDSA sig using secp521r1
145 
147 #define USER_PRG_MAX_PARAM_COUNT (6)
148 
150 #define USER_PRG_PARAM_MIN_LIMIT (-100)
151 
153 #define USER_PRG_PARAM_MAX_LIMIT (100)
154 
156 #define USER_PRG_PARAM_NAME_LEN (12)
157 
159 #define USER_PRG_NAME_LEN (13)
160 
162  enum {
163  k_user_prg_param_type_percent = 0,
164  k_user_prg_param_type_percent_bipolar,
165  k_user_prg_param_type_select,
166  k_user_prg_param_type_count
167  };
168 
170 #pragma pack(push, 1)
171  typedef struct user_prg_param {
172  int8_t min;
173  int8_t max;
174  uint8_t type;
175  char name[USER_PRG_PARAM_NAME_LEN+1];
176  } user_prg_param_t;
177 #pragma pack(pop)
178 
180 #pragma pack(push, 1)
181  typedef struct user_prg_header {
182  uint16_t target;
183  uint32_t api;
184  uint32_t dev_id;
185  uint32_t prg_id;
186  uint32_t version;
187  char name[USER_PRG_NAME_LEN+1];
188  uint32_t num_param;
189  user_prg_param_t params[USER_PRG_MAX_PARAM_COUNT];
190  uint8_t pad[USER_PRG_HEADER_SIZE-40-USER_PRG_MAX_PARAM_COUNT*sizeof(user_prg_param_t)];
191  uint32_t load_size;
192  } user_prg_header_t;
193 #pragma pack(pop)
194 
195  // Located at load-size bytes after header
197 #pragma pack(push, 1)
198  typedef struct user_prg_sig {
199  uint8_t pad[USER_PRG_SIG_SIZE];
200  } user_prg_sig_t;
201 #pragma pack(pop)
202 
203 #ifdef __cplusplus
204 } // extern "C"
205 #endif
206 
207 #endif // __userprg_h
208 
k_user_module_osc
Oscillators.
Definition: userprg.h:63
k_user_module_revfx
Reverb effects.
Definition: userprg.h:61
k_user_module_modfx
Modulation effects.
Definition: userprg.h:57
k_user_module_delfx
Delay effects.
Definition: userprg.h:59
k_user_module_global
Dummy category, may be used in future.
Definition: userprg.h:55