| 244 | |
| 245 | template <typename T> |
| 246 | audio_processor_metaclass<T>::audio_processor_metaclass() |
| 247 | { |
| 248 | audio_processor_metaclass::instance = this; |
| 249 | using instance = audio_processor<T>; |
| 250 | |
| 251 | #if !defined(_MSC_VER) |
| 252 | //static_assert(std::is_aggregate_v<T>); |
| 253 | static_assert(std::is_aggregate_v<instance>); |
| 254 | static_assert(std::is_nothrow_constructible_v<instance>); |
| 255 | // static_assert(std::is_nothrow_move_constructible_v<instance>); |
| 256 | // static_assert(std::is_nothrow_move_assignable_v<instance>); |
| 257 | #endif |
| 258 | |
| 259 | /// Small wrapper methods which will call into our actual type /// |
| 260 | |
| 261 | // Ctor |
| 262 | constexpr auto obj_new = +[](t_symbol* s, int argc, t_atom* argv) -> void* { |
| 263 | // Initializes the t_object |
| 264 | auto* ptr = object_alloc(g_class); |
| 265 | t_object tmp; |
| 266 | memcpy(&tmp, ptr, sizeof(t_object)); |
| 267 | |
| 268 | // Initializes the rest |
| 269 | auto obj = reinterpret_cast<instance*>(ptr); |
| 270 | new(obj) instance; |
| 271 | |
| 272 | memcpy(&obj->x_obj, &tmp, sizeof(t_object)); |
| 273 | |
| 274 | obj->init(argc, argv); |
| 275 | return obj; |
| 276 | }; |
| 277 | |
| 278 | // Dtor |
| 279 | constexpr auto obj_free = +[](instance* obj) -> void { |
| 280 | obj->destroy(); |
| 281 | obj->~instance(); |
| 282 | }; |
| 283 | |
| 284 | // DSP |
| 285 | constexpr auto obj_dsp |
| 286 | = +[](instance* obj, t_object* dsp64, short* count, double samplerate, |
| 287 | long maxvectorsize, long flags) -> void { |
| 288 | obj->dsp(dsp64, count, samplerate, maxvectorsize, flags); |
| 289 | }; |
| 290 | |
| 291 | constexpr auto inputchange = +[](instance* x, long index, long count) -> long { |
| 292 | if(count != x->m_runtime_input_count) |
| 293 | { |
| 294 | x->m_runtime_input_count = count; |
| 295 | return true; |
| 296 | } |
| 297 | else |
| 298 | return false; |
| 299 | }; |
| 300 | constexpr auto outputcount = +[](instance* x, long index) -> long { |
| 301 | // TODO check whether the outputs are fixed or dynamic |
| 302 | return x->m_runtime_input_count; |
| 303 | }; |