#lang racket
(require (planet gcr/openal)
(planet gcr/libvorbisfile))
(define device (open-device #f))
(define context (create-context device))
(set-current-context context)
(define filename (vector-ref (current-command-line-arguments) 0))
(printf "Playing file ~a\n" filename)
(define m (open-vorbis-file filename))
(printf "Rate: ~a Channels: ~a Length: ~a sec\n"
(vorbis-frequency m)
(vorbis-channels m)
(vorbis-length-time m))
(define vorbis-binary (make-vorbis-input-port m 0 2 1))
(define source (car (gen-sources 1)))
(define stream-thread
(stream-port-to-source vorbis-binary
source
AL_FORMAT_STEREO16
(vorbis-frequency m)))
(play-source source)
(thread-wait stream-thread)
(set-current-context #f)
(destroy-context! context)
(close-device! device)
(close-vorbis-file! m)