You are looking at historical revision 719 of this page. It may differ significantly from its current revision.


The MPEG3 is a thin wrapper around the libmpeg3 C library.

The official documentation for the C library is available here:


Show information of an MPEG3 audio file

(use mpeg3)

(define *path* "/tmp/file.mp3")

; Verify that the file has the right signature:

(unless (mpeg3-check-sig *path*)
  (error "Invalid file type"))

; Open the file:

(define *file* (mpeg3-open *path*))

; Make sure the file has audio:

(unless (mpeg3-has-audio *file*)
  (error "File doesn't have audio"))

; Get the total number of audio streams in the file:

(define *total-streams* (mpeg3-total-astreams *file*))

; Print information for each audio stream in the file:

(let loop ((stream 0))
  (unless (= stream *total-streams*)
    (format #t "Stream: ~A~%  Channels: ~A~%  Sample rate: ~A~%  Samples: ~A~%"
            (mpeg3-audio-channels *file* stream)
            (mpeg3-sample-rate *file* stream)
            (mpeg3-audio-samples *file* stream))
    (loop (+ stream 1))))

; Close the file.  This step is optional: if you don't do it, Chicken
; will close it when it no longer is required.  However, if you open
; a lot of files you will want to close them as soon as you know you'll
; no longer require them.

(mpeg3-close *file*)