bool LadspaManager::hasRealTimeDependency( 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_REALTIME( descriptor->Properties ) ); } else { return( false ); } }
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; }
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"); }