Re: [Sndobj-devel] Python SNdIO /Core Audio SetSr
Status: Abandoned
Brought to you by:
veplaini
From: Edward H. <ed....@gm...> - 2007-08-11 02:40:31
|
Yes I've had that as well IIRC correctly I added some helper methods to the .i file for the video library I wrapped (I'd have to go back to it on another machine to check) but in this case another overloaded constructor added (I assume, correct me if I'm wrong) to SndCoreAudio.cpp SndCoreAudio.h before rebuilding the library would be straightforward. I'll tackle that later on today. Cheers Ed On 8/10/07, Victor Lazzarini <vic...@nu...> wrote: > Another thing you can try straight away is to > use SndRTIO, which on OSX is effectively SndCoreAudio, > but with the important difference that its constructor > is > > SndRTIO(short ch, int mode, int bsize = DEF_BSIZE, > int period = DEF_PERIOD, int encoding = SHORTSAM, > SndObj** input=0, int vsize= DEF_VECSIZE, float sr=DEF_SR, > int dev = DEF_DEV) > > without any Uint32 (in fact, there is a slight bug in > there in that the conversion from int to uint is not > handled, but I can fix that if there is a problem). > > Victor > > > > > Problem is the constructor still expects 8 args not the 7 > > you suggest I introduced the sndobj.SND_OUTPUT argument to > > provide the 8th. I think this is a prototyping issue in > > SWIG though my close familiarity with SWIG predates the > > C++ extensions. However I note the the cpp source > > constructor is SndCoreAudio::SndCoreAudio(int channels,int > > bufframes, int buffnos, float norm, SndObj** inObjs, > > UInt32 dev, int vecsize, float sr) > > i.e. 8 args the 6th being the device. > > > > The python traceback remains as follows irrespective of > > whether 7 or 8 args are provided or whether > > sndobj.SND_OUTPUT or a python int is passed. > > > > > > File "aif.py", line 20, in <module> > > outp = sndobj.SndCoreAudio(2, 512, 4, 32767.0, objsp, > > 256, 22050.0) #wrong args number > > File "/Users/edh/Contracts/StAndrews_1/sndobj/sndobj.py" > > , line 2803, in __init__ > > this = _sndobj.new_SndCoreAudio(*args) > > NotImplementedError: Wrong number of arguments for > > overloaded function 'new_SndCoreAudio'. > > Possible C/C++ prototypes are: > > SndCoreAudio(int,int,int,float,SndObj **,UInt32,int > > ,float) > > SndCoreAudio(int,int,int,float,SndObj **,UInt32,int) > > SndCoreAudio(int,int,int,float,SndObj **,UInt32) > > SndCoreAudio(int,int,int,float,SndObj **) > > SndCoreAudio(int,int,int,float) > > SndCoreAudio(int,int,int) > > SndCoreAudio(int,int) > > SndCoreAudio(int) > > SndCoreAudio() > > > > I suspect that the constructor is looking for a C++ Uint32 > > in the 6th argument but where to pick an appropriate one > > from? > > > > if sndobj.DEF_DEV is substituted for the 6th arg the > > following traceback is obtained: > > 22050.0 256 which is reasonable enough as this is another > > function reference. > > > > Python(620,0xa000d000) malloc: *** Deallocation of a > > pointer not malloced: 0x613158; This could be a double > > free(), or free() called with the middle of an allocated > > block; Try setting environment variable MallocHelp to see > > tools to help debug Python(620,0xa000d000) malloc: *** > > Deallocation of a pointer not malloced: 0x709458; This > > could be a double free(), or free() called with the middle > > of an allocated block; Try setting environment variable > > MallocHelp to see tools to help debug > > Python(620,0xa000d000) malloc: *** Deallocation of a > > pointer not malloced: 0x7bdcf0; This could be a double > > free(), or free() called with the middle of an allocated > > block; Try setting environment variable MallocHelp to see > > tools to help debug > > > > I can't see anything obvious in SndCoreAudio.h or > > AudioDefs.i Ed > > > > On 8/10/07, Victor Lazzarini <vic...@nu...> > > > wrote: Try > > > > > > outp = sndobj.SndCoreAudio(2, 512, 4, 32767.0, objsp > > > ,256, 22050.0) > > > > > > There is no sndobj.SND_OUTPUT argument for > > > SndCoreAudio (it always opens full-duplex). > > > > > > Victor > > > > > > > > > > > > > > Thanks for the pointer to the solution however > > > > > > > > now I've removed the constructor > > > > > > > > outp = sndobj.SndCoreAudio() > > > > > > > > and after constructing aif1,aif2 replaced it with > > > > > > > > objs[0]=aif1 > > > > objs[1]=aif2 > > > > objsp = objs.cast() > > > > outp = sndobj.SndCoreAudio(2, 512, 4, 32767.0, objsp) > > > > which as expected still produces output at the wrong > > > > sampling rate however if I extend this to > > > > outp = sndobj.SndCoreAudio(2, 512, 4, 32767.0, objsp , > > > > sndobj.SND_OUTPUT, 256, 22050) > > > > or > > > > outp = sndobj.SndCoreAudio(2, 512, 4, 32767.0, objsp , > > > > 1) or variants in between I get tracebacks similar to > > > this > > > > > File "aif.py", line 20, in <module> > > > > outp = sndobj.SndCoreAudio(2, 512, 4, 32767.0, > > > > objsp, 1) #, 256, 22050) #wrong args number > > > > File > > > > "/Users/edh/Contracts/StAndrews_1/sndobj/sndobj.py" , > > > > line 2803, in __init__ this = > > > > _sndobj.new_SndCoreAudio(*args) NotImplementedError: > > > > Wrong number of arguments for overloaded function > > > > 'new_SndCoreAudio'. Possible C/C++ prototypes are: > > > > SndCoreAudio(int,int,int,float,SndObj **,UInt32 > > > > ,int ,float) > > > > SndCoreAudio(int,int,int,float,SndObj **,UInt32 > > > > ,int) SndCoreAudio(int,int,int,float,SndObj ** > > > > ,UInt32) SndCoreAudio(int,int,int,float,SndObj **) > > > > SndCoreAudio(int,int,int,float) > > > > SndCoreAudio(int,int,int) > > > > SndCoreAudio(int,int) > > > > SndCoreAudio(int) > > > > SndCoreAudio() > > > > > > > > Best > > > > Ed > > > > > > > > On 8/9/07, Victor Lazzarini <vic...@nu...> > > > > > wrote: You will need to set the SR on all objects > > > > > to 22050. It is generally the last argument > > > > > (which defaults to 44100) of each object. You > > > > > have done it with all SndObjs, but it looks > > > > > like you left the SndCoreAudio to its default. > > > > > You need to create it with the right SR. > > > > > > > > > > Victor > > > > > > > > > > > > > > > > > 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 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ---------------------------------------------------------- > > > > --------------- This SF.net email is sponsored by: > > > > > > Splunk Inc. Still grepping through log files to > > > > > > find problems? Stop. Now Search log events and > > > > > > configuration files using AJAX and a browser. > > > > > > Download your FREE copy of Splunk now >> > > > > > > http://get.splunk.com/ > > > > > > _______________________________________________ > > > > > > Sndobj-devel mailing list > > > > Snd...@li... > > > > > > https://lists.sourceforge.net/lists/listinfo/sndobj-devel > > > > > |