Audio-Ecasound-1.01/0000755000175000017500000000000011416477520012340 5ustar bsbbsbAudio-Ecasound-1.01/META.yml0000644000175000017500000000107211416477520013611 0ustar bsbbsb--- #YAML:1.0 name: Audio-Ecasound version: 1.01 abstract: Perl binding to the ecasound sampler, recorder, fx-processor author: - Brad Bowman license: artistic_2 distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: {} no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.56 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Audio-Ecasound-1.01/README0000644000175000017500000002236711416477520013232 0ustar bsbbsbNAME Audio::Ecasound - Perl binding to the ecasound sampler, recorder, fx-processor SYNOPSIS One function interface: use Audio::Ecasound qw(:simple); eci("cs-add play_chainsetup"); eci("c-add 1st_chain"); eci("-i:some_file.wav"); eci("-o:/dev/dsp"); # multiple \n separated commands eci("cop-add -efl:100 # with comments cop-select 1 copp-select 1 cs-connect"); eci("start"); my $cutoff_inc = 500.0; while (1) { sleep(1); last if eci("engine-status") ne "running"; my $curpos = eci("get-position"); last if $curpos > 15; my $next_cutoff = $cutoff_inc + eci("copp-get"); # Optional float argument eci("copp-set", $next_cutoff); } eci("stop"); eci("cs-disconnect"); print "Chain operator status: ", eci("cop-status"); Object Interface use Audio::Ecasound; my $e = new Audio::Ecasound; $e->on_error(''); $e->eci("cs-add play_chainsetup"); # etc. Vanilla Ecasound Control Interface (See Ecasound's Programmer Guide): use Audio::Ecasound qw(:std); command("copp-get"); $precise_float = last_float() / 2; command_float_arg("copp-set", $precise_float); warn last_error() if error(); IAM Interface, pretend interactive mode commands are functions. use Audio::Ecasound qw(:iam :simple); # iam commands as functions with s/-/_/g my $val = copp_get; copp_set $val+0.1; # floats are stringified so beware eci("-i /dev/dsp"); # not all commands are exported DESCRIPTION Audio::Ecasound provides perl bindings to the ecasound control interface of the ecasound program. You can use perl to automate or interact with ecasound so you don't have to turn you back on the adoring masses packed into Wembly Stadium. Ecasound is a software package designed for multitrack audio processing. It can be used for audio playback, recording, format conversions, effects processing, mixing, as a LADSPA plugin host and JACK node. Version >= 2.2.X must be installed to use this package. "SEE ALSO" for more info. INSTALLATION perl Makefile.PL If your perl wasn't built with -Dusethreads or -D_REENTRANT you will be prompted whether to continue with the install. It's in your hands... See "THREADING NOTE" make make test make install THREADING NOTE The ecasoundc library uses pthreads so will may only work if your perl was compiled with threading enabled, check with: % perl -V:usethreads You are welcome to try using the module with non-threaded perls (perhaps -D_REENTRANT alone would work) it have worked for some. EXPORT * Nothing by default as when going OO. * :simple gives eci() which does most everything, also errmsg and on_error. Or you could just import 'eci' and call the others "Audio::Ecasound::errmsg()" * :iam imports many iam commands so that you can use them as perl functions. Basically everything listed by ecasound's 'int-cmd-list' except the single letter commands and hyphens are replaced by underscores. The list is produced at run-time and returned by Audio::Ecasound::get_iam_cmds(). See "IAM COMMANDS"; * :std to import the full ecasound control interface detailed in the Ecasound Programmer's Guide. * :raw and raw_r, C functions with minimal wrapping, _r ones are reentrant and must be passed the object returned by eci_init_r(). I don't know why you would use these, presumably you do. These options may be removed in future. METHODS AND FUNCTIONS The procedural and OO interfaces use the same functions, the differences are that when called on an Audio::Ecasound object the reentrant C versions are used so you can have multiple independent engine (with independent options). new() Constructor for Audio::Ecasound objects, inherits the on_error and other options from the current package settings (defaults if untouched). eci('ecasound command string', [$float_argument]) Sends commands to the Ecasound engine. A single command may be called with an optional float argument (to avoid precision loss). Alternatively, multiple commands may be given separated by newlines (with "#" starting a comment). If called in non-void context the result of the last command is returned, it may be an integer, float, string (ie. scalar) or a list of strings. Which will depend on the ecasound command, see ecasound-iam for each function's return value. If there is an error the action given to on_error will be taken. See on_error below for return value caveats when on_error = ''. Error processing is performed for each command in a multiline command. on_error('die') Set the action to be taken when an error occurs from and "eci" command, may be 'die', 'warn', '', 'confess', ... (default is 'warn'). When '' is selected "return;" is used for an error, that is undef or (). To disamibiguate eci will return '' or ('') for no return value and no string list respectively. errmsg() The last error message from an "eci" command. It is not reset so clear it yourself if required "errmsg('')". This shouldn't be necessary as you can use "defined" or on_error to find out when errors occur. The remainder of the functions/methods are the standard Ecasound Control Interface methods but they come in three flavours. The bare function name may be called with or without an object: use Audio::Ecasound ':simple': command($cmd); # or my $e = new Audio::Ecasound; $e = command($cmd); The other two flavours are low-level, reentrant and non-reentrant. These are thinly wrapped C functions better documented in the ECI document with the ecasound distribution. Just add 'eci_' to the names below for the non-reentrant version and then add a '_r' to the end for the reentrant version. The reentrant version takes an extra first argument, the object returned by eci_init_r() which must be destroyed with eci_cleanup_r(). command($cmd_string) eci_command_float_arg($cmd_string, $float_arg) $bool = eci_error() $err_str = eci_last_error() $float = eci_last_float() $int = eci_last_integer() $lint = eci_last_long_integer() $str = eci_last_string() $n = eci_last_string_list_count() $str_n = eci_last_string_list_item($n) $type_str = eci_last_type() 's' 'S' 'i' 'li' 'f' '' IAM COMMANDS When the :iam tag is imported most of the commands in ecasounds interactive mode become perl functions. The '-'s become '_'s to become valid perl names ('cop-get' is cop_get, etc.) The list is printed with: use Audio::Ecasound qw(:iam :simple); print join ' ', Audio::Ecasound::get_iam_cmds(); The arguments joined together as a string and then sent to ecasound. This means that float precision is lost, unlike with the two argument "eci" so use it. Also use "eci" for command-line style commands like "eci "-i /dev/dsp"". But most other things you can just use the iam command itself (s/-/_/g): use Audio::Ecasound qw(:iam :simple); ... # setup stuff print status; start; $v = copp_get; copp_set $v + 1.2; I would never encourage anyone to use "no strict 'subs';" but with :iam you may enjoy a little less discipline. See the iam_int.pl example file in the eg directory. EXAMPLES See the "eg/" subdirectory. TROUBLESHOOTING The ecasound command 'debug' could be useful, add "eci "debug 63"" to the top of your program. The argument is various bits OR'd and controls the amount and type of debugging information, see the ecasound documentation of source or just try your favorite powers of two. FILES AND ENVIRONMENT The libecasoundc library now uses the environment variable "ECASOUND" to find the ecasound executable. If it is not set then the libarary will print a warning. To suppress it, simply set the ECASOUND variable: eg. export ECASOUND=ecasound The ecasound library will still process ~/.ecasoundrc and other setup files for default values. See the library documentation. AUTHOR Copyright (C) 2001, Brad Bowman LICENSE This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. SEE ALSO The Ecasound Programmer's Guide and ECI doc, ecasound, ecasound-iam http://eca.cx/, http://www.ladspa.org/ The internals of libecasoundc have been rebuilt and now interact with a running ecasound via a socket using a protocol defined in the Programmer's Guide. The C library is now just a compatibility layer and the Python version now talks directly to the socket. It would be straight forward to write an equivalent Perl version should the need arise. Audio-Ecasound-1.01/MANIFEST0000644000175000017500000000023411416477520013470 0ustar bsbbsbChanges Ecasound.pm Ecasound.xs eg/iam_int.pl eg/oo_int.pl eg/raw_int.pl eg/simple_int.pl Makefile.PL MANIFEST META.yml README t/ecasound.t t/pod.t typemap Audio-Ecasound-1.01/Makefile.PL0000644000175000017500000000610111416477520014310 0ustar bsbbsbuse ExtUtils::MakeMaker; $| = 1; WriteMakefile( NAME => 'Audio::Ecasound', VERSION_FROM => 'Ecasound.pm', PREREQ_PM => {}, # e.g., Module::Name => 1.1 # next two could be from libecasoundc-config --libs --cflags # not for now since want it to install w/o libecasoundc-config LIBS => ['-lecasoundc'], INC => '', ABSTRACT_FROM => 'Ecasound.pm', AUTHOR => 'Brad Bowman ', LICENSE => 'artistic_2', dist => { # expand my tabs to 4 PREOP => "(cd \$(DISTVNAME); \\ perl -MExtUtils::Manifest=maniread \\ -pi -e 'BEGIN{\@ARGV=keys \%{maniread()}; } \\ s/\\t/ /g' \\ )" }, CONFIGURE => sub { my %cfg; use Config; unless ($Config{usethreads} eq 'define' || $Config{ccflags} =~ /\b-D_REENTRANT\b/) { prompt_cont(< 2 & rest >= 4.5 unless($ev[0] >2 || ($ev[0] == 2 && "$ev[1].$ev[2]" >= '4.5')) { prompt_cont(<= $Config{longsize}) { warn "long int is bigger than IV, may cause problems with last_long_interger\n"; } return \%cfg; }, ); sub prompt_cont { my ($message, $default) = @_; local $_; chomp($message); # because prompt() adds "[y]\n" while (1) { $_ = prompt($message, $default); if(/^n/i) { print "Aborting\n"; exit; } if(/^y/i) { print "Continuing\n"; last; } } } Audio-Ecasound-1.01/Changes0000644000175000017500000000302611416477520013634 0ustar bsbbsbRevision history for Perl extension Audio::Ecasound. 1.01 Mon Jul 12 12:18:04 EST 2010 - Clarify license for Debian packaging (Thanks Joel Roth http://github.com/bolangi) 0.93 Sun Jan 6 15:30:02 EST 2008 - RT #32101: missing flush to STDOUT from Andreas Koenig $| is Makefile.PL and use MM's prompt instead of custom 0.92 Sun Dec 16 14:15:44 EST 2007 - Update email address - 'todo' test done, shush test warning - Require ecasound 2.4.5, document bugs around 2.4.4 http://www.eca.cx/ecasound-list/2006/06/0004.html http://www.eca.cx/ecasound-list/2006/12/0007.html 0.91 Tue May 30 22:40:23 EST 2006 - Fixup pattern for tests on chainsetup error messages (Joel Roth http://ecmdr.infogami.com) - Move test.pl to t/ecasound.t - Add t/pod.t for Kwalitee 0.9 Sun Aug 10 16:38:10 EST 2003 - Use UNIVERSAL::isa for self test (more robust) - Updated eg/* for new cop-status - on_error with Carp::* + docs - Use libecasoundc-config (renamed in ecasound) - Fix lib dir in Ecasound.xs (change in ecasound) - Makefile.PL requires ecasound 2.2 for above - Remove -lkvutils, not required - Thread warning updated from feedback - Update/Fix tests for new return formats and codes - Warn and document ECASOUND re: env var 0.2 Tue Jun 26 01:28:01 EST 2001 - Public debut, Changes file becomes relevant 0.01 Mon May 21 14:39:57 2001 - original version; created by h2xs 1.20 with options -A -x -p eci_ -n ECI ecasound/ecasoundc.h -lecasoundc Audio-Ecasound-1.01/t/0000755000175000017500000000000011416477520012603 5ustar bsbbsbAudio-Ecasound-1.01/t/ecasound.t0000644000175000017500000000553311416477520014577 0ustar bsbbsb use Test; BEGIN { $| = 1; plan tests => 46 } END { ok(0) unless $loaded;} use Audio::Ecasound qw(:simple :std :raw :raw_r :iam); $loaded = 1; ok(1); use strict; # die, warn, '' # raw, raw_r, simple, oo # float arg # last_types # raw interface eci_command('cs-add c1'); eci_command('cs-selected'); ok eci_last_type() => 's'; ok eci_last_string() => 'c1'; eci_command('cs-is-valid'); ok eci_last_type() => 'i'; ok eci_last_integer() => 0; eci_command('cs-list'); ok eci_last_type() => 'S'; my $n = eci_last_string_list_count(); ok $n >= 1; # gets 1 or 2 ok ((eci_last_string_list_item($n-1))[0] => 'c1'); eci_command('cs-get-length'); ok eci_last_type() => 'f'; ok eci_last_float() => 0; eci_command_float_arg('cs-set-length', 2.0); ok eci_last_type() => '-'; # once was '' eci_command('start'); ok eci_error() => 1; ok eci_last_error() => qr/chainsetup cannot be connected|No chainsetup connected/i; ok eci_last_type() => 'e'; # raw_r interface (test 14) # call with wrong $obj eval { no warnings 'uninitialized'; eci_command_r(undef,'status'); }; ok $@ => qr/not of type eci_handle_t/; my $eh = eci_init_r(); ok ref($eh) => 'eci_handle_t'; eci_command_r($eh,'status'); ok eci_last_type_r($eh) => 's'; ok eci_last_string_r($eh) => qr/Chainsetup status/i; eci_cleanup_r($eh); # simple (test 18) ok eci('status') => qr/Chainsetup status/i; ok on_error() => 'warn'; # default val ok on_error('') => ''; ok !defined(eci('start')); # error ok errmsg() => qr/chainsetup cannot be connected|No chainsetup connected/i; ok errmsg('') => ''; eci('cs-set-length'); ok errmsg() => qr/argument omitted/; eci('cs-set-length', 4.0); ok eci('cs-get-length') => 4; # 4.000? ok on_error('confess') => 'confess'; eval { eci('asyntaxerror'); }; ok $@ => qr/Unknown command/; ok errmsg() => qr/Unknown command/; ok on_error('die') => 'die'; eval { eci('asyntaxerror'); }; ok $@ => qr/Unknown command/; ok errmsg() => qr/Unknown command/; # OO interface (test 28) my $e = new Audio::Ecasound; ok ref($e) => 'Audio::Ecasound'; ok $e->on_error => 'die'; # set from class on_error('warn'); ok $e->on_error() => 'die'; # diverge from class $e->errmsg(''); eval { $e->eci('start') }; ok $@ => qr/chainsetup cannot be connected|No chainsetup connected/i; eval { $e->eci('cs-set-length'); }; ok $@ => qr/argument omitted/; ok $e->errmsg() => qr/argument omitted/; ok $e->eci('status') => qr/Chainsetup status/i; #changed $e->eci('cs-add c1'); $e->eci('cs-set-length', 5.0); ok $e->eci('cs-get-length') => 5; # comments added ok eci('status # a comment') => qr/Chainsetup status/i; #changed # multiline commands ok eci("cs-set-length 6 cs-get-length") => 6; # :iam tests on_error(''); ok((cs_set_length 7) => ''); ok((cs_get_length) => 7); # Second time shouldn't redefine ok((cs_get_length) => 7); eval { an_unknown_function(); }; ok $@ => qr/Undefined subroutine .*an_unknown_function called/; Audio-Ecasound-1.01/t/pod.t0000644000175000017500000000020111416477520013543 0ustar bsbbsbuse Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); Audio-Ecasound-1.01/Ecasound.pm0000644000175000017500000003656211416477520014453 0ustar bsbbsbpackage Audio::Ecasound; require 5.005_62; use Carp; use strict; use vars qw(@ISA @EXPORT %EXPORT_TAGS @EXPORT_OK $VERSION $AUTOLOAD); require Exporter; require DynaLoader; @ISA = qw(Exporter DynaLoader); # base names for methods (correspond to the C eci_X and eci_X_r versions) my @cmds = qw( command command_float_arg last_float last_integer last_long_integer last_string last_string_list_count last_string_list_item last_type error last_error ); %EXPORT_TAGS = ( simple => [qw( eci on_error errmsg )], std => [ @cmds ], raw => [ map { "eci_$_" } @cmds ], raw_r => [ qw(eci_init_r eci_cleanup_r), map { "eci_$_"."_r" } @cmds ], # NOTE the :iam tag is added dynamically in &import ); # NOTE :iam adds to this in &import @EXPORT_OK = ( map { @{$_} } @EXPORT_TAGS{'simple', 'std','raw','raw_r'} ); my %iam_cmds; sub get_iam_cmds { return keys %iam_cmds; } sub import { # When :iam is imported, the internal commands (len >=2) # are found with eci 'int-cmd-list' and declared # hyphens are converted to underscores to produce legal names if(grep { /^:iam$/ } @_) { my @iam_cmds = map { s/-/_/g; (/^\w{2,}$/)? $_ : () } eci('int-cmd-list'); $EXPORT_TAGS{iam} = [ @iam_cmds ]; push @EXPORT_OK, @iam_cmds; $iam_cmds{$_} = 1 for (@iam_cmds); } Audio::Ecasound->export_to_level(1,@_); } # AUTOLOAD to proxy iam commands as functions # defines iam commands as they are used sub AUTOLOAD { my $cmd = $AUTOLOAD; $cmd =~ s/.*:://; unless($iam_cmds{$cmd}) { # can't you pass? Just pretend by doing what perl would do croak "Undefined subroutine $AUTOLOAD called"; } no strict 'refs'; *$cmd = sub { $cmd =~ s/_/-/g; # eg cop_list => cop-list; eci(join ' ', $cmd, @_); }; goto &$cmd; } $VERSION = '1.01'; bootstrap Audio::Ecasound $VERSION; # Generate wrappers(OO or not-OO) for raw C functions for my $cmd (@cmds) { # eg. the 'command' sub is a perl wrapper which # calls 'eci_command' or 'eci_command_r' depending # on whether it's called as a method no strict 'refs'; *$cmd = sub { my $self = &_shift_self; if(ref $self) { # treat string as function name (symref), pass handle "eci_${cmd}_r"->($self->{eci_handle}, @_); } else { "eci_$cmd"->(@_); } }; } # Overriding DynaLoader's method so that .so symbols are # globally visible, hence ecasound-plugins (like libaudioio_af.so) # can link to them sub dl_load_flags { 0x01 } my %opts = ( on_error => 'warn', # 'die', '', 'cluck', 'confess' errmsg => '', ); # generate accessors for my $option (keys %opts) { no strict 'refs'; *$option = sub { my $self = &_shift_self; my $opts = \%opts; if(ref $self) { # use object's hash $opts = $self; } $opts->{$option} = shift if @_; return $opts->{$option}; }; } sub new { my $arg = shift; my $class = ref($arg) || $arg; my $self = { %opts }; # object gets current package values $self->{eci_handle} = eci_init_r(); bless $self, $class; } sub do_error { my $self = &_shift_self; my $errstr = shift; $self->errmsg($errstr); my $on_error = $self->on_error; no strict 'refs'; if($on_error eq 'die') { die "Audio::Ecasound::error: $errstr\n"; } elsif($on_error eq 'warn') { warn "Audio::Ecasound::error: $errstr\n"; } elsif(exists &{"Carp::$on_error"}) { &{"Carp::$on_error"}("Audio::Ecasound::error: $errstr\n"); } elsif($on_error) { die "Audio::Ecasound::error: $errstr\n" ."(And on_error=$on_error is bad)\n"; } return; } # do everything in one function sub eci { my $self = &_shift_self; my $cmdstr = shift; if(@_) { my $float = shift; $self->command_float_arg($cmdstr, $float); $cmdstr .= ' ' . $float; # Handle an eci error if($self->error()) { my $errstr = $self->last_error() . "(in $cmdstr)"; return $self->do_error($errstr); } } else { # multiline commands for my $mcmdstr (split /\n/, $cmdstr) { # Comments $mcmdstr =~ s/#.*//; $mcmdstr =~ s/^\s+//; $mcmdstr =~ s/\s+$//; # Skip blanks next if $mcmdstr =~ /^$/; $self->command($mcmdstr); # Handle an eci error ( would be 'e' return code ) if($self->error()) { my $errstr = $self->last_error() . "(in $mcmdstr)"; return $self->do_error($errstr); } } } # do return value return unless defined wantarray; my $ret; my $type = $self->last_type(); if($type eq 'i') { return $self->last_integer(); } elsif($type eq 'f') { return $self->last_float(); } elsif($type eq 's') { return $self->last_string(); } elsif($type eq 'li') { return $self->last_long_integer(); } elsif($type eq '' || $type eq '-') { # - from python return ''; # false but defined } elsif($type eq 'S') { my $count = $self->last_string_list_count(); # differentiate from () err when ambiguous return ('') unless ($count && $self->on_error); my @ret; for my $n (0..$count-1) { push @ret, $self->last_string_list_item($n); } return @ret; } elsif($type eq 'e') { # should be handled above... my $errstr = $self->last_error() . "(in $cmdstr)"; return $self->do_error($errstr); } else { die "last_type() returned unexpected type <$type>"; } } # Look at first argument and return something that # can be used as an object, either a blessed ref # a class name which isa A::E or the string # 'Audio::Ecasound' (can be used 'Audio::Ecasound'->eci($c)) # NOTE: should be called &_shift_self to shift @_ for parent; sub _shift_self { if(!defined $_[0]) { return __PACKAGE__; } elsif(ref $_[0]) { return shift; } elsif ( $_[0] =~ /^[_a-zA-Z][\w:']*$/ # Common package names && UNIVERSAL::isa($_[0],__PACKAGE__) ) { #&& $_[0]->isa(__PACKAGE__) ) { return shift; } else { return __PACKAGE__; } } DESTROY { my $self = shift; eci_cleanup_r($self->{eci_handle}); } END { # Partner eci_init in XS BOOT: eci_cleanup(); } 1; __END__ =head1 NAME Audio::Ecasound - Perl binding to the ecasound sampler, recorder, fx-processor =head1 SYNOPSIS One function interface: use Audio::Ecasound qw(:simple); eci("cs-add play_chainsetup"); eci("c-add 1st_chain"); eci("-i:some_file.wav"); eci("-o:/dev/dsp"); # multiple \n separated commands eci("cop-add -efl:100 # with comments cop-select 1 copp-select 1 cs-connect"); eci("start"); my $cutoff_inc = 500.0; while (1) { sleep(1); last if eci("engine-status") ne "running"; my $curpos = eci("get-position"); last if $curpos > 15; my $next_cutoff = $cutoff_inc + eci("copp-get"); # Optional float argument eci("copp-set", $next_cutoff); } eci("stop"); eci("cs-disconnect"); print "Chain operator status: ", eci("cop-status"); Object Interface use Audio::Ecasound; my $e = new Audio::Ecasound; $e->on_error(''); $e->eci("cs-add play_chainsetup"); # etc. Vanilla Ecasound Control Interface (See Ecasound's Programmer Guide): use Audio::Ecasound qw(:std); command("copp-get"); $precise_float = last_float() / 2; command_float_arg("copp-set", $precise_float); warn last_error() if error(); IAM Interface, pretend interactive mode commands are functions. use Audio::Ecasound qw(:iam :simple); # iam commands as functions with s/-/_/g my $val = copp_get; copp_set $val+0.1; # floats are stringified so beware eci("-i /dev/dsp"); # not all commands are exported =head1 DESCRIPTION Audio::Ecasound provides perl bindings to the ecasound control interface of the ecasound program. You can use perl to automate or interact with ecasound so you don't have to turn you back on the adoring masses packed into Wembly Stadium. Ecasound is a software package designed for multitrack audio processing. It can be used for audio playback, recording, format conversions, effects processing, mixing, as a LADSPA plugin host and JACK node. Version E= 2.2.X must be installed to use this package. L for more info. =head1 INSTALLATION perl Makefile.PL If your perl wasn't built with -Dusethreads or -D_REENTRANT you will be prompted whether to continue with the install. It's in your hands... See L make make test make install =head1 THREADING NOTE The ecasoundc library uses pthreads so will may only work if your perl was compiled with threading enabled, check with: % perl -V:usethreads You are welcome to try using the module with non-threaded perls (perhaps -D_REENTRANT alone would work) it have worked for some. =head1 EXPORT =over 4 =item * Nothing by default as when going OO. =item * :simple gives eci() which does most everything, also errmsg and on_error. Or you could just import 'eci' and call the others C =item * :iam imports many iam commands so that you can use them as perl functions. Basically everything listed by ecasound's 'int-cmd-list' except the single letter commands and hyphens are replaced by underscores. The list is produced at run-time and returned by Audio::Ecasound::get_iam_cmds(). See L; =item * :std to import the full ecasound control interface detailed in the Ecasound Programmer's Guide. =item * :raw and raw_r, C functions with minimal wrapping, _r ones are reentrant and must be passed the object returned by eci_init_r(). I don't know why you would use these, presumably you do. These options may be removed in future. =back =head1 METHODS AND FUNCTIONS The procedural and OO interfaces use the same functions, the differences are that when called on an Audio::Ecasound object the reentrant C versions are used so you can have multiple independent engine (with independent options). =over 2 =item B Constructor for Audio::Ecasound objects, inherits the on_error and other options from the current package settings (defaults if untouched). =item B Sends commands to the Ecasound engine. A single command may be called with an optional float argument (to avoid precision loss). Alternatively, multiple commands may be given separated by newlines (with C<#> starting a comment). If called in non-void context the result of the last command is returned, it may be an integer, float, string (ie. scalar) or a list of strings. Which will depend on the ecasound command, see L for each function's return value. If there is an error the action given to on_error will be taken. See on_error below for return value caveats when on_error = ''. Error processing is performed for each command in a multiline command. =item B Set the action to be taken when an error occurs from and C command, may be 'die', 'warn', '', 'confess', ... (default is 'warn'). When '' is selected C is used for an error, that is undef or (). To disamibiguate eci will return '' or ('') for no return value and no string list respectively. =item B The last error message from an C command. It is not reset so clear it yourself if required C. This shouldn't be necessary as you can use C or on_error to find out when errors occur. =back The remainder of the functions/methods are the standard Ecasound Control Interface methods but they come in three flavours. The bare function name may be called with or without an object: use Audio::Ecasound ':simple': command($cmd); # or my $e = new Audio::Ecasound; $e = command($cmd); The other two flavours are low-level, reentrant and non-reentrant. These are thinly wrapped C functions better documented in the ECI document with the ecasound distribution. Just add 'eci_' to the names below for the non-reentrant version and then add a '_r' to the end for the reentrant version. The reentrant version takes an extra first argument, the object returned by eci_init_r() which must be destroyed with eci_cleanup_r(). =over 4 =item B =item B =item B<$bool = eci_error()> =item B<$err_str = eci_last_error()> =item B<$float = eci_last_float()> =item B<$int = eci_last_integer()> =item B<$lint = eci_last_long_integer()> =item B<$str = eci_last_string()> =item B<$n = eci_last_string_list_count()> =item B<$str_n = eci_last_string_list_item($n)> =item B<$type_str = eci_last_type()> 's' 'S' 'i' 'li' 'f' '' =back =head1 IAM COMMANDS When the :iam tag is imported most of the commands in ecasounds interactive mode become perl functions. The '-'s become '_'s to become valid perl names ('cop-get' is cop_get, etc.) The list is printed with: use Audio::Ecasound qw(:iam :simple); print join ' ', Audio::Ecasound::get_iam_cmds(); The arguments joined together as a string and then sent to ecasound. This means that float precision is lost, unlike with the two argument C so use it. Also use C for command-line style commands like C. But most other things you can just use the iam command itself (s/-/_/g): use Audio::Ecasound qw(:iam :simple); ... # setup stuff print status; start; $v = copp_get; copp_set $v + 1.2; I would never encourage anyone to use C but with :iam you may enjoy a little less discipline. See the iam_int.pl example file in the eg directory. =head1 EXAMPLES See the C subdirectory. =head1 TROUBLESHOOTING The ecasound command 'debug' could be useful, add C to the top of your program. The argument is various bits OR'd and controls the amount and type of debugging information, see the ecasound documentation of source or just try your favorite powers of two. There was a bug effecting Audio::Ecasound with ecasound version 2.4.4, causing problems with :iam mode, and test failure ("Do you need to predeclare cs_set_length"). See L and L. =head1 FILES AND ENVIRONMENT The libecasoundc library now uses the environment variable "ECASOUND" to find the ecasound executable. If it is not set then the libarary will print a warning. To suppress it, simply set the ECASOUND variable: eg. export ECASOUND=ecaosund The ecasound library will still process ~/.ecasoundrc and other setup files for default values. See the library documentation. =head1 AUTHOR (c) 2001-2007 Brad Bowman Eeci-perl@bereft.netE This software may be distributed under the same terms as Perl itself. =head1 SEE ALSO The Ecasound Programmer's Guide and ECI doc, L, L http://eca.cx/, http://www.ladspa.org/ The internals of libecasoundc have been rebuilt and now interact with a running ecasound via a socket using a protocol defined in the Programmer's Guide. The C library is now just a compatibility layer and the Python version now talks directly to the socket. It would be straight forward to write an equivalent Perl version should the need arise. =cut Audio-Ecasound-1.01/Ecasound.xs0000644000175000017500000000255711416477520014466 0ustar bsbbsb#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include MODULE = Audio::Ecasound PACKAGE = Audio::Ecasound PROTOTYPES: ENABLE BOOT: eci_init(); void eci_cleanup() void eci_command(cmd) const char * cmd void eci_command_float_arg(arg0, arg) const char * arg0 double arg double eci_last_float() int eci_last_integer() long int eci_last_long_integer() const char * eci_last_string() int eci_last_string_list_count() const char * eci_last_string_list_item(n) int n const char * eci_last_type() int eci_error() const char * eci_last_error() eci_handle_t eci_init_r() void eci_cleanup_r(p) eci_handle_t p void eci_command_float_arg_r(p, arg1, arg) eci_handle_t p const char * arg1 double arg void eci_command_r(p, cmd) eci_handle_t p const char * cmd double eci_last_float_r(p) eci_handle_t p int eci_last_integer_r(p) eci_handle_t p long int eci_last_long_integer_r(p) eci_handle_t p int eci_last_string_list_count_r(p) eci_handle_t p const char * eci_last_string_list_item_r(p, n) eci_handle_t p int n const char * eci_last_string_r(p) eci_handle_t p const char * eci_last_type_r(p) eci_handle_t p int eci_error_r(p) eci_handle_t p const char * eci_last_error_r(p) eci_handle_t p Audio-Ecasound-1.01/eg/0000755000175000017500000000000011416477520012733 5ustar bsbbsbAudio-Ecasound-1.01/eg/iam_int.pl0000755000175000017500000000144411416477520014716 0ustar bsbbsb#!/usr/bin/perl -w use ExtUtils::testlib; use Audio::Ecasound qw(:simple :iam); use strict; # :iam is nicer without strict 'subs' no strict 'subs'; on_error(''); # no strict 'subs' lets you do this: cs_add play_chainsetup; c_add chain1; eci("-i:some_file.wav -o:/dev/dsp"); cop_add '-efl:100'; cop_select 1; copp_select 1; defined(cs_connect) or die "Setup error, you need 'some_file.wav' in the current directory\n\n" . errmsg(); on_error('die'); start; my $cutoff_inc = 500.0; while (1) { sleep(1); last if engine_status ne "running"; my $curpos = get_position; last if $curpos > 15; my $next_cutoff = $cutoff_inc + copp_get; # keep float precision eci("copp-set", $next_cutoff); } stop; cs_disconnect; print cop_status, "\n"; Audio-Ecasound-1.01/eg/simple_int.pl0000755000175000017500000000141111416477520015433 0ustar bsbbsb#!/usr/bin/perl -w use ExtUtils::testlib; use strict; use Audio::Ecasound qw(:simple); on_error(''); $_ = eci(" cs-add play_chainsetup c-add 1st_chain -i:some_file.wav -o:/dev/dsp cop-add -efl:100 cop-select 1 copp-select 1 cs-connect start "); if(!defined) { die "Setup error, you need 'some_file.wav' in the current directory\n\n" . errmsg(); } on_error('die'); my $cutoff_inc = 500.0; while (1) { sleep(1); last if eci("engine-status") ne "running"; my $curpos = eci("get-position"); last if $curpos > 15; my $next_cutoff = $cutoff_inc + eci("copp-get"); eci("copp-set", $next_cutoff); } eci("stop"); eci("cs-disconnect"); print eci("cop-status"), "\n"; Audio-Ecasound-1.01/eg/raw_int.pl0000755000175000017500000000162611416477520014743 0ustar bsbbsb#!/usr/bin/perl -w use ExtUtils::testlib; use strict; use Audio::Ecasound ':std'; # WARNING NO ERROR CHECKING!! command("cs-add play_chainsetup"); command("c-add 1st_chain"); command("-i:some_file.wav"); command("-o:/dev/dsp"); command("cop-add -efl:100"); command("cop-select 1"); command("copp-select 1"); command("cs-connect"); if(error()) { die "Setup error, you need 'some_file.wav' in the current directory\n\n" . last_error(); } command("start"); my $cutoff_inc = 500.0; while (1) { sleep(1); command("engine-status"); last if last_string() ne "running"; command("get-position"); my $curpos = last_float(); last if $curpos > 15; command("copp-get"); my $next_cutoff = $cutoff_inc + last_float(); command_float_arg("copp-set", $next_cutoff); } command("stop"); command("cs-disconnect"); command("cop-status"); print last_string(), "\n"; Audio-Ecasound-1.01/eg/oo_int.pl0000755000175000017500000000154411416477520014566 0ustar bsbbsb#!/usr/bin/perl -w use ExtUtils::testlib; use strict; use Audio::Ecasound; my $e = new Audio::Ecasound; $e->on_error('die'); $e->eci("cs-add play_chainsetup"); $e->eci("c-add 1st_chain"); $e->eci("-i:some_file.wav"); $e->eci("-o:/dev/dsp"); $e->eci("cop-add -efl:100"); $e->eci("cop-select 1"); $e->eci("copp-select 1"); if(!defined(eval { $e->eci("cs-connect") })) { die "Setup error, you need 'some_file.wav' in the current directory\n\n" . $e->errmsg(); } $e->on_error('die'); $e->eci("start"); my $cutoff_inc = 500.0; while (1) { sleep(1); last if $e->eci("engine-status") ne "running"; my $curpos = $e->eci("get-position"); last if $curpos > 15; my $next_cutoff = $cutoff_inc + $e->eci("copp-get"); $e->eci("copp-set", $next_cutoff); } $e->eci("stop"); $e->eci("cs-disconnect"); print $e->eci("cop-status"), "\n"; Audio-Ecasound-1.01/typemap0000644000175000017500000000014711416477520013744 0ustar bsbbsbconst char * T_PV long int T_IV eci_handle_t T_PTROBJ