Browse Source

Added FLAC audio property info and general cleanup

Mark VandenBrink 12 năm trước cách đây
mục cha
commit
d79e7da63b
4 tập tin đã thay đổi với 18 bổ sung16 xóa
  1. 3 2
      abstract-tag.lisp
  2. 6 5
      audio-streams.lisp
  3. 2 2
      packages.lisp
  4. 7 7
      taglib-tests.lisp

+ 3 - 2
abstract-tag.lisp

@@ -497,8 +497,9 @@
             (track (track me))
             (year (year me)))
 
-        ;;(if (audio-info me)
-        ;;(mp4-atom:vpprint (audio-info me) t))
+        (if (audio-info me)
+            (flac-frame:vpprint (audio-info me) t))
+
         (when album (format t "~&~4talbum: ~a~%" album))
         (when album-artist (format t "~4talbum-artist: ~a~%" album-artist))
         (when artist (format t "~4tartist: ~a~%" artist))

+ 6 - 5
audio-streams.lisp

@@ -87,11 +87,12 @@ As a convenience, OFFSET and FROM are optional, so (STREAM-SEEK stream) returns
 
 (declaim (inline read-n-bytes))
 
-(defmethod stream-read-u8  ((stream mem-stream) &key (bits-per-byte 8)) (read-n-bytes stream 1 :bits-per-byte bits-per-byte))
-(defmethod stream-read-u16 ((stream mem-stream) &key (bits-per-byte 8) (endian :little-endian)) (read-n-bytes stream 2 :bits-per-byte bits-per-byte :endian endian))
-(defmethod stream-read-u24 ((stream mem-stream) &key (bits-per-byte 8) (endian :little-endian)) (read-n-bytes stream 3 :bits-per-byte bits-per-byte :endian endian))
-(defmethod stream-read-u32 ((stream mem-stream) &key (bits-per-byte 8) (endian :little-endian)) (read-n-bytes stream 4 :bits-per-byte bits-per-byte :endian endian))
-(defmethod stream-read-u64 ((stream mem-stream) &key (bits-per-byte 8) (endian :little-endian)) (read-n-bytes stream 8 :bits-per-byte bits-per-byte :endian endian))
+(defmethod stream-read-u8   ((stream mem-stream) &key (bits-per-byte 8)) (read-n-bytes stream 1 :bits-per-byte bits-per-byte))
+(defmethod stream-read-u16  ((stream mem-stream) &key (bits-per-byte 8) (endian :little-endian)) (read-n-bytes stream 2  :bits-per-byte bits-per-byte :endian endian))
+(defmethod stream-read-u24  ((stream mem-stream) &key (bits-per-byte 8) (endian :little-endian)) (read-n-bytes stream 3  :bits-per-byte bits-per-byte :endian endian))
+(defmethod stream-read-u32  ((stream mem-stream) &key (bits-per-byte 8) (endian :little-endian)) (read-n-bytes stream 4  :bits-per-byte bits-per-byte :endian endian))
+(defmethod stream-read-u64  ((stream mem-stream) &key (bits-per-byte 8) (endian :little-endian)) (read-n-bytes stream 8  :bits-per-byte bits-per-byte :endian endian))
+(defmethod stream-read-u128 ((stream mem-stream) &key (bits-per-byte 8) (endian :little-endian)) (read-n-bytes stream 16 :bits-per-byte bits-per-byte :endian endian))
 
 (defmethod stream-read-sequence ((stream mem-stream) size &key (bits-per-byte 8))
   "Read in a sequence of octets at BITS-PER-BYTE.  If BITS-PER-BYTE == 8, then simply return

+ 2 - 2
packages.lisp

@@ -17,7 +17,7 @@
            #:id3-header #:audio-info #:mp4-atoms #:flac-headers
            #:parse-mp3-file #:parse-mp4-file #:parse-audio-file #:parse-flac-file #:flac-tags
            #:make-mem-stream #:make-file-stream #:stream-filename
-           #:stream-read-u8 #:stream-read-u16 #:stream-read-u24 #:stream-read-u32 #:stream-read-u64 #:stream-read-octets
+           #:stream-read-u8 #:stream-read-u16 #:stream-read-u24 #:stream-read-u32 #:stream-read-u64 #:stream-read-u128 #:stream-read-octets
            #:stream-decode-iso-string #:stream-deocode-ucs-string #:stream-decode-ucs-be-string
            #:stream-decode-utf-8-string #:stream-decode-string #:stream-read-iso-string-with-len
            #:stream-read-ucs-string-with-len #:stream-read-ucs-be-string-with-len
@@ -30,7 +30,7 @@
 
 (defpackage #:flac-frame
   (:export #:flac-frame-condition #:flac-header #:vpprint #:is-valid-flac-file #:find-flac-frames
-           #:get-flac-audio-info #:flac-get-tag)
+           #:get-flac-audio-info #:flac-get-tag #:get-flac-audio-info)
   (:use #:common-lisp #:utils #:audio-streams))
 
 (defpackage #:mp4-atom

+ 7 - 7
taglib-tests.lisp

@@ -8,8 +8,9 @@
 (in-package #:taglib-tests)
 
 ;;; some convenient songs to parse
-(defparameter *song-m4a* "Queen/Queen I/01 Keep Yourself Alive.m4a")
-(defparameter *song-mp3* "Queen/Sheer Heart Attack/07 In The Lap Of The Gods.mp3")
+(defparameter *song-m4a*  "Queen/Queen I/01 Keep Yourself Alive.m4a")
+(defparameter *song-mp3*  "Queen/Sheer Heart Attack/07 In The Lap Of The Gods.mp3")
+(defparameter *song-flac* "Frank Zappa/Baby Snakes/02. Baby Snakes.flac")
 
 ;;;
 ;;; Set the pathname (aka filename) encoding in CCL for appropriate platorm
@@ -37,10 +38,9 @@
         (stream-close foo)))))
 
 
-
 (defun do-audio-dir (&optional (dir "Queen") &key (file-system-encoding :utf-8)
                                                   (func #'abstract-tag:show-tags))
-  "Walk :DIR and FUNCALL specified function for each file (MP4/MP3) found."
+  "Walk :DIR and FUNCALL specified function for each file audio found."
   (set-pathname-encoding file-system-encoding)
   (let ((mp3-count 0)
         (flac-count 0)
@@ -60,7 +60,7 @@
                                                                  (when func (funcall func s)))
                                                                 ((null s) (incf other-count)))))))
 
-    (format t "~&~:d MP3s, ~:d MP4s, ~:d FLACs ~:d Others, for a total of ~:d~%"
+    (format t "~&~:d MP3s, ~:d MP4s, ~:d FLACs, ~:d Others, for a total of ~:d~%"
             mp3-count mp4-count flac-count other-count (+ mp3-count mp4-count flac-count other-count))))
 
 (defun time-test (&optional (dir "Queen") &key (file-system-encoding :utf-8) (do-audio-processing t))
@@ -82,7 +82,7 @@
 
 (defun mp-do-audio-dir (&optional (dir "Queen") &key (file-system-encoding :utf-8)
                                                      (func #'abstract-tag:show-tags))
-  "Walk :DIR and FUNCALL specified function for each file (MP4/MP3) found."
+  "Walk :DIR and FUNCALL specified function for each file audio found."
   (set-pathname-encoding file-system-encoding)
   (let ((channel (make-instance 'chanl:unbounded-channel))
         (dead-channel (make-instance 'chanl:unbounded-channel))
@@ -130,7 +130,7 @@
           (loop
             (force-output *standard-output*)
             (setf results (chanl:recv dead-channel))
-            (format t "~4t~a died, ~:d MP3s, ~:d MP4s, ~:d FLACs~:d Others~%"
+            (format t "~4t~a died, ~:d MP3s, ~:d MP4s, ~:d FLACs, ~:d Others~%"
                     (chanl-results-name results)
                     (chanl-results-mp3-count results)
                     (chanl-results-mp4-count results)