# File /home/moumar/dev/rubyforge/ruby-mp3info/lib/mp3info.rb, line 321
  def initialize(filename)
    $stderr.puts("#{self.class}::new() does not take block; use #{self.class}::open() instead") if block_given?
    raise(Mp3InfoError, "empty file") unless File.stat(filename).size? #FIXME
    @filename = filename
    @hastag1, @hastag2 = false
    @tag = Hash.new
    @tag1 = Hash.new
    @tag2 = Hash.new

    @file = File.new(filename, "rb")
    parse_tags
    @tag_orig = @tag1.dup

    #creation of a sort of "universal" tag, regardless of the tag version
    if hastag2?
      h = { 
        "title"    => "TIT2",
        "artist"   => "TPE1", 
        "album"    => "TALB",
        "year"     => "TYER",
        "tracknum" => "TRCK",
        "comments" => "COMM",
        "genre"    => 255,
        "genre_s"  => "TCON"
      }

      h.each { |k, v| @tag[k] = @tag2[v] }

    elsif hastag1?
      @tag = @tag1.dup
    end


    extract_info_from_head(find_next_frame)
    seek =
    if @mpeg_version == 1                     # mpeg version 1
    (@channel_num == 3 ? 17 : 32)        # channel_num 3 = Mono
    else                                      # mpeg version 2 or 2.5
    (@channel_num == 3 ?  9 : 17)
    end
    @file.seek(seek, IO::SEEK_CUR)
    
    vbr_head = @file.read(4)
    if vbr_head == "Xing"
      @vbr = true
      parse_xing_header
    end
    if @vbr
      @length = (26/1000.0)*@frames
      @bitrate = (((@streamsize/@frames)*@samplerate)/144) >> 10
    else
      # for cbr, calculate duration with the given bitrate
      @streamsize = @file.stat.size - (@hastag1 ? TAGSIZE : 0) - (@hastag2 ? @tag2["length"] : 0)
      @length = ((@streamsize << 3)/1000.0)/@bitrate
      if @tag2["TLEN"]
        # but if another duration is given and it isn't close (within 5%)
        #  assume the mp3 is vbr and go with the given duration
        tlen = (@tag2["TLEN"].to_i)/1000
        percent_diff = ((@length.to_i-tlen)/tlen.to_f)
        if percent_diff.abs > 0.05
          # without the xing header, this is the best guess without reading
          #  every single frame
          @vbr = true
          @length = @tag2["TLEN"].to_i/1000
          @bitrate = (@streamsize / @bitrate) >> 10
        end
      end
    end
  end