samer@0: ;;; Simple program that streams audio input to audio output samer@0: ;;; and a WAV file called out.wav. samer@0: ;;; Uses raw LineSource and LineSink, not LineIn and LineOut objects samer@0: ;;; (see lineio.scm) samer@0: samer@0: (load "audio.scm") samer@0: samer@0: (tasks) samer@0: (define fmt (mono 44100)) ; see audio.scm for other options samer@0: samer@5: (define in (linesrc fmt)) samer@5: (define out (linesnk fmt)) samer@0: (define wav (filesnk "out.wav" fmt)) samer@0: samer@0: (define N 1024) ; frame size for audio transfers samer@0: (define x (VVector. "x" N)) ; frame of audio data samer@0: samer@0: ; this sets up the tasks to run in the main loop, but samer@0: ; nothing happens until the loop is started samer@0: (addtasks samer@0: (.reader in (.array x) 0 N) ; read N samples into x samer@0: (Ops.update x) ; to update GUI samer@0: ; the switches mean that the tasks can be switched in samer@0: ; and out of the main loop on the fly through the GUI samer@0: (node "writer" (switch (.writer wav (.array x) 0 N))) samer@0: (node "lineout" (switch (.writer out (.array x) 0 N))) samer@0: ) samer@0: samer@0: (expose) ; show GUI samer@0: (expose (.getScale out)) ; show GUI for lineout scaling samer@0: (expose (.getScale wav)) ; ditto for file out scaling samer@0: samer@0: (display "Type (start) or press start button to start main loop.\n")