diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-04-26 20:54:31 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-04-26 20:54:31 +0000 |
commit | 87726495c30f90554b5204b5385d17274a8fe93e (patch) | |
tree | d7ecaf0be9b5cbd2afa226cd02cb53a36875d6a2 /tools/ARDOUR/AutomationSRConverter.pm | |
parent | 45d3ec1437cf661533bc7750c623865def4424df (diff) |
Merged changes from trunk 1699:1751 into 2.1-staging
git-svn-id: svn://localhost/ardour2/branches/2.1-staging@1752 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'tools/ARDOUR/AutomationSRConverter.pm')
-rw-r--r-- | tools/ARDOUR/AutomationSRConverter.pm | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tools/ARDOUR/AutomationSRConverter.pm b/tools/ARDOUR/AutomationSRConverter.pm new file mode 100644 index 0000000000..afd8f6c702 --- /dev/null +++ b/tools/ARDOUR/AutomationSRConverter.pm @@ -0,0 +1,61 @@ +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; |