~ubuntu-branches/ubuntu/utopic/ardour3/utopic

« back to all changes in this revision

Viewing changes to tools/ARDOUR/SourceInfoLoader.pm

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2013-09-21 19:05:02 UTC
  • Revision ID: package-import@ubuntu.com-20130921190502-8gsftrku6jnzhd7v
Tags: upstream-3.4~dfsg
ImportĀ upstreamĀ versionĀ 3.4~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package ARDOUR::SourceInfoLoader;
 
2
 
 
3
 
 
4
use XML::Handler::Subs;
 
5
 
 
6
@ISA = qw( XML::Handler::Subs );
 
7
 
 
8
$VERSION = 1.0;
 
9
 
 
10
 
 
11
sub new {
 
12
        my ($type, $sessionName) = @_;
 
13
 
 
14
        my $self = $type->SUPER::new();
 
15
        
 
16
        $self->{SessionName} = $sessionName;
 
17
        $self->{InRegions} = 0;
 
18
        %self->{Sources} = {};
 
19
 
 
20
        
 
21
        return $self;
 
22
}
 
23
 
 
24
sub start_element {
 
25
        my $self = shift;
 
26
        my $element = shift;
 
27
 
 
28
        my $atts = $element->{Attributes};
 
29
 
 
30
        if ( $element->{Name} eq "Source") {
 
31
                if ( ! -f "interchange/".$sessionName."/audiofiles/".$atts->{name}) {
 
32
                        $atts->{calculated_length} = 1;
 
33
                        $self->{Sources}->{$atts->{id}} = $atts;
 
34
                }
 
35
        }
 
36
 
 
37
        
 
38
        if ( $self->{InRegions} eq 1 && $element->{Name} eq "Region") {
 
39
                #print "Looking at region ".$atts->{id}."\n";
 
40
                my $num = 0;
 
41
 
 
42
                my $region_length = $atts->{length};
 
43
                while ( $atts->{"source-".$num} ne "" ) {
 
44
 
 
45
                        if ($region_length > $self->{Sources}->{$atts->{"source-".$num}}->{calculated_length} ) {
 
46
                                $self->{Sources}->{$atts->{"source-".$num}}->{calculated_length} = $region_length;
 
47
                        }
 
48
 
 
49
                        $num++;
 
50
                }
 
51
        }
 
52
 
 
53
        if ( $element->{Name} eq "Regions") {
 
54
                $self->{InRegions} = 1;
 
55
                #print "In regions\n";
 
56
        }
 
57
 
 
58
 
 
59
}
 
60
 
 
61
sub end_element {
 
62
        my $self = shift;
 
63
        my $element = shift;
 
64
 
 
65
        if ( $element->{Name} eq "Regions") {
 
66
                $self->{InRegions} = 0;
 
67
                #print "Out of regions\n";
 
68
        }
 
69
 
 
70
}
 
71
 
 
72
1;
 
73
 
 
74
 
 
75