Пример #1
0
// Derived methods.
bool qtractorLadspaPluginType::open (void)
{
	// Do we have a descriptor already?
	if (m_pLadspaDescriptor == NULL)
		m_pLadspaDescriptor = ladspa_descriptor(file(), index());
	if (m_pLadspaDescriptor == NULL)
		return false;

#ifdef CONFIG_DEBUG
	qDebug("qtractorLadspaPluginType[%p]::open() filename=\"%s\" index=%lu",
		this, filename().toUtf8().constData(), index());
#endif

	// Retrieve plugin type names.
	m_sName  = m_pLadspaDescriptor->Name;
	m_sLabel = m_pLadspaDescriptor->Label;

	// Retrieve plugin unique identifier.
	m_iUniqueID = m_pLadspaDescriptor->UniqueID;

	// Compute and cache port counts...
	m_iControlIns  = 0;
	m_iControlOuts = 0;
	m_iAudioIns    = 0;
	m_iAudioOuts   = 0;
	m_iMidiIns     = 0;
	m_iMidiOuts    = 0;

	for (unsigned long i = 0; i < m_pLadspaDescriptor->PortCount; ++i) {
		const LADSPA_PortDescriptor portType
			= m_pLadspaDescriptor->PortDescriptors[i];
		if (LADSPA_IS_PORT_INPUT(portType)) {
			if (LADSPA_IS_PORT_AUDIO(portType))
				++m_iAudioIns;
			else
			if (LADSPA_IS_PORT_CONTROL(portType))
				++m_iControlIns;
		}
		else
		if (LADSPA_IS_PORT_OUTPUT(portType)) {
			if (LADSPA_IS_PORT_AUDIO(portType))
				++m_iAudioOuts;
			else
			if (LADSPA_IS_PORT_CONTROL(portType))
				++m_iControlOuts;
		}
	}

	// Cache flags.
	m_bRealtime = LADSPA_IS_HARD_RT_CAPABLE(m_pLadspaDescriptor->Properties);

	// Done.
	return true;
}
Пример #2
0
bool LadspaManager::isRealTimeCapable(
					const ladspa_key_t &  _plugin )
{
	if( m_ladspaManagerMap.contains( _plugin ) )
	{
		LADSPA_Descriptor_Function descriptorFunction =
			m_ladspaManagerMap[_plugin]->descriptorFunction;
		const LADSPA_Descriptor * descriptor =
				descriptorFunction(
					m_ladspaManagerMap[_plugin]->index );
		return( LADSPA_IS_HARD_RT_CAPABLE( descriptor->Properties ) );
	}
	else
	{
		return( false );
	}
}
Пример #3
0
plugin_t *
jack_rack_instantiate_plugin (jack_rack_t * jack_rack, plugin_desc_t * desc)
{
  plugin_t * plugin;
  
  /* check whether or not the plugin is RT capable and confirm with the user if it isn't */
  if (!LADSPA_IS_HARD_RT_CAPABLE(desc->properties)) {
    GtkWidget * dialog;
    gint response;

    dialog = gtk_message_dialog_new (GTK_WINDOW(jack_rack->ui->main_window),
               GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL,
               GTK_MESSAGE_WARNING,
               GTK_BUTTONS_YES_NO,
               _("Plugin not RT capable\n\nThe plugin '%s' does not describe itself as being capable of real-time operation.  If you use it, you may experience drop-outs or unexpected disconnection from JACK.\n\nAre you sure you want to add this plugin?"),
               desc->name);
    response = gtk_dialog_run (GTK_DIALOG (dialog));
    gtk_widget_destroy (dialog);
    
    if (response != GTK_RESPONSE_YES) {
      return NULL;
    }
  }

  /* create the plugin */
  plugin = plugin_new (desc, jack_rack);

  if (!plugin) {
    GtkWidget * dialog;
    
    dialog = gtk_message_dialog_new (GTK_WINDOW(jack_rack->ui->main_window),
               GTK_DIALOG_DESTROY_WITH_PARENT,
               GTK_MESSAGE_ERROR,
               GTK_BUTTONS_CLOSE,
               _("Error loading file plugin '%s' from file '%s'"),
               desc->name, desc->object_file);
    gtk_dialog_run (GTK_DIALOG (dialog));
    gtk_widget_destroy (dialog);
    return NULL;
  }
  
  return plugin;
}
Пример #4
0
plugin_t *
jack_rack_instantiate_plugin (jack_rack_t * jack_rack, plugin_desc_t * desc)
{
  plugin_t * plugin;
  
  /* check whether or not the plugin is RT capable and confirm with the user if it isn't */
  if (!LADSPA_IS_HARD_RT_CAPABLE(desc->properties)) {
    mlt_log_info( NULL, "Plugin not RT capable. The plugin '%s' does not describe itself as being capable of real-time operation. You may experience drop outs or jack may even kick us out if you use it.\n",
               desc->name);
  }

  /* create the plugin */
  plugin = plugin_new (desc, jack_rack);

  if (!plugin) {
   mlt_log_error( NULL, "Error loading file plugin '%s' from file '%s'\n",
               desc->name, desc->object_file);
  }
  
  return plugin;
}
Пример #5
0
plugin_desc_t *
plugin_desc_new_with_descriptor (const char * object_file,
                                 unsigned long index,
                                 const LADSPA_Descriptor * descriptor)
{
  plugin_desc_t * pd;
  pd = plugin_desc_new ();
  
  plugin_desc_set_object_file (pd, object_file);
  plugin_desc_set_index       (pd, index);
  plugin_desc_set_id          (pd, descriptor->UniqueID);
  plugin_desc_set_name        (pd, descriptor->Name);
  plugin_desc_set_maker       (pd, descriptor->Maker);
  plugin_desc_set_properties  (pd, descriptor->Properties);
  plugin_desc_set_ports       (pd,
                               descriptor->PortCount,
                               descriptor->PortDescriptors,
                               descriptor->PortRangeHints,
                               descriptor->PortNames);
  
  pd->rt = LADSPA_IS_HARD_RT_CAPABLE(pd->properties) ? TRUE : FALSE;

  return pd;
}
int lp_ladspa_plugin::init(const LADSPA_Descriptor *descriptor, int channels, int buf_size, int samplerate)
{
	if(descriptor == 0){
		std::cerr << "lp_ladspa_plugin::" << __FUNCTION__ << ": descriptor is Null\n";
		return -1;
	}
	pv_descriptor = descriptor;

	if(pv_descriptor->activate != 0){
		pv_has_activate = true;
	}
	if(pv_descriptor->deactivate != 0){
		pv_has_deactivate = true;
	}

	int col = 2;

	// Layout
	layout = new QGridLayout(this);

	// Add the gain control
	gain_slider = new lp_ladspa_slider_float;
	gain_slider->init(-20.0, 10.0, 0.0, true);
	gain_slider->set_name(QObject::tr("Input gain"));
	layout->addWidget(gain_slider, 1, 0);

	// Add input meter
	in_peackmeter = new lp_peackmeter(this, channels, buf_size);
	in_pmc = in_peackmeter->get_core();
	layout->addWidget(in_peackmeter, 1, 1);


	// Plugin parameters here
	if(LADSPA_IS_REALTIME(pv_descriptor->Properties)){
		std::cerr << "lp_ladspa_plugin::" << __FUNCTION__ << ": Real time dependencies\n";
	}
	if(LADSPA_IS_INPLACE_BROKEN(pv_descriptor->Properties)){
		std::cerr << "lp_ladspa_plugin::" << __FUNCTION__ << ": INPLACE BROCKEN !\n";
	}
	if(LADSPA_IS_HARD_RT_CAPABLE(pv_descriptor->Properties)){
		std::cerr << "lp_ladspa_plugin::" << __FUNCTION__ << ": Hard RT\n";
	}


	txt_routing = new QLabel;
	layout->addWidget(txt_routing, 0, 0);

	unsigned long i, pcount, ctl_count = 0;
	pcount = descriptor->PortCount;

	// Audio ports - the pv_audio_ports instance manages all audio ports
	pv_audio_ports = new lp_ladspa_audio_ports;
	pv_audio_ports->init(descriptor, channels, buf_size, samplerate);
	txt_routing->setText("Routing mode: " + pv_audio_ports->get_merge_mode_name());
	pv_handles_count = pv_audio_ports->needed_handles_count();
	std::cout << "handles count: " << pv_handles_count << "\n";

	// Count ctl ports
	for(i=0; i<pcount; i++){
		if(LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i])) {
			ctl_count++;
			//std::cout << "Ctl port: " << ctl_count << std::endl;
		}
	}
	pv_ctl_ports = new lp_ladspa_ctl_port[ctl_count];
	// init each ctl port
	ctl_count = 0;
	for(i=0; i<pcount; i++){
		if(LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i])) {
			if((pv_ctl_ports[ctl_count].init_port(descriptor, i, samplerate, layout, 1, col))<0){
				std::cerr << "lp_ladspa_plugin::" << __FUNCTION__ << ": initialisation failed !\n";
			}
			col++;
			ctl_count++;
		}
	}
	pv_ctl_count = (int)ctl_count;
	// Instanciate plugin
	int y;
	pv_instances = new lp_ladspa_handle[pv_handles_count];
	if(pv_instances == 0){
		std::cerr << "lp_ladspa_plugin::" << __FUNCTION__ << ": plugin instantiation failed\n";
	}
	for(y=0; y<pv_handles_count; y++){
		if(pv_instances[y].instantiate(pv_descriptor, (unsigned long)samplerate) < 0){
			std::cerr << "lp_ladspa_plugin::" << __FUNCTION__ << ": plugin instantiation failed\n";
			return -1;
		}
	}

	// call instantiate
	pv_audio_ports->instantiate(pv_instances);
	for(i=0; i<ctl_count; i++){
		pv_ctl_ports[i].instantiate(pv_instances, pv_handles_count);
	}

	// Add output meter
	out_peackmeter = new lp_peackmeter(this, channels, buf_size);
	out_pmc = out_peackmeter->get_core();
	layout->addWidget(out_peackmeter, 1, pv_ctl_count + 2);

	setLayout(layout);
	setWindowTitle(pv_descriptor->Name);

	return 0;
}
Пример #7
0
static void dump_info(const LADSPA_Descriptor *ldesc)
{
    int i = 0;

    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Plugin Name: \"%s\"\n", ldesc->Name);
    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Plugin Label: \"%s\"\n", ldesc->Label);
    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Plugin Unique ID: %lu\n", ldesc->UniqueID);
    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Maker: \"%s\"\n", ldesc->Maker);
    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Copyright: \"%s\"\n", ldesc->Copyright);

    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Must Run Real-Time: ");
    if (LADSPA_IS_REALTIME(ldesc->Properties))
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Yes\n");
    else
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "No\n");

    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Has activate() Function: ");
    if (ldesc->activate != NULL)
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Yes\n");
    else
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "No\n");
    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Has deactivate() Function: ");
    if (ldesc->deactivate != NULL)
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Yes\n");
    else
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "No\n");
    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Has run_adding() Function: ");
    if (ldesc->run_adding != NULL)
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Yes\n");
    else
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "No\n");

    if (ldesc->instantiate == NULL)
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "ERROR: PLUGIN HAS NO INSTANTIATE FUNCTION.\n");
    if (ldesc->connect_port == NULL)
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "ERROR: PLUGIN HAS NO CONNECT_PORT FUNCTION.\n");
    if (ldesc->run == NULL)
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "ERROR: PLUGIN HAS NO RUN FUNCTION.\n");
    if (ldesc->run_adding != NULL && ldesc->set_run_adding_gain == NULL)
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "ERROR: PLUGIN HAS RUN_ADDING FUNCTION BUT " "NOT SET_RUN_ADDING_GAIN.\n");
    if (ldesc->run_adding == NULL && ldesc->set_run_adding_gain != NULL)
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "ERROR: PLUGIN HAS SET_RUN_ADDING_GAIN FUNCTION BUT " "NOT RUN_ADDING.\n");
    if (ldesc->cleanup == NULL)
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "ERROR: PLUGIN HAS NO CLEANUP FUNCTION.\n");

    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Environment: ");
    if (LADSPA_IS_HARD_RT_CAPABLE(ldesc->Properties))
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Normal or Hard Real-Time\n");
    else
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Normal\n");

    if (LADSPA_IS_INPLACE_BROKEN(ldesc->Properties))
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "This plugin cannot use in-place processing. " "It will not work with all hosts.\n");

    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "Ports:");

    if (ldesc->PortCount == 0)
        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "\tERROR: PLUGIN HAS NO PORTS.\n");

    for (i = 0; i < ldesc->PortCount; i++) {
        LADSPA_Data dft = 0.0f;
        int found = 0;

        if (LADSPA_IS_PORT_CONTROL(ldesc->PortDescriptors[i])) {
            found = find_default(ldesc, i, &dft);
        }

        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "\n  \"%s\" ", ldesc->PortNames[i]);

        if (LADSPA_IS_PORT_INPUT(ldesc->PortDescriptors[i])
                && LADSPA_IS_PORT_OUTPUT(ldesc->PortDescriptors[i]))
            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "ERROR: INPUT AND OUTPUT");
        else if (LADSPA_IS_PORT_INPUT(ldesc->PortDescriptors[i]))
            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "input");
        else if (LADSPA_IS_PORT_OUTPUT(ldesc->PortDescriptors[i]))
            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "output");
        else
            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "ERROR: NEITHER INPUT NOR OUTPUT");

        if (LADSPA_IS_PORT_CONTROL(ldesc->PortDescriptors[i])
                && LADSPA_IS_PORT_AUDIO(ldesc->PortDescriptors[i]))
            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, ", ERROR: CONTROL AND AUDIO");
        else if (LADSPA_IS_PORT_CONTROL(ldesc->PortDescriptors[i]))
            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, ", control");
        else if (LADSPA_IS_PORT_AUDIO(ldesc->PortDescriptors[i]))
            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, ", audio");
        else
            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, ", ERROR: NEITHER CONTROL NOR AUDIO");

        if (LADSPA_IS_PORT_CONTROL(ldesc->PortDescriptors[i])) {
            if (found) {
                switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "\n    RANGE: %f-%f DEFAULT: %f\n",
                                  ldesc->PortRangeHints[i].LowerBound, ldesc->PortRangeHints[i].UpperBound, dft);
            } else {
                switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "\n    RANGE: %f-%f DEFAULT: none.\n",
                                  ldesc->PortRangeHints[i].LowerBound, ldesc->PortRangeHints[i].UpperBound);
            }
        }



    }

    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "\n\n");
}