예제 #1
0
Result
LV2Module::instantiate (double samplerate)
{
    freeInstance();
    currentSampleRate = samplerate;
    
    features.clearQuick();
    world.getFeatures (features);
    
    // check for a worker interface
    LilvNodes* nodes = lilv_plugin_get_extension_data (plugin);
    LILV_FOREACH (nodes, iter, nodes)
    {
        const LilvNode* node = lilv_nodes_get (nodes, iter);
        if (lilv_node_equals (node, world.work_interface))
        {
            worker = new LV2Worker (world.getWorkThread(), 1);
            features.add (worker->getFeature());
        }
    }
    lilv_nodes_free (nodes); nodes = nullptr;        
    
    features.add (nullptr);
    instance = lilv_plugin_instantiate (plugin, samplerate,
                                        features.getRawDataPointer());
    if (instance == nullptr) {
        features.clearQuick();
        worker = nullptr;
        return Result::fail ("Could not instantiate plugin.");
    }
    
    if (const void* data = getExtensionData (LV2_WORKER__interface))
    {
        assert (worker != nullptr);
        worker->setSize (2048);
        worker->setInterface (lilv_instance_get_handle (instance),
                              (LV2_Worker_Interface*) data);
    }
    else if (worker)
    {
        features.removeFirstMatchingValue (worker->getFeature());
        worker = nullptr;
    }
    
    return Result::ok();
}
예제 #2
0
void
LV2Module::setSampleRate (double newSampleRate)
{
    if (newSampleRate == currentSampleRate)
        return;
    
    if (instance != nullptr)
    {
        const bool wasActive = isActive();
        deactivate();
        
        freeInstance();
        instantiate (newSampleRate);
                
        jassert (currentSampleRate == newSampleRate);
        
        if (wasActive)
            activate();
    }
}
예제 #3
0
void fmiFreeModelInstance(fmiComponent c) {
    freeInstance("fmiFreeModelInstance", c);
}
예제 #4
0
void fmiFreeSlaveInstance(fmiComponent c) {
    ModelInstance* comp = (ModelInstance *)c;
    if (invalidState(comp, "fmiFreeSlaveInstance", modelTerminated))
         return;
    freeInstance("fmiFreeSlaveInstance", c);
}
예제 #5
0
LV2Module::~LV2Module()
{
    freeInstance();
    worker = nullptr;
}