Audio-Nama
view release on metacpan or search on metacpan
lib/Audio/Nama/ChainSetup.pm view on Meta::CPAN
push @{$outputs{$_->ecs_string}}, $_->chain_id;
$pre_output{$_->chain_id} = $_->ecs_extra if $_->ecs_extra;
}
grep { $_->direction eq 'output' } @io;
no warnings 'numeric';
my @in_keys = values %inputs;
my @out_keys = values %outputs;
use warnings 'numeric';
%is_ecasound_chain = map{ $_, 1} map{ @$_ } values %inputs;
# sort entries into an aesthetic order
my %rinputs = reverse %inputs;
my %routputs = reverse %outputs;
@input_chains = sort map {'-a:'.join(',',sort by_chain @$_)." $rinputs{$_}"} @in_keys;
@output_chains = sort map {'-a:'.join(',',sort by_chain @$_)." $routputs{$_}"} @out_keys;
@post_input = sort by_index map{ "-a:$_ $post_input{$_}"} keys %post_input;
@pre_output = sort by_index map{ "-a:$_ $pre_output{$_}"} keys %pre_output;
@input_chains + @output_chains # to sense empty chain setup
}
{ my ($m,$n,$o,$p,$q,$r);
sub by_chain {
($m,$n,$o) = $a =~ /(\D*)(\d+)(\D*)/ ;
($p,$q,$r) = $b =~ /(\D*)(\d+)(\D*)/ ;
if ($n != $q){ $n <=> $q }
elsif ( $m ne $p){ $m cmp $p }
else { $o cmp $r }
}
}
sub by_index {
my ($i) = $a =~ /(\d+)/;
my ($j) = $b =~ /(\d+)/;
$i <=> $j
}
sub non_track_dispatch {
# loop -> loop
#
# assign chain_id to edge based on chain_id of left-side loop's
# corresponding track:
#
# hihat_out -- J7a -> Main_in
#
# soundcard_in -> wav_out (rec_file)
#
# currently handled using an anonymous track
#
# we expect edge attributes
# to have been provided for handling this.
# loop -> soundcard_out
#
# track7-soundcard_out as aux_send will have chain id S7
# that will be transferred by expand_graph() to
# the new edge, loop-soundcard-out
# we will issue two IO objects, one for the chain input
# fragment, one for the chain output
my $edge = shift;
logpkg(__FILE__,__LINE__,'debug',"non-track IO dispatch:",join ' -> ',@$edge);
my $eattr = $g->get_edge_attributes(@$edge) // {};
logpkg(__FILE__,__LINE__,'debug',"found edge attributes: ",json_out($eattr)) if $eattr;
my $vattr = $g->get_vertex_attributes($edge->[0]) // {};
logpkg(__FILE__,__LINE__,'debug',"found vertex attributes: ",json_out($vattr)) if $vattr;
if ( ! $eattr->{chain_id} and ! $vattr->{chain_id} ){
my $n = $eattr->{n} || $vattr->{n};
$eattr->{chain_id} = jumper_count($n);
}
my @direction = qw(input output);
map{
my $direction = shift @direction;
my $class = Audio::Nama::IO::get_class($_, $direction);
my $attrib = {%$vattr, %$eattr};
$attrib->{endpoint} //= $_ if Audio::Nama::Graph::is_a_loop($_);
logpkg(__FILE__,__LINE__,'debug',"non-track: $_, class: $class, chain_id: $attrib->{chain_id},","device_id: $attrib->{device_id}");
my $io = $class->new($attrib ? %$attrib : () ) ;
$g->set_edge_attribute(@$edge, $direction, $io);
$io;
} @$edge;
}
{
### counter for jumper chains
#
# sequence: J1 J1a J1b J1c, J2, J3, J4, J4d, J4e
my %used;
my $counter;
my $prefix = 'J';
reset_aux_chain_counter();
sub reset_aux_chain_counter {
%used = ();
$counter = 'a';
}
sub jumper_count {
my $track_index = shift;
my $try1 = $prefix . $track_index;
$used{$try1}++, return $try1 unless $used{$try1};
$try1 . $counter++;
}
}
sub dispatch { # creates an IO object from a graph edge
my $edge = shift;
return non_track_dispatch($edge) if not grep{ $tn{$_} } @$edge ;
logpkg(__FILE__,__LINE__,'debug','dispatch: ',join ' -> ', @$edge);
my($name, $endpoint, $direction) = decode_edge($edge);
logpkg(__FILE__,__LINE__,'debug',"name: $name, endpoint: $endpoint, direction: $direction");
my $track = $tn{$name};
my $class = Audio::Nama::IO::get_class( $endpoint, $direction );
# we need the $direction because there can be
# edges to and from loop,Main_in
my @args = (track => $name,
( run in 0.828 second using v1.01-cache-2.11-cpan-b16cb0d3907 )