(OS X) make /Volumes show up in 1 extra location in the new session dialog
[ardour2.git] / tools / ARDOUR / AutomationSRConverter.pm
blobafd8f6c7022609c907dd467200773fa2728c3ad6
1 package ARDOUR::AutomationSRConverter;
3 sub new {
4 my ($type, $input, $output, $inputSR, $outputSR) = @_;
6 my $self = bless {}, $type;
8 $self->{Input} = $input;
9 $self->{Output} = $output;
10 $self->{Ratio} = ($outputSR+0) / ($inputSR+0);
12 return $self;
15 sub readline {
16 my ($self) = @_;
18 my $buf;
19 my $c='';
21 do {
22 $buf.=$c;
23 $c=$self->{Input}->getc;
24 } while ($c ne '' && $c ne "\n");
26 return $buf;
29 sub writeline {
30 my ($self, $line) = @_;
32 $self->{Output}->print($line."\n");
35 sub convert {
36 my ($self) = @_;
38 my $version=$self->readline;
40 if ($version ne "version 1") {
41 die ("Unsupported automation version $version");
44 $self->writeline($version);
46 my $buf = $self->readline;
47 while ( $buf ne "" ) {
48 if ( $buf eq "begin" ||
49 $buf eq "end") {
50 $self->writeline($buf);
51 } else {
52 my ($type, $position, $value) = split(' ', $buf);
54 $self->writeline($type." ".sprintf("%.0f",$position*$self->{Ratio})." ".$value);
57 $buf = $self->readline;