Class: LAME::Decoding::MPEGAudioFrameMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/lame/decoding/mpeg_audio_frame_matcher.rb

Overview

Specification is here: www.codeproject.com/Articles/8295/MPEG-Audio-Frame-Header

Also see ‘is_syncword_mp123` in lame-3.99.5/frontend/get_audio.c

Get ready for some bit-matching magic:

Constant Summary collapse

CHANNEL_MODES =
[:stereo, :joint_stereo, :dual_channel, :mono]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bytes) ⇒ MPEGAudioFrameMatcher

Returns a new instance of MPEGAudioFrameMatcher.



16
17
18
# File 'lib/lame/decoding/mpeg_audio_frame_matcher.rb', line 16

def initialize(bytes)
  @bytes = bytes.unpack("C*")
end

Instance Attribute Details

#bytesObject (readonly)

Returns the value of attribute bytes.



12
13
14
# File 'lib/lame/decoding/mpeg_audio_frame_matcher.rb', line 12

def bytes
  @bytes
end

Instance Method Details

#match?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
28
# File 'lib/lame/decoding/mpeg_audio_frame_matcher.rb', line 20

def match?
  leading_bits? &&
    mpeg? &&
    layer? &&
    bitrate? &&
    sample_frequency? &&
    valid_mpeg1_layer2? &&
    emphasis?
end