Csound Csound-dev Csound-tekno Search About

[Csnd] Re: Re: Re: Re: Re: Re: Re: Re: Re: Querying available audio devices

Date2008-10-27 18:17
Fromvictor
Subject[Csnd] Re: Re: Re: Re: Re: Re: Re: Re: Re: Querying available audio devices
Does not quite work in Python because of the GIL (since
we almost always use performance threads). I have
wrapped manually the callbacks to take care of that. However
I use a certain mechanism to pass data that is probably the
problem that makes it incompatible with CppSound.

Victor
----- Original Message ----- 
From: "Steven Yi" 
To: 
Sent: Monday, October 27, 2008 6:13 PM
Subject: [Csnd] Re: Re: Re: Re: Re: Re: Re: Re: Querying available audio 
devices


> For Java, I'm using the CsoundCallbackWrapper class.  I think Istvan
> put this in a long while ago to get around dealing with pointers in
> Java, but it works well.  I subclass from CsoundCallbackWrapper and
> override the MessageCallback method, and when initializing the object
> pass in a Csound object and call SetMessageCallback on the wrapper,
> like this:
>
>            blueCallbackWrapper = new BlueCallbackWrapper(csound);
>            blueCallbackWrapper.SetMessageCallback();
>
> I'm not sure if this is available in Python, but if so, it might be
> worth checking out (and you can override other methods, like those for
> MIDI in and out, Yield callback, etc.).
>
> steven
>
> On Mon, Oct 27, 2008 at 10:03 AM, victor  wrote:
>> I don't know about CppSound, but the callbacks work fine
>> with the Csound class.
>>
>> Victor
>> ----- Original Message ----- From: "Chuckk Hubbard"
>> 
>> To: 
>> Sent: Monday, October 27, 2008 2:45 PM
>> Subject: [Csnd] Re: Re: Re: Re: Re: Re: Querying available audio devices
>>
>>
>>> Using CppSound instead of Csound, the cs.Compile() line gives me a
>>> segmentation fault and crashes the interpreter.
>>> For me, Csound messages print to the interpreter terminal by default;
>>> I haven't yet been able to stop them.
>>> I used this:
>>>
>>> import csnd
>>> csdlog = ''
>>> def csdsave(s):
>>>   global csdlog
>>>   csdlog += s
>>>
>>> cs = csnd.CppSound()
>>> cs.PreCompile()
>>> cs.SetMessageCallback(csdsave)
>>> cs.Compile("test.csd")
>>>
>>> Python exits.
>>> -Chuckk
>>>
>>> On Mon, Oct 27, 2008 at 3:39 PM, victor  
>>> wrote:
>>>>
>>>> Works here:
>>>>
>>>> import csnd
>>>> cs = csnd.Csound()
>>>>
>>>> cs.PreCompile()
>>>>
>>>> def somefunc(s):
>>>>   print s
>>>>
>>>> cs.SetMessageCallback(somefunc)
>>>>
>>>> cs.Compile("test.csd")
>>>>
>>>> ... messages get printed to the interpreter terminal
>>>>
>>>>
>>>> Victor
>>>>
>>>>
>>>>
>>>>
>>>> ----- Original Message ----- From: "Chuckk Hubbard"
>>>> 
>>>> To: 
>>>> Sent: Monday, October 27, 2008 1:18 PM
>>>> Subject: [Csnd] Re: Re: Re: Re: Querying available audio devices
>>>>
>>>>
>>>>> More precisely, I get:
>>>>>
>>>>>>>> cs.SetPythonMessageCallback(csdlog)
>>>>>
>>>>> Traceback (most recent call last):
>>>>>  File "", line 1, in 
>>>>>  File "/usr/lib/python2.5/csnd.py", line 1737, in
>>>>> SetPythonMessageCallback
>>>>>  return _csnd.Csound_SetPythonMessageCallback(*args)
>>>>> AttributeError: 'module' object has no attribute
>>>>> 'Csound_SetPythonMessageCallback'
>>>>>
>>>>>
>>>>> Looking a little closer it looks like that's actually a problem, not
>>>>> just me doing the wrong thing.  I'll try replacing my csnd.py and
>>>>> _csnd.so files.
>>>>> -Chuckk
>>>>>
>>>>> On Mon, Oct 27, 2008 at 3:08 PM, Chuckk Hubbard
>>>>>  wrote:
>>>>>>
>>>>>> The closest I have available is .setPythonMessageCallback() for
>>>>>> CppSound, and .SetPythonMessageCallback() for Csound class.
>>>>>> .SetPythonMessageCallback() somehow can't find the attribute, 
>>>>>> although
>>>>>> it is listed with dir(CppSound) and help(CppSound), and
>>>>>> .setPythonMessageCallback() takes 1 argument (self), won't take a
>>>>>> function as argument.
>>>>>>
>>>>>> -Chuckk
>>>>>>
>>>>>> On Mon, Oct 27, 2008 at 2:53 PM, victor 
>>>>>> wrote:
>>>>>>>
>>>>>>> Use the Csound() (or derived) class and the
>>>>>>> Csound::SetMessageCallback()
>>>>>>> method.
>>>>>>>
>>>>>>> the callback should be something like
>>>>>>>
>>>>>>> def  mcallback(s):
>>>>>>>  # s is a string
>>>>>>>  # e.g. you can print it
>>>>>>>  print s
>>>>>>>
>>>>>>>
>>>>>>> cs.SetMessageCallback(mcallback)
>>>>>>>
>>>>>>>
>>>>>>> Victor
>>>>>>> ----- Original Message ----- From: "Chuckk Hubbard"
>>>>>>> 
>>>>>>> To: 
>>>>>>> Sent: Monday, October 27, 2008 12:04 PM
>>>>>>> Subject: [Csnd] Re: Re: Querying available audio devices
>>>>>>>
>>>>>>>
>>>>>>>> Sounds like a plan.  I'll let people choose from whichever modules
>>>>>>>> are
>>>>>>>> available for their platform and then see the devices for whatever
>>>>>>>> they choose.
>>>>>>>>
>>>>>>>> I tried directing both stderr and stdout to file objects, and 
>>>>>>>> didn't
>>>>>>>> pick up the Csound output from cs.compile().  Anyone know how I do
>>>>>>>> that in Python?
>>>>>>>>
>>>>>>>> -Chuckk
>>>>>>>>
>>>>>>>> On Mon, Oct 27, 2008 at 11:12 AM, victor 
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> For -+rtaudio you can just check the platform OS and the
>>>>>>>>> modules for each are well-defined (ie portaudio and alsa for 
>>>>>>>>> linux,
>>>>>>>>> etc).
>>>>>>>>>
>>>>>>>>> The only way I think is to run csound with -odac99, then parse
>>>>>>>>> the message output.
>>>>>>>>>
>>>>>>>>> Perhaps an API function to do this might be possible, but it
>>>>>>>>> will need to be implemented by the IO modules.
>>>>>>>>>
>>>>>>>>> Regards
>>>>>>>>>
>>>>>>>>> Victor
>>>>>>>>>
>>>>>>>>> ----- Original Message ----- From: "Chuckk Hubbard"
>>>>>>>>> 
>>>>>>>>> To: "Csound List" 
>>>>>>>>> Sent: Monday, October 27, 2008 7:54 AM
>>>>>>>>> Subject: [Csnd] Querying available audio devices
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Is there a way to do this with the API?  To build a list of
>>>>>>>>>> available
>>>>>>>>>> devices to show in my app?
>>>>>>>>>> I think it would have to know possible values for both -+rtaudio
>>>>>>>>>> and
>>>>>>>>>> -odac, no?
>>>>>>>>>>
>>>>>>>>>> -Chuckk
>>>>>>>>>> --
>>>>>>>>>> http://www.badmuthahubbard.com
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Send bugs reports to this list.
>>>>>>>>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>>>>>>>>>> "unsubscribe
>>>>>>>>>> csound"
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Send bugs reports to this list.
>>>>>>>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>>>>>>>>> "unsubscribe
>>>>>>>>> csound"
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> http://www.badmuthahubbard.com
>>>>>>>>
>>>>>>>>
>>>>>>>> Send bugs reports to this list.
>>>>>>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>>>>>>>> "unsubscribe
>>>>>>>> csound"
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Send bugs reports to this list.
>>>>>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>>>>>>> "unsubscribe
>>>>>>> csound"
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> http://www.badmuthahubbard.com
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> http://www.badmuthahubbard.com
>>>>>
>>>>>
>>>>> Send bugs reports to this list.
>>>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body 
>>>>> "unsubscribe
>>>>> csound"
>>>>
>>>>
>>>>
>>>> Send bugs reports to this list.
>>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body 
>>>> "unsubscribe
>>>> csound"
>>>>
>>>
>>>
>>>
>>> --
>>> http://www.badmuthahubbard.com
>>>
>>>
>>> Send bugs reports to this list.
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>>> csound"
>>
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe 
> csound" 


Date2008-10-27 18:26
From"Steven Yi"
Subject[Csnd] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Querying available audio devices
AttachmentsNone