ardour/tools/ARDOUR/AutomationSRConverter.pm
Sampo Savolainen fbdd0ab815 Added the session resampler which now should work for 2.0 sessions and
almost work for 0.99 originated session (automation is not handled yet).
Stopped the creation on the automation/ directory in new sessions as 
it's not used anymore


git-svn-id: svn://localhost/ardour2/trunk@1725 d708f5d6-7413-0410-9779-e7cbd77b26cf
2007-04-15 20:47:21 +00:00

61 lines
999 B
Perl

package ARDOUR::AutomationSRConverter;
sub new {
my ($type, $input, $output, $inputSR, $outputSR) = @_;
my $self = bless {}, $type;
$self->{Input} = $input;
$self->{Output} = $output;
$self->{Ratio} = ($outputSR+0) / ($inputSR+0);
return $self;
}
sub readline {
my ($self) = @_;
my $buf;
my $c='';
do {
$buf.=$c;
$c=$self->{Input}->getc;
} while ($c ne '' && $c ne "\n");
return $buf;
}
sub writeline {
my ($self, $line) = @_;
$self->{Output}->print($line."\n");
}
sub convert {
my ($self) = @_;
my $version=$self->readline;
if ($version ne "version 1") {
die ("Unsupported automation version $version");
}
$self->writeline($version);
my $buf = $self->readline;
while ( $buf ne "" ) {
if ( $buf eq "begin" ||
$buf eq "end") {
$self->writeline($buf);
} else {
my ($type, $position, $value) = split(' ', $buf);
$self->writeline($type." ".sprintf("%.0f",$position*$self->{Ratio})." ".$value);
}
$buf = $self->readline;
}
}
1;