The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

 Audio::Mad::Frame - Interface to mad_frame structure
 

SYPNOSIS

 my $frame = new Audio::Mad::Frame;

 FRAME: while(1) {
        if ($frame->decode($stream) == -1) {
                print "stream error: " . $stream->error() . "\n";
                last FRAME;
        }
        
        my $layer      = $frame->layer();
        my $mode       = $frame->mode();
        my $bitrate    = $frame->bitrate();
        my $samplerate = $frame->samplerate();
        my $timer      = $frame->duration(); #see Audio::Mad::Timer
        my $flags      = $frame->flags();
        
        # do something with the frame.  usually requires
        # Audio::Mad::Synth (see docs)
 }
        

DESCRIPTION

  This package provides an interface to the underlying mad_frame
  structure used in the decoder library.  Most of the functions
  and underlying data are exposed to perl.
  

METHODS

  • new

      Allocates and initializes a new mad_frame structure,  and
      provides us with a handle to access it.
      
  • decode(stream)

      Fully decodes the next available frame from 'stream' and 
      stores the information in it's internal structure.
  • decode_header(stream)

      Much the same as 'decode' but it only decodes the header
      information from the next frame.  You can access the
      frame data at this point,  however,  the frame is not
      ready for synthesizing (or a ->mute call).  To finish 
      the decoding,  just call ->decode() again on the stream;
      although it's not required (e.g., you can seek/quit/etc)
      
  • mute

      Mutes all the sub-band samples in the current frame
      structure.  It's usually prudent to call this after
      seeking around on a stream,  to avoid hearing
      scratches and pops.
      
  • layer

  • mode

  • flags

  • bitrate

  • samplerate

      These functions retrieve the information from the currently 
      decoded frame header.  layer,  mode,  and flags correspond
      to the MAD_LAYER_, MAD_MODE_, and MAD_FLAG_ constants.
      bitrate and samplerate are represented as integers.
      
  • duration

      Returns the duration of the currently decoded frame as an
      Audio::Mad::Timer object.  See Audio::Mad::Timer's manpage
      for details on what this means.
      
  • NCHANNELS

      Returns number of channels in current frame.  1 or 2.
      
  • NSBSAMPLES

      Returns number of samples in this frame.

AUTHOR

  Mark McConnell <mischke@cpan.org>