racket/collects/ffi/examples/sndfile.ss
Eli Barzilay 7d50e61c7f * Newlines at EOFs
* Another big chunk of v4-require-isms
* Allow `#lang framework/keybinding-lang' for keybinding files
* Move hierlist sources into "mrlib/hierlist", leave stub behind

svn: r10689
2008-07-09 07:18:06 +00:00

34 lines
1.0 KiB
Scheme
Executable File

#! /usr/bin/env mzscheme
#lang scheme/base
(require ffi/sndfile)
;; (require swindle)
(define (add-half x y)
(/ (+ x (* y 0.5)) 1.5))
(define (repeated-list x n)
(let loop ([n n] [r '()])
(if (zero? n) r (loop (sub1 n) (cons x r)))))
(let-values ([(data meta) (read-sound* "x.wav")])
(printf ">>> data-length: ~s\n>>> meta: ~s\n" (length data) meta)
(let* ([data data #;
(list-of (list (add-half (1st x) (1st y))
(add-half (2nd x) (2nd y)))
(x <- data
and
y <- (append (repeated-list (list 0.0 0.0) 11025) data)
and
i <- 0.1 0.12 ..))])
(printf "writing to y.wav\n")
(write-sound* "y.wav"
;data
;(append data (reverse data))
(append data (reverse (map reverse data)))
`((artist "Eli") (comment "Comment") (title "Title")
(date "1/1/1999") (software "mzscheme")
,@meta))))