(bind-func sf_frames_from_file
  "get the total number of frames from an audio file"
  (lambda (filename)
    (let ((info:SF_INFO* (salloc))
          (audiofile (sf_open filename SFM_READ info)))
      (if (null? audiofile)
          -1
          (begin
            (sf_close audiofile)
            (sf_frames info))))))