| DISCLAIMER: I've just started learning scheme, let alone the mzscheme
foreign function facilities. But it works!
(require (lib "foreign.ss"))
(unsafe!)
(file-stream-buffer-mode (current-output-port) 'line)
(define libcsound (ffi-lib "libcsound"))
(define CSOUND
(make-ctype _pointer #f #f))
(define csoundCreate
(get-ffi-obj "csoundCreate" libcsound (_fun _int -> CSOUND)))
(define csoundCompile
(get-ffi-obj "csoundCompile" libcsound (_fun CSOUND _int _cvector ->
_int)))
(define csoundInputMessage
(get-ffi-obj "csoundInputMessage" libcsound (_fun CSOUND _string ->
_void)))
(define csoundPerformKsmps
(get-ffi-obj "csoundPerformKsmps" libcsound (_fun CSOUND -> _int)))
(define csoundDestroy
(get-ffi-obj "csoundDestroy" libcsound (_fun CSOUND -> _void)))
(define comm (list->cvector '("csound" "template.csd") _string))
(define cs (csoundCreate 0))
(define (csloop)
(if (= (csoundPerformKsmps cs) 0) (csloop)))
(csoundCompile cs 2 comm)
(csoundInputMessage cs "i1 0 20 7.00 15000")
(csloop)
(csoundDestroy cs)
(exit)
Best,
-c.
--
www.cesaremarilungo.com
|