anchor.diff:                                (+ (* 72  (/ bit-rate sample-rate)) padded)))))))
   
   (defmethod load-frame ((me frame) &key instream (read-payload nil))
  -  "Load an MPEG frame from current file position"
  +  "Load an MPEG frame from current file position.  If READ-PAYLOAD is set, read in frame's content."
     (fastest
       (log5:with-context "load-frame"
         (handler-case
  
positive.code: 
  (defun get-layer-string (layer) (nth layer '("Reserved" "Layer III" "Layer II" "Layer I")))
  
  (defconstant +channel-mode-stereo+ 0)
  (defconstant +channel-mode-joint+  1)
  (defconstant +channel-mode-dual+   2)
  (defconstant +channel-mode-mono+   3)
  (defun get-channel-mode-string (mode)  (nth mode '("Stereo" "Joint" "Dual" "Mono")))
  
  (defconstant +emphasis-none+     0)
  (defconstant +emphasis-50-15+    1)
  (defconstant +emphasis-reserved+ 2)
  
negative.code:           nil)))))
  
  (defmethod parse-header ((me frame))
    "Given a frame, verify that is a valid MPEG audio frame by examining the header.
  A header looks like this:
  Bits 31-21 (11 bits): the sync word.  Must be #xffe (NB version 2.5 standard)
  Bits 20-19 (2  bits): the version
  Bits 18-17 (2  bits): the layer
  Bit     16 (1  bit ): the protection bit
  Bits 15-12 (4  bits): the bit-rate index
  Bits 11-10 (2  bits): the sample-rate index
  Bit      9 (1  bit ): the padding bit
  Bit      8 (1  bit ): the private bit
  Bits   7-6 (2  bits): the channel mode
  Bits   5-4 (2  bits): the mode extension
  Bit      3 (1  bit ): the copyright bit
  Bit      2 (1  bit ): the original bit
  Bits   1-0 (2  bits): the emphasis"
  
    (fastest
      (log5:with-context "parse-header"
        (with-frame-slots (me)
          ;; check sync word
          (setf sync (get-bitfield hdr-u32 31 11))
          ;(setf (ldb (byte 8 8) sync) (ldb (byte 8 24) hdr-u32))
          ;(setf (ldb (byte 3 5) sync) (ldb (byte 3 5) (ldb (byte 8 16) hdr-u32)))
          (when (not (= sync +sync-word+))
            (log-mpeg-frame "bad sync ~x/~x" sync hdr-u32)
            (return-from parse-header nil))
  
          ;; check version
          ;(setf version (ldb (byte 2 3) (ldb (byte 8 16) hdr-u32)))
          (setf version (get-bitfield hdr-u32 20 2))
          (when (not (valid-version version))
            (log-mpeg-frame "bad version ~d" version)
            (return-from parse-header nil))
  
          ;; check layer
          ;(setf layer (ldb (byte 2 1) (ldb (byte 8 16) hdr-u32)))
          (setf layer (get-bitfield hdr-u32 18 2))
          (when (not (valid-layer layer))
            (log-mpeg-frame "bad layer ~d" layer)
            (return-from parse-header nil))
  
          ;(setf protection (ldb (byte 1 0) (ldb (byte 8 16) hdr-u32)))
          (setf protection (get-bitfield hdr-u32 16 1))
  
          (setf samples (get-samples-per-frame version layer))
  
          ;; check bit-rate
          ;(let ((br-index (the fixnum (ldb (byte 4 4) (ldb (byte 8 8) hdr-u32)))))
          (let ((br-index (get-bitfield hdr-u32 15 4)))
            (when (not (valid-bit-rate-index br-index))
              (log-mpeg-frame "bad bit-rate index ~d" br-index)
              (return-from parse-header nil))
  
            (setf bit-rate (get-bit-rate version layer br-index)))
  
          ;; check sample rate
          ;(let ((sr-index (the fixnum (ldb (byte 2 2) (ldb (byte 8 8) hdr-u32)))))
          (let ((sr-index (get-bitfield hdr-u32 11 2)))
            (when (not (valid-sample-rate-index sr-index))
              (log-mpeg-frame "bad sample-rate index ~d" sr-index)
              (return-from parse-header nil))
  
            (setf sample-rate (get-sample-rate version sr-index)))
  
          ;(setf padded (ldb (byte 1 1) (ldb (byte 8 8) hdr-u32)))
          (setf padded (get-bitfield hdr-u32 9 1))
  
          ;(setf private (ldb (byte 1 0) (ldb (byte 8 8) hdr-u32)))
          (setf private (get-bitfield hdr-u32 8 1))
  
          ;(setf channel-mode (ldb (byte 2 6) (ldb (byte 8 0) hdr-u32)))
          (setf channel-mode (get-bitfield hdr-u32 7 2))
  
          ;(setf mode-extension (ldb (byte 2 4) (ldb (byte 8 0) hdr-u32)))
          (setf mode-extension (get-bitfield hdr-u32 5 2))
  
          ;(setf copyright (ldb (byte 1 3) (ldb (byte 8 0) hdr-u32)))
          (setf copyright (get-bitfield hdr-u32 3 1))
  
          ;(setf original (ldb (byte 1 2) (ldb (byte 8 0) hdr-u32)))
          (setf original (get-bitfield hdr-u32 2 1))
  
          ;(setf emphasis (ldb (byte 2 0) (ldb (byte 8 0) hdr-u32)))
          (setf emphasis (get-bitfield hdr-u32 1 2))
  
          ;; check emphasis
          (when (not (valid-emphasis emphasis))
            (log-mpeg-frame "bad emphasis ~d" emphasis)
            (return-from parse-header nil))
  