File: wav.t

package info (click to toggle)
libaudio-scan-perl 0.93%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,152 kB
  • sloc: ansic: 11,482; perl: 241; sh: 48; makefile: 2
file content (130 lines) | stat: -rw-r--r-- 4,652 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
use strict;

use File::Spec::Functions;
use FindBin ();
use Test::More tests => 55;

use Audio::Scan;

# TODO: LPCM_low profile test

# WAV file with ID3 tags
{
    local $ENV{AUDIO_SCAN_NO_ARTWORK} = 1;
    
    my $s = Audio::Scan->scan( _f('id3.wav'), { md5_size => 4096 } );
    
    my $info = $s->{info};
    my $tags = $s->{tags};
    
    is( $info->{audio_offset}, 44, 'Audio offset ok' );
    is( $info->{audio_size}, 1904, 'Audio size ok' );
    is( $info->{audio_md5}, 'f69093529247ffd1dfaa5b7c66a19377', 'Audio MD5 ok' );
    is( $info->{bitrate}, 1411200, 'Bitrate ok' );
    is( $info->{bits_per_sample}, 16, 'Bits/sample ok' );
    is( $info->{block_align}, 4, 'Block align ok' );
    is( $info->{channels}, 2, 'Channels ok' );
    is( $info->{file_size}, 4240, 'File size ok' );
    is( $info->{format}, 1, 'Format ok' );
    is( $info->{samplerate}, 44100, 'Sample rate ok' );
    is( $info->{song_length_ms}, 10, 'Song length ok' );
    is( $info->{id3_version}, 'ID3v2.3.0', 'ID3 version ok' );
    is( $info->{dlna_profile}, 'LPCM', 'DLNA profile ok' );
    
    is( ref $tags->{COMM}, 'ARRAY', 'COMM ok' );
    is( $tags->{TALB}, 'WAV Album', 'TALB ok' );
    is( $tags->{TCON}, 'Alternative', 'TCON ok' );
    is( $tags->{TDRC}, 2009, 'TDRC ok' );
    is( $tags->{TIT2}, 'WAV Title', 'TIT2 ok' );
    is( $tags->{TPE1}, 'WAV Artist', 'TPE1 ok' );
    is( $tags->{TPOS}, 1, 'TPOS ok' );
    is( $tags->{TRCK}, 5, 'TRCK ok' );
    
    # Bug 17392, make sure artwork offset is correct when ID3 tag is not at the front of the file
    is( ref $tags->{APIC}, 'ARRAY', 'APIC ok' );
    is( $tags->{APIC}->[0], 'image/jpg', 'APIC type ok' );
    is( $tags->{APIC}->[3], 2103, 'APIC length ok' );
    is( $tags->{APIC}->[4], 2137, 'APIC offset ok' );
}

# 32-bit WAV with PEAK info
{
    my $s = Audio::Scan->scan( _f('wav32.wav') );
    
    my $info = $s->{info};
    
    is( $info->{audio_offset}, 88, '32-bit WAV audio offset ok' );
    is( $info->{audio_size}, 3808, '32-bit WAV audio size ok' );
    is( $info->{bitrate}, 2822400, '32-bit WAV bitrate ok' );
    is( $info->{bits_per_sample}, 32, '32-bit WAV bits/sample ok' );
    is( $info->{block_align}, 8, '32-bit WAV block align ok' );
    is( ref $info->{peak}, 'ARRAY', '32-bit WAV PEAK ok' );
    is( $info->{peak}->[0]->{position}, 284, '32-bit WAV Peak 1 ok' );
    is( $info->{peak}->[1]->{position}, 47, '32-bit WAV Peak 2 ok' );
    like( $info->{peak}->[0]->{value}, qr/^0.477/, '32-bit WAV Peak 1 value ok' );
    like( $info->{peak}->[1]->{value}, qr/^0.476/, '32-bit WAV Peak 2 value ok' );
    ok( !exists $info->{dlna_profile}, '32-bit WAV no DLNA profile ok' );
}

# MP3 in WAV
{
    my $s = Audio::Scan->scan( _f('8kmp38.wav') );
    
    my $info = $s->{info};
    
    is( $info->{bitrate}, 8000, 'MP3 WAV bitrate ok' );
    is( $info->{format}, 85, 'MP3 WAV format ok' );
    is( $info->{samplerate}, 8000, 'MP3 WAV samplerate ok' );
    is( $info->{song_length_ms}, 13811, 'MP3 WAV length ok' );
}

# Wav with INFO tags and wrong chunk size in header
{
    my $s = Audio::Scan->scan( _f('wav32-info-badchunk.wav') );
    
    my $tags = $s->{tags};
    
    is( $tags->{IART}, 'They Might Be Giants', 'IART ok' );
    is( $tags->{ICRD}, 2005, 'ICRD ok' );
    is( $tags->{IGNR}, 'Soundtrack', 'IGNR ok' );
    is( $tags->{INAM}, 'Here Come The ABCs', 'INAM ok' );
    is( $tags->{IPRD}, 'Here Come The Abcs With Tmbg - Original Songs About The Alphabet', 'IPRD ok' );
}

# Bug 14946, WAV file with INFO tags with trailing nulls
{
    my $s = Audio::Scan->scan( _f('wav32-info-nulls.wav') );
    
    my $tags = $s->{tags};
    
    is( $tags->{IART}, 'Archies, The', 'INFO nulls IART ok' );
    is( $tags->{ICMT}, 'Gift From Uncle Roddy', 'INFO nulls ICMT ok' );
    is( $tags->{ICRD}, 1997, 'INFO nulls ICRD ok' );
    is( $tags->{IGNR}, 'Pop', 'INFO nulls IGNR ok' );
    is( $tags->{INAM}, 'Tester Bang Shang A Lang', 'INFO nulls INAM ok' );
    is( $tags->{IPRD}, 'When I Was Young', 'INFO nulls IPRD ok' );
}

# Bug 14462, WAV file with 18-byte fmt chunk
{
    my $s = Audio::Scan->scan( _f('bug14462-wav-fmt.wav') );
    
    my $info = $s->{info};
    
    is( $info->{audio_offset}, 58, '18-byte fmt audio offset ok' );
    is( $info->{song_length_ms}, 7418, '18-byte fmt duration ok' );
}

# Bug 14462, WAV file with bad data size
{
    my $s = Audio::Scan->scan( _f('bug14462-wav-bad-data-size.wav') );
    
    my $info = $s->{info};
    
    is( $info->{audio_offset}, 44, 'bad data size audio offset ok' );
    is( $info->{song_length_ms}, 2977, 'bad data size duration ok' );
}

sub _f {
    return catfile( $FindBin::Bin, 'wav', shift );
}