Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

757 lines
23KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2009 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. /* Filter module. Can host LADPSA Plugins, or can be inherited from to make internal
  19. modules with special features and appearance. */
  20. #include "const.h"
  21. #include <string.h>
  22. #include <vector>
  23. #include <string>
  24. #include <ladspa.h>
  25. #include <stdlib.h>
  26. #include <math.h>
  27. #include <FL/fl_draw.H>
  28. #include <FL/Fl_Group.H>
  29. #include <FL/Fl_Menu_Button.H>
  30. #include "Plugin_Module.H"
  31. #include "debug.h"
  32. #define HAVE_LIBLRDF 1
  33. #include "LADSPAInfo.h"
  34. #include "Chain.H"
  35. #include "Engine/Engine.H"
  36. #include <dsp.h>
  37. #include <algorithm>
  38. static LADSPAInfo *ladspainfo;
  39. Thread* Plugin_Module::plugin_discover_thread;
  40. /* keep this out of the header to avoid spreading ladspa.h dependency */
  41. struct Plugin_Module::ImplementationData
  42. {
  43. const LADSPA_Descriptor *descriptor;
  44. // std::vector<LADSPA_Data*> m_LADSPABufVec;
  45. std::vector<LADSPA_Handle> handle;
  46. };
  47. Plugin_Module::Plugin_Module ( ) : Module( 50, 35, name() )
  48. {
  49. init();
  50. end();
  51. log_create();
  52. }
  53. Plugin_Module::~Plugin_Module ( )
  54. {
  55. log_destroy();
  56. plugin_instances( 0 );
  57. }
  58. void
  59. Plugin_Module::get ( Log_Entry &e ) const
  60. {
  61. // char s[512];
  62. // snprintf( s, sizeof( s ), "ladspa:%lu", _idata->descriptor->UniqueID );
  63. e.add( ":plugin_id", _idata->descriptor->UniqueID );
  64. /* these help us display the module on systems which are missing this plugin */
  65. e.add( ":plugin_ins", _plugin_ins );
  66. e.add( ":plugin_outs", _plugin_outs );
  67. Module::get( e );
  68. }
  69. void
  70. Plugin_Module::set ( Log_Entry &e )
  71. {
  72. for ( int i = 0; i < e.size(); ++i )
  73. {
  74. const char *s, *v;
  75. e.get( i, &s, &v );
  76. if ( ! strcmp( s, ":plugin_id" ) )
  77. {
  78. load( (unsigned long) atoll ( v ) );
  79. }
  80. else if ( ! strcmp( s, ":plugin_ins" ) )
  81. {
  82. _plugin_ins = atoi( v );
  83. }
  84. else if ( ! strcmp( s, ":plugin_outs" ) )
  85. {
  86. _plugin_outs = atoi( v );
  87. }
  88. }
  89. Module::set( e );
  90. }
  91. void
  92. Plugin_Module::init ( void )
  93. {
  94. _idata = new Plugin_Module::ImplementationData();
  95. _idata->handle.clear();
  96. /* module will be bypassed until plugin is loaded */
  97. _bypass = true;
  98. _crosswire = false;
  99. align( (Fl_Align)FL_ALIGN_CENTER | FL_ALIGN_INSIDE );
  100. // color( (Fl_Color)fl_color_average( FL_MAGENTA, FL_WHITE, 0.5f ) );
  101. int tw, th, tx, ty;
  102. bbox( tx, ty, tw, th );
  103. }
  104. int
  105. Plugin_Module::can_support_inputs ( int n )
  106. {
  107. /* this is the simple case */
  108. if ( plugin_ins() == n )
  109. return plugin_outs();
  110. /* e.g. MONO going into STEREO */
  111. /* we'll duplicate our inputs */
  112. else if ( n < plugin_ins() &&
  113. 1 == n )
  114. {
  115. return plugin_outs();
  116. }
  117. /* e.g. STEREO going into MONO */
  118. /* we'll run multiple instances of the plugin */
  119. else if ( n > plugin_ins() &&
  120. ( plugin_ins() == 1 && plugin_outs() == 1 ) )
  121. {
  122. return n;
  123. }
  124. return -1;
  125. }
  126. bool
  127. Plugin_Module::configure_inputs( int n )
  128. {
  129. int inst = _idata->handle.size();
  130. if ( ninputs() != n )
  131. {
  132. _crosswire = false;
  133. if ( n != ninputs() )
  134. {
  135. if ( 1 == n && plugin_ins() > 1 )
  136. {
  137. DMESSAGE( "Cross-wiring plugin inputs" );
  138. _crosswire = true;
  139. audio_input.clear();
  140. for ( int i = n; i--; )
  141. audio_input.push_back( Port( this, Port::INPUT, Port::AUDIO ) );
  142. }
  143. else if ( n >= plugin_ins() &&
  144. ( plugin_ins() == 1 && plugin_outs() == 1 ) )
  145. {
  146. DMESSAGE( "Running multiple instances of plugin" );
  147. audio_input.clear();
  148. audio_output.clear();
  149. for ( int i = n; i--; )
  150. {
  151. add_port( Port( this, Port::INPUT, Port::AUDIO ) );
  152. add_port( Port( this, Port::OUTPUT, Port::AUDIO ) );
  153. }
  154. inst = n;
  155. }
  156. else if ( n == plugin_ins() )
  157. {
  158. DMESSAGE( "Plugin input configuration is a perfect match" );
  159. }
  160. else
  161. {
  162. DMESSAGE( "Unsupported input configuration" );
  163. return false;
  164. }
  165. }
  166. }
  167. if ( loaded() )
  168. {
  169. bool b = bypass();
  170. if ( !b )
  171. deactivate();
  172. if ( plugin_instances( inst ) )
  173. instances( inst );
  174. else
  175. return false;
  176. if ( !b )
  177. activate();
  178. }
  179. return true;
  180. }
  181. void *
  182. Plugin_Module::discover_thread ( void * )
  183. {
  184. THREAD_ASSERT( Plugin_Discover );
  185. DMESSAGE( "Discovering plugins in the background" );
  186. ladspainfo = new LADSPAInfo();
  187. return NULL;
  188. }
  189. /* Spawn a background thread for plugin discovery */
  190. void
  191. Plugin_Module::spawn_discover_thread ( void )
  192. {
  193. if ( plugin_discover_thread )
  194. {
  195. FATAL( "Plugin discovery thread is already running or has completed" );
  196. }
  197. plugin_discover_thread = new Thread( "Plugin_Discover" );
  198. plugin_discover_thread->clone( &Plugin_Module::discover_thread, NULL );
  199. }
  200. void
  201. Plugin_Module::join_discover_thread ( void )
  202. {
  203. plugin_discover_thread->join();
  204. }
  205. /* return a list of available plugins */
  206. std::list<Plugin_Module::Plugin_Info>
  207. Plugin_Module::get_all_plugins ( void )
  208. {
  209. if ( !ladspainfo )
  210. {
  211. if ( ! plugin_discover_thread )
  212. ladspainfo = new LADSPAInfo();
  213. else
  214. plugin_discover_thread->join();
  215. }
  216. std::vector<LADSPAInfo::PluginInfo> plugins = ladspainfo->GetPluginInfo();
  217. std::list<Plugin_Module::Plugin_Info> pr;
  218. int j = 0;
  219. for (std::vector<LADSPAInfo::PluginInfo>::iterator i=plugins.begin();
  220. i!=plugins.end(); i++, j++)
  221. {
  222. Plugin_Info pi;
  223. // pi[j].path = i->Name.c_str();
  224. pi.path = NULL;
  225. pi.id = i->UniqueID;
  226. pi.author = i->Maker.c_str();
  227. pi.name = i->Name.c_str();
  228. pi.audio_inputs = i->AudioInputs;
  229. pi.audio_outputs = i->AudioOutputs;
  230. pr.push_back( pi );
  231. }
  232. pr.sort();
  233. return pr;
  234. }
  235. bool
  236. Plugin_Module::plugin_instances ( unsigned int n )
  237. {
  238. if ( _idata->handle.size() > n )
  239. {
  240. for ( int i = _idata->handle.size() - n; i--; )
  241. {
  242. DMESSAGE( "Destroying plugin instance" );
  243. LADSPA_Handle h = _idata->handle.back();
  244. if ( _idata->descriptor->deactivate )
  245. _idata->descriptor->deactivate( h );
  246. if ( _idata->descriptor->cleanup )
  247. _idata->descriptor->cleanup( h );
  248. _idata->handle.pop_back();
  249. }
  250. }
  251. else if ( _idata->handle.size() < n )
  252. {
  253. for ( int i = n - _idata->handle.size(); i--; )
  254. {
  255. LADSPA_Handle h;
  256. DMESSAGE( "Instantiating plugin..." );
  257. if ( ! (h = _idata->descriptor->instantiate( _idata->descriptor, Engine::sample_rate() ) ) )
  258. {
  259. WARNING( "Failed to instantiate plugin" );
  260. return false;
  261. }
  262. DMESSAGE( "Instantiated: %p", h );
  263. _idata->handle.push_back( h );
  264. DMESSAGE( "Connecting control ports..." );
  265. int ij = 0;
  266. int oj = 0;
  267. for ( unsigned int k = 0; k < _idata->descriptor->PortCount; ++k )
  268. {
  269. if ( LADSPA_IS_PORT_CONTROL( _idata->descriptor->PortDescriptors[k] ) )
  270. {
  271. if ( LADSPA_IS_PORT_INPUT( _idata->descriptor->PortDescriptors[k] ) )
  272. _idata->descriptor->connect_port( h, k, (LADSPA_Data*)control_input[ij++].buffer() );
  273. else if ( LADSPA_IS_PORT_OUTPUT( _idata->descriptor->PortDescriptors[k] ) )
  274. _idata->descriptor->connect_port( h, k, (LADSPA_Data*)control_output[oj++].buffer() );
  275. }
  276. }
  277. // connect ports to magic bogus value to aid debugging.
  278. for ( unsigned int k = 0; k < _idata->descriptor->PortCount; ++k )
  279. if ( LADSPA_IS_PORT_AUDIO( _idata->descriptor->PortDescriptors[k] ) )
  280. _idata->descriptor->connect_port( h, k, (LADSPA_Data*)0x42 );
  281. }
  282. }
  283. return true;
  284. }
  285. void
  286. Plugin_Module::bypass ( bool v )
  287. {
  288. if ( v != bypass() )
  289. {
  290. if ( v )
  291. deactivate();
  292. else
  293. activate();
  294. }
  295. }
  296. bool
  297. Plugin_Module::load ( unsigned long id )
  298. {
  299. if ( !ladspainfo )
  300. {
  301. if ( ! plugin_discover_thread )
  302. ladspainfo = new LADSPAInfo();
  303. else
  304. plugin_discover_thread->join();
  305. }
  306. _idata->descriptor = ladspainfo->GetDescriptorByID( id );
  307. _plugin_ins = _plugin_outs = 0;
  308. if ( ! _idata->descriptor )
  309. {
  310. /* unknown plugin ID */
  311. WARNING( "Unknown plugin ID: %lu", id );
  312. label( "----" );
  313. return false;
  314. }
  315. label( _idata->descriptor->Name );
  316. if ( _idata->descriptor )
  317. {
  318. if ( LADSPA_IS_INPLACE_BROKEN( _idata->descriptor->Properties ) )
  319. {
  320. WARNING( "Cannot use this plugin because it is incapable of processing audio in-place" );
  321. return false;
  322. }
  323. else if ( ! LADSPA_IS_HARD_RT_CAPABLE( _idata->descriptor->Properties ) )
  324. {
  325. WARNING( "Cannot use this plugin because it is incapable of hard real-time operation" );
  326. return false;
  327. }
  328. MESSAGE( "Name: %s", _idata->descriptor->Name );
  329. for ( unsigned int i = 0; i < _idata->descriptor->PortCount; ++i )
  330. {
  331. if ( LADSPA_IS_PORT_AUDIO( _idata->descriptor->PortDescriptors[i] ) )
  332. {
  333. if ( LADSPA_IS_PORT_INPUT( _idata->descriptor->PortDescriptors[i] ) )
  334. {
  335. add_port( Port( this, Port::INPUT, Port::AUDIO, _idata->descriptor->PortNames[ i ] ) );
  336. _plugin_ins++;
  337. }
  338. else if (LADSPA_IS_PORT_OUTPUT(_idata->descriptor->PortDescriptors[i]))
  339. {
  340. _plugin_outs++;
  341. add_port( Port( this, Port::OUTPUT, Port::AUDIO, _idata->descriptor->PortNames[ i ] ) );
  342. }
  343. }
  344. }
  345. MESSAGE( "Plugin has %i inputs and %i outputs", _plugin_ins, _plugin_outs);
  346. for ( unsigned int i = 0; i < _idata->descriptor->PortCount; ++i )
  347. {
  348. if ( LADSPA_IS_PORT_CONTROL( _idata->descriptor->PortDescriptors[i] ) )
  349. {
  350. Port::Direction d = Port::INPUT;
  351. if ( LADSPA_IS_PORT_INPUT( _idata->descriptor->PortDescriptors[i] ) )
  352. {
  353. d = Port::INPUT;
  354. }
  355. else if ( LADSPA_IS_PORT_OUTPUT( _idata->descriptor->PortDescriptors[i] ) )
  356. {
  357. d = Port::OUTPUT;
  358. }
  359. Port p( this, d, Port::CONTROL, _idata->descriptor->PortNames[ i ] );
  360. LADSPA_PortRangeHintDescriptor hd = _idata->descriptor->PortRangeHints[i].HintDescriptor;
  361. if ( LADSPA_IS_HINT_BOUNDED_BELOW(hd) )
  362. {
  363. p.hints.ranged = true;
  364. p.hints.minimum = _idata->descriptor->PortRangeHints[i].LowerBound;
  365. if ( LADSPA_IS_HINT_SAMPLE_RATE(hd) )
  366. {
  367. p.hints.minimum *= Engine::sample_rate();
  368. }
  369. }
  370. if ( LADSPA_IS_HINT_BOUNDED_ABOVE(hd) )
  371. {
  372. p.hints.ranged = true;
  373. p.hints.maximum = _idata->descriptor->PortRangeHints[i].UpperBound;
  374. if ( LADSPA_IS_HINT_SAMPLE_RATE(hd) )
  375. {
  376. p.hints.maximum *= Engine::sample_rate();
  377. }
  378. }
  379. if ( LADSPA_IS_HINT_HAS_DEFAULT(hd) )
  380. {
  381. float Max=1.0f, Min=-1.0f, Default=0.0f;
  382. int Port=i;
  383. // Get the bounding hints for the port
  384. LADSPA_PortRangeHintDescriptor HintDesc=_idata->descriptor->PortRangeHints[Port].HintDescriptor;
  385. if (LADSPA_IS_HINT_BOUNDED_BELOW(HintDesc))
  386. {
  387. Min=_idata->descriptor->PortRangeHints[Port].LowerBound;
  388. if (LADSPA_IS_HINT_SAMPLE_RATE(HintDesc))
  389. {
  390. Min*=Engine::sample_rate();
  391. }
  392. }
  393. if (LADSPA_IS_HINT_BOUNDED_ABOVE(HintDesc))
  394. {
  395. Max=_idata->descriptor->PortRangeHints[Port].UpperBound;
  396. if (LADSPA_IS_HINT_SAMPLE_RATE(HintDesc))
  397. {
  398. Max*=Engine::sample_rate();
  399. }
  400. }
  401. #ifdef LADSPA_VERSION
  402. // We've got a version of the header that supports port defaults
  403. if (LADSPA_IS_HINT_HAS_DEFAULT(HintDesc)) {
  404. // LADSPA_HINT_DEFAULT_0 is assumed anyway, so we don't check for it
  405. if (LADSPA_IS_HINT_DEFAULT_1(HintDesc)) {
  406. Default = 1.0f;
  407. } else if (LADSPA_IS_HINT_DEFAULT_100(HintDesc)) {
  408. Default = 100.0f;
  409. } else if (LADSPA_IS_HINT_DEFAULT_440(HintDesc)) {
  410. Default = 440.0f;
  411. } else {
  412. // These hints may be affected by SAMPLERATE, LOGARITHMIC and INTEGER
  413. if (LADSPA_IS_HINT_DEFAULT_MINIMUM(HintDesc) &&
  414. LADSPA_IS_HINT_BOUNDED_BELOW(HintDesc)) {
  415. Default=_idata->descriptor->PortRangeHints[Port].LowerBound;
  416. } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(HintDesc) &&
  417. LADSPA_IS_HINT_BOUNDED_ABOVE(HintDesc)) {
  418. Default=_idata->descriptor->PortRangeHints[Port].UpperBound;
  419. } else if (LADSPA_IS_HINT_BOUNDED_BELOW(HintDesc) &&
  420. LADSPA_IS_HINT_BOUNDED_ABOVE(HintDesc)) {
  421. // These hints require both upper and lower bounds
  422. float lp = 0.0f, up = 0.0f;
  423. float min = _idata->descriptor->PortRangeHints[Port].LowerBound;
  424. float max = _idata->descriptor->PortRangeHints[Port].UpperBound;
  425. if (LADSPA_IS_HINT_DEFAULT_LOW(HintDesc)) {
  426. lp = 0.75f;
  427. up = 0.25f;
  428. } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(HintDesc)) {
  429. lp = 0.5f;
  430. up = 0.5f;
  431. } else if (LADSPA_IS_HINT_DEFAULT_HIGH(HintDesc)) {
  432. lp = 0.25f;
  433. up = 0.75f;
  434. }
  435. if (LADSPA_IS_HINT_LOGARITHMIC(HintDesc)) {
  436. p.hints.type = Port::Hints::LOGARITHMIC;
  437. if (min==0.0f || max==0.0f) {
  438. // Zero at either end means zero no matter
  439. // where hint is at, since:
  440. // log(n->0) -> Infinity
  441. Default = 0.0f;
  442. } else {
  443. // Catch negatives
  444. bool neg_min = min < 0.0f ? true : false;
  445. bool neg_max = max < 0.0f ? true : false;
  446. if (!neg_min && !neg_max) {
  447. Default = exp(::log(min) * lp + ::log(max) * up);
  448. } else if (neg_min && neg_max) {
  449. Default = -exp(::log(-min) * lp + ::log(-max) * up);
  450. } else {
  451. // Logarithmic range has asymptote
  452. // so just use linear scale
  453. Default = min * lp + max * up;
  454. }
  455. }
  456. } else {
  457. Default = min * lp + max * up;
  458. }
  459. }
  460. if (LADSPA_IS_HINT_SAMPLE_RATE(HintDesc)) {
  461. Default *= Engine::sample_rate();
  462. }
  463. if (LADSPA_IS_HINT_INTEGER(HintDesc)) {
  464. if ( p.hints.ranged &&
  465. 0 == p.hints.minimum &&
  466. 1 == p.hints.maximum )
  467. p.hints.type = Port::Hints::BOOLEAN;
  468. else
  469. p.hints.type = Port::Hints::INTEGER;
  470. Default = floorf(Default);
  471. }
  472. if (LADSPA_IS_HINT_TOGGLED(HintDesc)){
  473. p.hints.type = Port::Hints::BOOLEAN;
  474. }
  475. }
  476. }
  477. #else
  478. Default = 0.0f;
  479. #endif
  480. p.hints.default_value = Default;
  481. }
  482. float *control_value = new float;
  483. *control_value = p.hints.default_value;
  484. p.connect_to( control_value );
  485. add_port( p );
  486. DMESSAGE( "Plugin has control port \"%s\" (default: %f)", _idata->descriptor->PortNames[ i ], p.hints.default_value );
  487. }
  488. }
  489. }
  490. else
  491. {
  492. WARNING( "Failed to load plugin" );
  493. return false;
  494. }
  495. int instances = plugin_instances( 1 );
  496. if ( instances )
  497. {
  498. bypass( false );
  499. }
  500. return instances;
  501. }
  502. void
  503. Plugin_Module::set_input_buffer ( int n, void *buf )
  504. {
  505. LADSPA_Handle h;
  506. if ( instances() > 1 )
  507. {
  508. h = _idata->handle[n];
  509. n = 0;
  510. }
  511. else
  512. h = _idata->handle[0];
  513. for ( unsigned int i = 0; i < _idata->descriptor->PortCount; ++i )
  514. if ( LADSPA_IS_PORT_INPUT( _idata->descriptor->PortDescriptors[i] ) &&
  515. LADSPA_IS_PORT_AUDIO( _idata->descriptor->PortDescriptors[i] ) )
  516. if ( n-- == 0 )
  517. _idata->descriptor->connect_port( h, i, (LADSPA_Data*)buf );
  518. }
  519. bool
  520. Plugin_Module::loaded ( void ) const
  521. {
  522. return _idata->descriptor;
  523. }
  524. void
  525. Plugin_Module::set_output_buffer ( int n, void *buf )
  526. {
  527. LADSPA_Handle h;
  528. if ( instances() > 1 )
  529. {
  530. h = _idata->handle[n];
  531. n = 0;
  532. }
  533. else
  534. h = _idata->handle[0];
  535. for ( unsigned int i = 0; i < _idata->descriptor->PortCount; ++i )
  536. if ( LADSPA_IS_PORT_OUTPUT( _idata->descriptor->PortDescriptors[i] ) &&
  537. LADSPA_IS_PORT_AUDIO( _idata->descriptor->PortDescriptors[i] ) )
  538. if ( n-- == 0 )
  539. _idata->descriptor->connect_port( h, i, (LADSPA_Data*)buf );
  540. }
  541. void
  542. Plugin_Module::activate ( void )
  543. {
  544. if ( !loaded() )
  545. return;
  546. DMESSAGE( "Activating plugin \"%s\"", label() );
  547. if ( !bypass() )
  548. FATAL( "Attempt to activate already active plugin" );
  549. if ( chain() )
  550. chain()->engine()->lock();
  551. if ( _idata->descriptor->activate )
  552. for ( unsigned int i = 0; i < _idata->handle.size(); ++i )
  553. _idata->descriptor->activate( _idata->handle[i] );
  554. _bypass = false;
  555. if ( chain() )
  556. chain()->engine()->unlock();
  557. }
  558. void
  559. Plugin_Module::deactivate( void )
  560. {
  561. if ( !loaded() )
  562. return;
  563. DMESSAGE( "Deactivating plugin \"%s\"", label() );
  564. if ( chain() )
  565. chain()->engine()->lock();
  566. _bypass = true;
  567. if ( _idata->descriptor->deactivate )
  568. for ( unsigned int i = 0; i < _idata->handle.size(); ++i )
  569. _idata->descriptor->deactivate( _idata->handle[i] );
  570. if ( chain() )
  571. chain()->engine()->unlock();
  572. }
  573. void
  574. Plugin_Module::handle_port_connection_change ( void )
  575. {
  576. // DMESSAGE( "Connecting audio ports" );
  577. if ( loaded() )
  578. {
  579. if ( _crosswire )
  580. {
  581. for ( int i = 0; i < plugin_ins(); ++i )
  582. set_input_buffer( i, audio_input[0].buffer() );
  583. }
  584. else
  585. {
  586. for ( unsigned int i = 0; i < audio_input.size(); ++i )
  587. set_input_buffer( i, audio_input[i].buffer() );
  588. }
  589. for ( unsigned int i = 0; i < audio_output.size(); ++i )
  590. set_output_buffer( i, audio_output[i].buffer() );
  591. }
  592. }
  593. /**********/
  594. /* Engine */
  595. /**********/
  596. void
  597. Plugin_Module::process ( nframes_t nframes )
  598. {
  599. handle_port_connection_change();
  600. if ( !bypass() )
  601. {
  602. for ( unsigned int i = 0; i < _idata->handle.size(); ++i )
  603. _idata->descriptor->run( _idata->handle[i], nframes );
  604. }
  605. else
  606. {
  607. /* If this is a mono to stereo plugin, then duplicate the input channel... */
  608. /* There's not much we can do to automatically support other configurations. */
  609. if ( ninputs() == 1 && noutputs() == 2 )
  610. {
  611. buffer_copy( (sample_t*)audio_output[1].buffer(), (sample_t*)audio_input[0].buffer(), nframes );
  612. }
  613. }
  614. }