view examples/sound/sampled/audioio.scm @ 0:bf79fb79ee13

Initial Mercurial check in.
author samer
date Tue, 17 Jan 2012 17:50:20 +0000
parents
children b67a33c44de7
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

; this is set up to read audio from one mixer and write out to
; another. This is because my main mixer, though it does full
; duplex, ends up feeding back because tritonus alsa mixer is
; mixing all the input channels on the sound card, rather than
; letting me choose just the line input.
(define in (linesrc (mixer-n 1) fmt))
(define out (linesnk (mixer-n 2) 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")