[Sndobj-devel] Python SNdIO /Core Audio SetSr
Status: Abandoned
Brought to you by:
veplaini
From: Edward H. <ed....@gm...> - 2007-08-09 19:19:13
|
Hi I've been tinkering with PySndObj on the Mac . BTW it built out of the box for python 2.5 with the MacPython framework and appropriate build switches to build the python wrapper. The examples work OK as does the I have now got to the point where I'm able to read an AIF file and providing it's a PCM file get it to play back OK apart from when the sampling rate is not the default 44100. In the case in question it is 22050 but it plays back as if 44100. (Thanks BTW to the wav file example post) I have tried the commented options shown in the code below, I'm new to the API so I'm not sure if this is a bug or I'm not setting the sampling rate in the right place. So suggestions welcomed. The example file is in the /Developer/Examples/Java/Sound source tree. import sndobj fn = '22-new.aif' #fn = 'sound.aif' af = sndobj.SndAiff(fn,sndobj.READ,2) sr = af.GetSr() vs = af.GetVectorSize() print sr,vs T1 = sndobj.SndThread() sndin = sndobj.SndIn(af,1) outp = sndobj.SndCoreAudio() aif1 = sndobj.SndIn(af,1) #aif1 = sndobj.SndIn(af,1,vs,sr) #aif1.SetSr(sr) aif2 = sndobj.SndIn(af,2) #aif2 = sndobj.SndIn(af,2, vs, sr) #aif2.SetSr(sr) outp.SetOutput(1,aif1) outp.SetOutput(2,aif2) T1.AddObj(af,sndobj.SNDIO_IN) T1.AddObj(aif1) T1.AddObj(aif2) T1.AddObj(outp,sndobj.SNDIO_OUT) T1.ProcOn() time.sleep(5) T1.ProcOff() TIA Ed |