Mercurial > hg > jslab
view examples/sound/sampled/audioio.scm @ 8:5e3cbbf173aa tip
Reorganise some more
author | samer |
---|---|
date | Fri, 05 Apr 2019 22:41:58 +0100 |
parents | b67a33c44de7 |
children |
line wrap: on
line source
;;; Simple program that streams audio input to audio output ;;; and a WAV file called out.wav. ;;; Uses raw LineSource and LineSink, not LineIn and LineOut objects ;;; (see lineio.scm) (load "audio.scm") (tasks) (define fmt (mono 44100)) ; see audio.scm for other options (define in (linesrc fmt)) (define out (linesnk fmt)) (define wav (filesnk "out.wav" fmt)) (define N 1024) ; frame size for audio transfers (define x (VVector. "x" N)) ; frame of audio data ; this sets up the tasks to run in the main loop, but ; nothing happens until the loop is started (addtasks (.reader in (.array x) 0 N) ; read N samples into x (Ops.update x) ; to update GUI ; the switches mean that the tasks can be switched in ; and out of the main loop on the fly through the GUI (node "writer" (switch (.writer wav (.array x) 0 N))) (node "lineout" (switch (.writer out (.array x) 0 N))) ) (expose) ; show GUI (expose (.getScale out)) ; show GUI for lineout scaling (expose (.getScale wav)) ; ditto for file out scaling (display "Type (start) or press start button to start main loop.\n")