[Sndobj-devel] Using SndBuffer from Python
Status: Abandoned
Brought to you by:
veplaini
From: Art B. <ac...@in...> - 2010-04-06 02:08:27
|
Obviously I'm doing something wrong. I'm a SndObj newbie and a Python-only chap to boot. But I'm trying to get a simple buffered audio-in to audio-out loop to work... and apparently it's not quite as simple as I am. So I'm reaching out for guidance. I can substitute an Oscil for the SndRTIO and SndIn and I get a tone out, but somehow feeding the SndBuffer from the realtime input isn't the same. The following runs ok for the prescribed ten seconds, but I hear nothing coming out. #!/usr/bin/python ##################################### # Testing soundcard loopback # (this doesn't work) import sndobj import time # set all to 16-bit (thanks Daniel Skinner) vec = 2**16 snd = sndobj.SndObj() # Set up the input thread to fill a buffer from soundcard input inThread = sndobj.SndThread() inp = sndobj.SndRTIO(1, sndobj.SND_INPUT, 512, 4, sndobj.SHORTSAM_LE, snd.GetInput(), vec, sndobj.DEF_SR, 'plughw:1,0') sndin = sndobj.SndIn(inp, 1, vec) inBuf = sndobj.SndBuffer(1,512) inBuf.SetOutput(1, sndin) inThread.AddObj(sndin) inThread.AddObj(inBuf, sndobj.SNDIO_OUT) # Set up the output thread to play from the buffer over another soundcard output outThread = sndobj.SndRTThread() sound = sndobj.SndIn(inBuf) outp = sndobj.SndRTIO(1, sndobj.SND_OUTPUT, 512, 4, sndobj.SHORTSAM_LE, snd.GetInput(), vec, sndobj.DEF_SR, 'plughw:0,0') outp.SetOutput(1, sound) outThread.AddObj(inBuf, sndobj.SNDIO_IN) outThread.AddObj(sound) outThread.AddObj(outp, sndobj.SNDIO_OUT) # Run both threads for ten seconds inThread.ProcOn() outThread.ProcOn() time.sleep(10) outThread.ProcOff() inThread.ProcOff() ### EOF Thanks in advance for any light that can shine on this! - Art |