| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | use lib qw(blib/lib blib/arch); |
| 4 | use strict; |
| 5 | |
| 6 | use Audio::Scan; |
| 7 | use Benchmark qw(cmpthese); |
| 8 | |
| 9 | $ENV{AUDIO_SCAN_NO_ARTWORK} = 1; |
| 10 | |
| 11 | my $file = shift || die "Usage: $0 [file]\n\n"; |
| 12 | |
| 13 | if ( $file =~ /\.mp(2|3)$/i ) { |
| 14 | require MP3::Info; |
| 15 | |
| 16 | cmpthese( -5, { |
| 17 | mp3_pp => sub { |
| 18 | MP3::Info::get_mp3info($file); |
| 19 | MP3::Info::get_mp3tag($file); |
| 20 | }, |
| 21 | mp3_c => sub { |
| 22 | Audio::Scan->scan($file); |
| 23 | }, |
| 24 | } ); |
| 25 | } |
| 26 | elsif ( $file =~ /\.ogg$/i ) { |
| 27 | require Ogg::Vorbis::Header::PurePerl; |
| 28 | |
| 29 | cmpthese( -5, { |
| 30 | ogg_pp => sub { |
| 31 | my $ogg = Ogg::Vorbis::Header::PurePerl->new($file); |
| 32 | $ogg->info; |
| 33 | $ogg->comment_tags; |
| 34 | }, |
| 35 | ogg_c => sub { |
| 36 | Audio::Scan->scan($file); |
| 37 | }, |
| 38 | } ); |
| 39 | } |
| 40 | elsif ( $file =~ /\.fla?c$/i ) { |
| 41 | require Audio::FLAC::Header; |
| 42 | |
| 43 | cmpthese( -5, { |
| 44 | flac_pp => sub { |
| 45 | Audio::FLAC::Header->_new_PP($file) |
| 46 | }, |
| 47 | flac_c => sub { |
| 48 | Audio::Scan->scan($file); |
| 49 | }, |
| 50 | } ); |
| 51 | } |
| 52 | elsif ( $file =~ /\.(wma|asf)$/i ) { |
| 53 | require Audio::WMA; |
| 54 | |
| 55 | cmpthese( -5, { |
| 56 | asf_pp => sub { |
| 57 | Audio::WMA->new($file); |
| 58 | }, |
| 59 | asf_c => sub { |
| 60 | Audio::Scan->scan($file); |
| 61 | }, |
| 62 | } ); |
| 63 | } |
| 64 | elsif ( $file =~ /\.(wav|aiff?)$/i ) { |
| 65 | require Audio::Wav; |
| 66 | |
| 67 | cmpthese( -5, { |
| 68 | wav_pp => sub { |
| 69 | Audio::Wav->new->read($file); |
| 70 | }, |
| 71 | wav_c => sub { |
| 72 | Audio::Scan->scan($file); |
| 73 | }, |
| 74 | } ); |
| 75 | } |
| 76 | elsif ( $file =~ /\.(mpc|mp\+|mpp)$/i ) { |
| 77 | require Audio::Musepack; |
| 78 | |
| 79 | cmpthese( -5, { |
| 80 | mpc_pp => sub { |
| 81 | Audio::Musepack->new($file); |
| 82 | }, |
| 83 | mpc_c => sub { |
| 84 | Audio::Scan->scan($file); |
| 85 | }, |
| 86 | } ); |
| 87 | } |
| 88 | elsif ( $file =~ /\.(m4a)$/i ) { |
| 89 | require MP4::Info; |
| 90 | |
| 91 | cmpthese( -5, { |
| 92 | mp4_pp => sub { |
| 93 | MP4::Info->new($file); |
| 94 | }, |
| 95 | mp4_c => sub { |
| 96 | Audio::Scan->scan($file); |
| 97 | }, |
| 98 | } ); |
| 99 | } |
| 100 | else { |
| 101 | die "Unsupported file type: $file\n\n"; |
| 102 | } |