From 2fee037094da6faf1912a0bd237c7e2060d596ea Mon Sep 17 00:00:00 2001 From: divide Date: Mon, 18 Feb 2008 15:01:25 +0000 Subject: [PATCH] VBR mp3s handled correctly. git-svn-id: file:///home/divide/svn/trunk/walkgirl/trunk@442 92f4db9c-a619-0410-8c93-89f5936be7a8 --- walkgirl/audiofile.rb | 4 ++-- walkgirl/mp3.rb | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/walkgirl/audiofile.rb b/walkgirl/audiofile.rb index aabdad1..7a5bc94 100644 --- a/walkgirl/audiofile.rb +++ b/walkgirl/audiofile.rb @@ -23,7 +23,7 @@ require 'id3' module NetworkWalkman class AudioFile MPEG_VERSION = [:v2_5, :reserved, :v2, :v1] - attr_accessor :length, :frames, :tags + attr_accessor :length, :frames, :tags, :is_vbr attr_reader :filename, :slot class FromDevice < AudioFile attr_reader :encoding @@ -110,7 +110,7 @@ module NetworkWalkman outfile.syswrite "EA3" outfile.syswrite [2, 0, 0x60, 0xff, 0xfe, 1, 0x0f, 0x50, 0x00].pack("c5@9c4") outfile.syswrite [0, 4, 0, 0, 0, 1, 2, 3, 0xc8, 0xd8, 0x36, 0xd8, 0x11, 0x22, 0x33, 0x44].pack("c*") - outfile.syswrite [0x03, 0x80, encoding, 10, length, frames, 0].pack("c4N3") + outfile.syswrite [0x03, if is_vbr then 0x90 else 0x80 end, encoding, 10, length, frames, 0].pack("c4N3") outfile.syswrite [0,0,0,0].pack("N4") outfile.syswrite [0,0,0,0].pack("N4") outfile.syswrite [0,0,0,0].pack("N4") diff --git a/walkgirl/mp3.rb b/walkgirl/mp3.rb index 63606ff..f6550d2 100644 --- a/walkgirl/mp3.rb +++ b/walkgirl/mp3.rb @@ -113,6 +113,7 @@ module NetworkWalkman if @has_crc @crc = @file.read(2).unpack("n") end + @is_vbr = @file.read(37).unpack("@33a4")[0].upcase == "XING" if @sampling_rate > 0 break end -- 2.11.4.GIT