Ejemplo n.º 1
0
Archivo: plugin.c Proyecto: vpinon/mlt
plugin_t *
plugin_new (plugin_desc_t * desc, jack_rack_t * jack_rack)
{
    void * dl_handle;
    const LADSPA_Descriptor * descriptor;
    LADSPA_Handle * instances;
    gint copies;
    unsigned long i;
    int err;
    plugin_t * plugin;

    /* open the plugin */
    err = plugin_open_plugin (desc, &dl_handle, &descriptor);
    if (err)
        return NULL;

    /* create the instances */
    copies = plugin_desc_get_copies (desc, jack_rack->channels);
    instances = g_malloc (sizeof (LADSPA_Handle) * copies);

    err = plugin_instantiate (descriptor, desc->index, copies, instances);
    if (err)
    {
        g_free (instances);
        dlclose (dl_handle);
        return NULL;
    }


    plugin = g_malloc (sizeof (plugin_t));

    plugin->descriptor = descriptor;
    plugin->dl_handle = dl_handle;
    plugin->desc = desc;
    plugin->copies = copies;
    plugin->enabled = FALSE;
    plugin->next = NULL;
    plugin->prev = NULL;
    plugin->wet_dry_enabled = FALSE;
    plugin->jack_rack = jack_rack;

    /* create audio memory and wet/dry stuff */
    plugin->audio_output_memory   = g_malloc (sizeof (LADSPA_Data *) * jack_rack->channels);
    plugin->wet_dry_fifos  = g_malloc (sizeof (lff_t) * jack_rack->channels);
    plugin->wet_dry_values = g_malloc (sizeof (LADSPA_Data) * jack_rack->channels);

    for (i = 0; i < jack_rack->channels; i++)
    {
        plugin->audio_output_memory[i] = g_malloc (sizeof (LADSPA_Data) * buffer_size);
        lff_init (plugin->wet_dry_fifos + i, CONTROL_FIFO_SIZE, sizeof (LADSPA_Data));
        plugin->wet_dry_values[i] = 1.0;
    }

    /* create holders and fill them out */
    plugin->holders = g_malloc (sizeof (ladspa_holder_t) * copies);
    for (i = 0; i < copies; i++)
        plugin_init_holder (plugin, i, instances[i], jack_rack);

    return plugin;
}
Ejemplo n.º 2
0
Archivo: plugin_mgr.c Proyecto: aib/mlt
void
plugin_mgr_set_plugins (plugin_mgr_t * plugin_mgr, unsigned long rack_channels)
{
  GSList * list;
  plugin_desc_t * desc;

  /* clear the current plugins */
  g_slist_free (plugin_mgr->plugins);
  plugin_mgr->plugins = NULL;
  
  for (list = plugin_mgr->all_plugins; list; list = g_slist_next (list))
    {
      desc = (plugin_desc_t *) list->data;
      
      if (plugin_desc_get_copies (desc, rack_channels) != 0)
        plugin_mgr->plugins = g_slist_append (plugin_mgr->plugins, desc);
    }
}
Ejemplo n.º 3
0
settings_t *
settings_new     (plugin_desc_t * desc, unsigned long channels, guint32 sample_rate)
{
    settings_t * settings;
    unsigned long channel;
    guint copies;

    settings = g_malloc (sizeof (settings_t));
    copies = plugin_desc_get_copies (desc, channels);

    settings->sample_rate = sample_rate;
    settings->desc = desc;
    settings->copies = copies;
    settings->channels = channels;
    settings->lock_all = TRUE;
    settings->enabled = FALSE;
    settings->locks = NULL;
    settings->control_values = NULL;
    settings->wet_dry_enabled = FALSE;
    settings->wet_dry_locked = TRUE;

    /* control settings */
    if (desc->control_port_count > 0)
    {
        guint copy;

        settings->locks = g_malloc (sizeof (gboolean) * desc->control_port_count);

        settings->control_values = g_malloc (sizeof (LADSPA_Data *) * copies);
        for (copy = 0; copy < copies; copy++)
        {
            settings->control_values[copy] = g_malloc (sizeof (LADSPA_Data) * desc->control_port_count);
        }

        settings_set_to_default (settings, sample_rate);
    }

    /* wet/dry settings */
    settings->wet_dry_values = g_malloc (sizeof (LADSPA_Data) * channels);
    for (channel = 0; channel < channels; channel++)
        settings->wet_dry_values[channel] = 1.0;

    return settings;
}