MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / fInitializer

Function fInitializer

src/CardinalUI.cpp:345–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343 #if ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
344 #ifdef DISTRHO_OS_WASM
345 fInitializer(new Initializer(static_cast<const CardinalBasePlugin*>(nullptr), this)),
346 #else
347 fInitializer(static_cast<const CardinalBasePlugin*>(nullptr), this),
348 #endif
349 #endif
350 lastMousePos()
351 {
352 rack::contextSet(context);
353
354 #if CARDINAL_VARIANT_MINI && ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
355 // create unique temporary path for this instance
356 try {
357 char uidBuf[24];
358 const std::string tmp = rack::system::getTempDirectory();
359
360 for (int i=1;; ++i)
361 {
362 std::snprintf(uidBuf, sizeof(uidBuf), "Cardinal.%04d", i);
363 const std::string trypath = rack::system::join(tmp, uidBuf);
364
365 if (! rack::system::exists(trypath))
366 {
367 if (rack::system::createDirectories(trypath))
368 fAutosavePath = trypath;
369 break;
370 }
371 }
372 } DISTRHO_SAFE_EXCEPTION("create unique temporary path");
373
374 const float sampleRate = 60; // fake audio running at 60 fps
375 rack::settings::sampleRate = sampleRate;
376
377 context->dataIns = new const float*[DISTRHO_PLUGIN_NUM_INPUTS];
378 context->dataOuts = new float*[DISTRHO_PLUGIN_NUM_OUTPUTS];
379
380 for (uint32_t i=0; i<DISTRHO_PLUGIN_NUM_INPUTS;++i)
381 {
382 float** const bufferptr = const_cast<float**>(&context->dataIns[i]);
383 *bufferptr = new float[1];
384 (*bufferptr)[0] = 0.f;
385 }
386 for (uint32_t i=0; i<DISTRHO_PLUGIN_NUM_OUTPUTS;++i)
387 context->dataOuts[i] = new float[1];
388
389 context->bufferSize = 1;
390 context->sampleRate = sampleRate;
391
392 context->engine = new rack::engine::Engine;
393 context->engine->setSampleRate(sampleRate);
394
395 context->history = new rack::history::State;
396 context->patch = new rack::patch::Manager;
397 context->patch->autosavePath = fAutosavePath;
398 context->patch->templatePath = context->patch->factoryTemplatePath = fInitializer->factoryTemplatePath;
399
400 context->event = new rack::widget::EventState;
401 context->scene = new rack::app::Scene;
402 context->event->rootWidget = context->scene;

Callers

nothing calls this directly

Calls 15

Engine_setRemoteDetailsFunction · 0.85
fFunction · 0.85
createFunction · 0.85
setSampleRateMethod · 0.80
backMethod · 0.80
frontMethod · 0.80
c_strMethod · 0.80
connectToRemoteFunction · 0.70
isStandaloneFunction · 0.70
contextSetFunction · 0.50
WindowSetPluginUIFunction · 0.50

Tested by

no test coverage detected