English     Español
[Main Index] : Programming : Languages : Perl : CPAN Modules : Miscellaneous Modules : Audio : Audio::LADSPA
 Audio::LADSPA::Network 

Search

 

Documents

Audio::LADSPA::Network - Semi automatic connection of Audio::LADSPA::* objects (Displayed)

Audio::LADSPA::Network - Semi automatic connection of Audio::LADSPA::* objects



NAME

Audio::LADSPA::Network - Semi automatic connection of Audio::LADSPA::* objects


SYNOPSIS

    use Audio::LADSPA::Network;
    use Audio::LADSPA::Plugin::Play;
    my $net = Audio::LADSPA::Network->new();
    my $sine = $net->add_plugin( label => 'sine_fcac' );
    my $delay = $net->add_plugin( label => 'delay_5s' );
    my $play = $net->add_plugin('Audio::LADSPA::Plugin::Play');
    $net->connect($sine,'Output',$delay,'Input');
    $net->connect($delay,'Output',$play,'Input');
    
    $sine->set('Frequency (Hz)' => 440); # set freq
    $sine->set(Amplitude => 1);   # set amp
    $delay->set('Delay (Seconds)' => 1); # 1 sec delay
    $delay->set('Dry/Wet Balance' => 0.2); # balance - 0.2
    for ( 0 .. 100 ) {
        $net->run(100);
    }
    $sine->set(Amplitude => 0); #just delay from now
    for ( 0 .. 500 ) {
        $net->run(100);
    }


DESCRIPTION

This module makes it easier to create connecting Audio::LADSPA::Plugin objects. It automatically keeps the sampling frequencies correct for all plugins, adds control and audio buffers to unconnected plugins, detects illegal connections etc.


CLASS METHODS

new

 my $network = Audio::LADSPA::Network->new( 
    sample_rate => $sample_rate, 
    buffer_size => $buffer_size 
 );

Construct a new Audio::LADSPA::Network. The sample_rate and buffer_size arguments may be omitted. The default sample_rate is 44100, the default buffer_size is 1024.


OBJECT METHODS

add_plugin

 my $plugin = $network->add_plugin( EXPR );

Adds a $plugin to the $network. All unconnected ports will be connected to new Audio::LADSPA::Buffers. Control buffers will be initalized with the correct default value for the port.

EXPR can be an Audio::LADSPA::Plugin object, an Audio::LADSPA::Plugin classname or any expression supported by Audio::LADSPA-plugin()>.

Any $plugin added to a $network will have its monitor set to that $network. This means that a $plugin cannot be in more than 1 Audio::LADSPA::Network at any given time, and that all callbacks from the $plugin are handled by the $network.

See also SETTING CALLBACKS in the Audio::LADSPA::Plugin manpage.

has_plugin

 if ($network->has_plugin($plugin)) {
     # something interesting...
 }

Check if a given $plugin object exists in the $network. $plugin must be an Audio::LADSPA::Plugin object.

plugins

 my @plugins = $network->plugins();

Returns all @plugins in the $network in topological order - this means that the plugins will be sorted so that if $plugin2 recieves input from $plugin1, $plugin1 will be before $plugin2 in the @plugins list.

Because the topological sorting is expensive (that is, for semi-realtime audio generation), the result of this operation is cached as long as the network does not change.

add_buffer

 my $buffer = $network->add_buffer( EXPR );

Add a $buffer to the $network. EXPR may be an Audio::LADSPA::Buffer object, or an integer specifying the $buffer's size.

This method is usually not needed by users of the module, as the connect() and add_plugin() methods take care of creating new buffers for you. Also note that buffers not immediately connected to a plugin will be removed when the network changes in any other way.

has_buffer

 if ($network->has_buffer($buffer)) {
   # ...
 }

Returns true if the $buffer is already in the $network.

buffers

 my @buffers = $network->buffers();

Returns all the $buffers in the $network.

connect

 unless ($network->connect( $plugin1, $port1, $plugin2, $port2 )) {
     warn "Connection failed";
 }

Connect $port1 of $plugin1 with $port2 of $plugin2. Plugins are added to the network and new buffers are created if needed.

This method will only connect input ports to output ports, which must both be of the same type (audio or control). The order in which the plugins are specified does not matter.

Returns true on success, false on failure.

You are advised to use this method instead of $plugin-connect( $buffer ) >>. Some of the magic in this method also works for $plugin->connect(), if the plugin is already added to the network, but that might change if the implementation changes. YMMV. $plugin->disconnect($port) works, and will stay working, though.

run

 $network->run( $number_of_samples );

Call $plugin->run( $number_of_samples ) on all plugins in the $network. Throws an exception when $number_of_samples is higher than the $buffer_size specified at the constructor.


SEE ALSO

the Audio::LADSPA manpage, the Graph::Base manpage


COPYRIGHT AND LICENSE

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.
   

©Copyright Nicholas Reynolds 2004