Search
Categories
Documents
Audio::LADSPA::Plugin.pod (Audio::LADPSA::Plugin - Use ladpsa plugins from perl)
Audio::LADPSA::Plugin - Use ladpsa plugins from perl
use Audio::LADSPA;
my (@plugin_classes) = Audio::LADPSA->plugins();
# or ...
my $plugin_class = Audio::LADSPA->plugin( label => "delay_5s", id => 1043);
my $plugin = $plugin_class->new($sample_rate);
Audio::LADSPA::Plugin is a base class for LADSPA plugins. Default behaviour of the Audio::LADPSA
module is to generate a subclass for each plugin found in LADSPA_PATH, using the
Audio::LADSPA::LibraryLoader module.
You can use the Audio::LADSPA::Plugin classes to query the capabilities of the loaded plugin, and
you can instantiate new objects from them to do some actual audio processing.
A list of all available classnames on your system can be retrieved from Audio::LADSPA->plugins(), or you can
get one by label and / or id via Audio::LADSPA->plugin( %ARGS ).
These methods can all be used as class methods as well as object methods, So you can query plugins
without creating a new instance, or query an object you've already created.
my $id = $plugin_class->id();
Returns the unique id of the plugin class, as reported by the plugin itself.
my $label = $plugin_class->label();
The short name of the plugin.
my $name = $plugin_class->name();
A more descriptive name of the plugin.
my $maker = $plugin_class->maker();
The author of the plugin.
my $copy = $plugin_class->copyright();
The copyright message for the plugin.
my $num_ports = $plugin_class->port_count();
The number of input / output / audio / control ports for the plugin, added together.
if ($plugin_class->is_realtime()) {
warn "This plugin uses realtime input";
}
From the LADSPA SDK:
``Indicates that the plugin has a real-time dependency (e.g. listens to a MIDI device)
and so its output must not be cached or subject to significant latency.''
The Audio::LADSPA environment might not be fast enough for these kinds of plugins though.
Report back to me if you can get it to do something interesting in real time.
if ($plugin->is_inplace_broken()) {
# connect plugin to seperate output buffer
}
else {
# connect plugin to shared output buffer
}
Returns true if the plugin doesn't use the C<run_adding()> method, so you should not
connect it need to a shared buffer. See L<run_adding> for more info.
if ($plugin->is_hard_rt_capable) {
# do something in realtime
}
Returns true if the plugin can be run in a realtime environment. Whether the Audio::LADSPA
host is a realtime environment, probably depends on you hardware and the complexity of your
plugin network. Let me know.
Returns true if the plugin has a run() method.
Returns true if the plugin has a run_adding() method.
Returns true if the plugin has an activate() method.
Returns true if the plugin has an deactivate() method.
my @ports = $plugin->ports();
Returns the names of all input/output ports for this plugin, ordered by port index.
my $port = $plugin->port($index);
Returns the name of an input/output port for the plugin given its index.
my $plugin_object = $plugin_class->new($sample_rate);
# now do something interesting involving audio
Create a new plugin object of $plugin_class and set its sample rate to $sample_rate. Usually you will want
to set all connected plugins to the same sample rate. Audio::LADSPA::Network objects
will do this automatically for you.
The following methods involve connections to buffers, handling audio data etc.
$plugin->connect( $port => $buffer);
Connects the $port to the Audio::LADSPA::Buffer $buffer. Returns true on success, false otherwise.
If the $plugin is part of an Audio::LADSPA::Network, use $network-connect() instead >>>>.
See also connect in the Audio::LADPSA::Network manpage and the cb_connect manpage.
$plugin->disconnect( $port );
Disconnect a $port.
See also cb_disconnect.
my $buffer = $plugin->get_buffer( $port );
Returns the buffer connected to the specified port. Returns undef if not connected.
$plugin->set( $port => @values );
# eg..
$drum->set( Velocity => 10 );
$echo->set( Input => 1, 1, 0, 0, -1, -1, 0, 0 );
Set the Audio::LADSPA::Buffer connected to the $port.
See set in the Audio::LADSPA::Buffer manpage.
my @values = $plugin->get( $port );
my $value = $plugin->get( $port );
# eg
@output = $sine_fcac->get('Output');
Get the data from the Audio::LADSPA::Buffer connected to the $port.
See get in the Audio::LADSPA::Buffer manpage.
$plugin->activate();
Signal that the plugin should get ready to run. Is called automatically when run or run_adding
is called and the plugin is not active. Is ignored after the first call, except when deactivate() is
called.
$plugin->deactivate();
Signal that the plugin can stop. Calling deactivate() and then activate() should reset the plugin.
$plugin->run($num_samples);
Run the plugin for $num_samples samples. All ports should be connected to a buffer, and activate is
called automatically if the plugin isn't active already.
Usually $plugin will read from all buffers connected to its input ports and write to all buffers connected to
its output ports.
$plugin->run_adding($num_samples);
Same as run() except that the plugin will add its output to the buffers connected to its output ports,
instead of overwriting them. Use $plugin->has_run_adding() to check whether the plugin supports this
mode.
$plugin->run_adding_gain($gain);
Set the output gain for the run_adding() method. Will throw an exception if the plugin has no run_adding() method. Check $plugin->has_run_adding().
To ease the creation of 'container' objects for Audio::LADSPA::Plugins, you can register a
'monitor' object that will recieve callbacks whenever certain methods are called on the plugin.
Please note that the monitor object should be kept in scope by the container; the reference counting
for the $monitor object is NOT increased by calling $plugin->set_monitor($monitor). This is
intentional; it allows the container to be the monitor, while still being DESTROYED when
going out of scope (this means you don't have to worry about this when the container is the monitor;
the Perl garbage collector will work as you would expect it to). See the Audio::LASDPA::Network manpage for
an implementation.
$plugin->set_monitor($monitor);
Sets the $monitor object for $plugin. Use $plugin->set_monitor(undef) to remove a monitor object.
my $monitor = $plugin->monitor();
Returns the $monitor object for $plugin, or undef if there is no monitor set.
In general, the callback methods will be called when the corresponing event is called, before
any processing of the event is done. Some callback methods can return true or false indicating
that the event should be processed or not. When a plugin has no monitor, or the callback is
not implemented, the event is processed (the plugin acts as if the callback returned true).
The monitor object may implement the following methods:
$monitor->cb_connect( $plugin, $port, $buffer );
Will be called when $plugin->connect($port, $buffer) is called. If cb_connect returns
false, the connection will not be made.
$monitor->cb_disconnect( $plugin, $port );
Will be called when $plugin->disconnect($port) is called.
the Audio::LADSPA manpage, the Audio::LASDPA::Plugin::XS manpage, the Audio::LADSPA::Plugin::Perl manpage.
Copyright (C) 2003 Joost Diepenmaat <joost AT hortus-mechanicus.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Information
|
This site is currently in testing, it is not yet operating using the full database. Until it is officially launched you may wish to visit Help-Site Computer Manuals. After launch, this site (HelpSpy) will replace Help-Site. Information about the spider which is currently trawling the Internet looking for links to add to this directory can be found here. |
|