(bind-func sf_print_audio_file_info
"print info about an audio file"
(lambda (filename)
(let ((info:SF_INFO* (salloc))
(audiofile (sf_open filename SFM_READ info))
(channels (sf_channels info)))
(if (null? audiofile)
(begin (printf "Bad audio file!\n")
void)
(let ((nframes (sf_frames info))
(rate (convert (sf_samplerate info)))
(nseconds (/ nframes rate)))
(printf "---------------\n")
(printf "filename: %s\n" filename)
(printf "samplerate: %d\n" rate)
(printf "channels: %d\n" (sf_channels info))
(printf "format: %#x\n" (sf_format info))
(printf "frames: %lld\n" nframes)
(if (< nframes (* 44100 60 1))
(printf "seconds: %f\n" nseconds)
(if (< nframes (* 44100 60 60))
(printf "minutes: %f\n" (/ (convert nseconds double) 60.))
(printf "hours: %f\n" (/ (convert nseconds double) (* 60. 60.)))))
(let ((loops:SF_LOOP_INFO* (alloc))
(lp1 (sf_command audiofile SFC_GET_LOOP_INFO (cast loops i8*) 44)))
(if (= lp1 SF_TRUE)
(printf "loop-mode: %d - bpm(%f)\n" (tref loops 2) (ftod (tref loops 4)))
(printf "loop-mode:\n")))
(let ((inst:SF_INSTRUMENT* (alloc))
(lp2 (sf_command audiofile SFC_GET_INSTRUMENT (cast inst i8*) 270)))
(if (= lp2 SF_TRUE)
(printf "nframes loops: %d\n" (tref inst 7))
(printf "nframes loops: 0\n")))
(sf_close audiofile)
void)))))