Csound Csound-dev Csound-tekno Search About

[Cs-dev] Python arguments from C++ documentation

Date2010-01-26 15:39
FromChuckk Hubbard
Subject[Cs-dev] Python arguments from C++ documentation
Hi.
Sorry if this is the wrong list, happy to switch if it is.
I've been asking questions on the users' list lately on various
things, but one problem I keep running into is that I'm not sure how
to translate the C++ API documentation to Python arguments. For
instance, from the reference manual:
PUBLIC void csoundSetOutputValueCallback  	(  	CSOUND *   	,
		void(*)(CSOUND *, const char *channelName, MYFLT value)
	outputValueCalback_
	) 	

The same function through Python's help command:
SetOutputValueCallback(self, PyObject pyfunc)
But I can't get it to take by offering it a Python function as
argument. No error, but it does nothing.

With this one:
PUBLIC void csoundSetChannelIOCallback  	(  	CSOUND *   	,
		CsoundChannelIOCallback_t  	func	
	) 	

I check the structure of CsoundChannelIOCallback_t and find;
typedef void(* CsoundChannelIOCallback_t)(CSOUND *csound, const char
*channelName, MYFLT *channelValuePtr, int channelType)

And Python's help function gives:
SetChannelIOCallback(self, CsoundChannelIOCallback_t func)

So in one case I'm wondering how a pointer as argument translates to
Python, and in the other, how to match the type
CsoundChannelIOCallback in Python. It seems like it only wants the
function, and there's no way to enter the channel name?

Sorry if these are basic questions. Understanding this will open up
lots of powerful-sounding capabilities that I've skipped until now.

Thanks.
-Chuckk




-- 
http://www.badmuthahubbard.com

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-01-26 18:09
FromVictor Lazzarini
SubjectRe: [Cs-dev] Python arguments from C++ documentation
Why do you need to set a callback? Can't you just use the GetChannel()/ 
SetChannel() methods?

The csoundSetChannelIOCallback() function is not yet implemented (we  
should mark it as that!).

For Python, I have wrapped Csound::SetOutputValueCallback() to take a  
python callback instead of a C function pointer. It should work but I  
have not tested it.

This callback will be called every time an opcode outvalue is used.  
You will need to then maintain and parse a list of channels to access  
the correct one. If you want a C example of how it's done lookup  
csoundapi_tilde sources.


Victor
On 26 Jan 2010, at 15:39, Chuckk Hubbard wrote:

> Hi.
> Sorry if this is the wrong list, happy to switch if it is.
> I've been asking questions on the users' list lately on various
> things, but one problem I keep running into is that I'm not sure how
> to translate the C++ API documentation to Python arguments. For
> instance, from the reference manual:
> PUBLIC void csoundSetOutputValueCallback  	(  	CSOUND *   	,
> 		void(*)(CSOUND *, const char *channelName, MYFLT value)
> 	outputValueCalback_
> 	) 	
>
> The same function through Python's help command:
> SetOutputValueCallback(self, PyObject pyfunc)
> But I can't get it to take by offering it a Python function as
> argument. No error, but it does nothing.
>
> With this one:
> PUBLIC void csoundSetChannelIOCallback  	(  	CSOUND *   	,
> 		CsoundChannelIOCallback_t  	func	
> 	) 	
>
> I check the structure of CsoundChannelIOCallback_t and find;
> typedef void(* CsoundChannelIOCallback_t)(CSOUND *csound, const char
> *channelName, MYFLT *channelValuePtr, int channelType)
>
> And Python's help function gives:
> SetChannelIOCallback(self, CsoundChannelIOCallback_t func)
>
> So in one case I'm wondering how a pointer as argument translates to
> Python, and in the other, how to match the type
> CsoundChannelIOCallback in Python. It seems like it only wants the
> function, and there's no way to enter the channel name?
>
> Sorry if these are basic questions. Understanding this will open up
> lots of powerful-sounding capabilities that I've skipped until now.
>
> Thanks.
> -Chuckk
>
>
>
>
> -- 
> http://www.badmuthahubbard.com
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the  
> business
> Choose flexible plans and management services without long-term  
> contracts
> Personal 24x7 support from experience hosting pros just a phone call  
> away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-01-26 22:35
FromChuckk Hubbard
SubjectRe: [Cs-dev] Python arguments from C++ documentation
Okay, thanks Victor.
My problem with GetChannel() is that I want discrete messages, not
continuously changing values. I want to send MIDI notes from these
callbacks through other Csound instances (I hope), and it seems like a
waste of CPU to have Python checking for changes so rapidly. I guess
any way it works there will be timing problems according to -b, but if
I understand correctly, the callback of SetOutputValueCallback() would
be initiated from Csound, whereas GetChannel() has to be initiated by
Python. Of course, if you tell me there won't be any noticeable
difference, then I'll try it.

-Chuckk


On Tue, Jan 26, 2010 at 8:09 PM, Victor Lazzarini
 wrote:
> Why do you need to set a callback? Can't you just use the GetChannel()/
> SetChannel() methods?
>
> The csoundSetChannelIOCallback() function is not yet implemented (we
> should mark it as that!).
>
> For Python, I have wrapped Csound::SetOutputValueCallback() to take a
> python callback instead of a C function pointer. It should work but I
> have not tested it.
>
> This callback will be called every time an opcode outvalue is used.
> You will need to then maintain and parse a list of channels to access
> the correct one. If you want a C example of how it's done lookup
> csoundapi_tilde sources.
>
>
> Victor
> On 26 Jan 2010, at 15:39, Chuckk Hubbard wrote:
>
>> Hi.
>> Sorry if this is the wrong list, happy to switch if it is.
>> I've been asking questions on the users' list lately on various
>> things, but one problem I keep running into is that I'm not sure how
>> to translate the C++ API documentation to Python arguments. For
>> instance, from the reference manual:
>> PUBLIC void csoundSetOutputValueCallback      (       CSOUND *        ,
>>               void(*)(CSOUND *, const char *channelName, MYFLT value)
>>       outputValueCalback_
>>       )
>>
>> The same function through Python's help command:
>> SetOutputValueCallback(self, PyObject pyfunc)
>> But I can't get it to take by offering it a Python function as
>> argument. No error, but it does nothing.
>>
>> With this one:
>> PUBLIC void csoundSetChannelIOCallback        (       CSOUND *        ,
>>               CsoundChannelIOCallback_t       func
>>       )
>>
>> I check the structure of CsoundChannelIOCallback_t and find;
>> typedef void(* CsoundChannelIOCallback_t)(CSOUND *csound, const char
>> *channelName, MYFLT *channelValuePtr, int channelType)
>>
>> And Python's help function gives:
>> SetChannelIOCallback(self, CsoundChannelIOCallback_t func)
>>
>> So in one case I'm wondering how a pointer as argument translates to
>> Python, and in the other, how to match the type
>> CsoundChannelIOCallback in Python. It seems like it only wants the
>> function, and there's no way to enter the channel name?
>>
>> Sorry if these are basic questions. Understanding this will open up
>> lots of powerful-sounding capabilities that I've skipped until now.
>>
>> Thanks.
>> -Chuckk
>>
>>
>>
>>
>> --
>> http://www.badmuthahubbard.com
>>
>> ------------------------------------------------------------------------------
>> The Planet: dedicated and managed hosting, cloud storage, colocation
>> Stay online with enterprise data centers and the best network in the
>> business
>> Choose flexible plans and management services without long-term
>> contracts
>> Personal 24x7 support from experience hosting pros just a phone call
>> away.
>> http://p.sf.net/sfu/theplanet-com
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>



-- 
http://www.badmuthahubbard.com

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
h

Date2010-01-27 10:35
FromVictor Lazzarini
SubjectRe: [Cs-dev] Python arguments from C++ documentation
I don't think there will be a lot of difference though, because Csound  
will call the python callback for every instance of outvalue, no  
matter what and this will happen at every k-period, unless you bypass  
outvalue in Csound using if-then (etc).

Victor


On 26 Jan 2010, at 22:35, Chuckk Hubbard wrote:

> Okay, thanks Victor.
> My problem with GetChannel() is that I want discrete messages, not
> continuously changing values. I want to send MIDI notes from these
> callbacks through other Csound instances (I hope), and it seems like a
> waste of CPU to have Python checking for changes so rapidly. I guess
> any way it works there will be timing problems according to -b, but if
> I understand correctly, the callback of SetOutputValueCallback() would
> be initiated from Csound, whereas GetChannel() has to be initiated by
> Python. Of course, if you tell me there won't be any noticeable
> difference, then I'll try it.
>
> -Chuckk
>
>
> On Tue, Jan 26, 2010 at 8:09 PM, Victor Lazzarini
>  wrote:
>> Why do you need to set a callback? Can't you just use the  
>> GetChannel()/
>> SetChannel() methods?
>>
>> The csoundSetChannelIOCallback() function is not yet implemented (we
>> should mark it as that!).
>>
>> For Python, I have wrapped Csound::SetOutputValueCallback() to take a
>> python callback instead of a C function pointer. It should work but I
>> have not tested it.
>>
>> This callback will be called every time an opcode outvalue is used.
>> You will need to then maintain and parse a list of channels to access
>> the correct one. If you want a C example of how it's done lookup
>> csoundapi_tilde sources.
>>
>>
>> Victor
>> On 26 Jan 2010, at 15:39, Chuckk Hubbard wrote:
>>
>>> Hi.
>>> Sorry if this is the wrong list, happy to switch if it is.
>>> I've been asking questions on the users' list lately on various
>>> things, but one problem I keep running into is that I'm not sure how
>>> to translate the C++ API documentation to Python arguments. For
>>> instance, from the reference manual:
>>> PUBLIC void csoundSetOutputValueCallback      (       CSOUND  
>>> *        ,
>>>               void(*)(CSOUND *, const char *channelName, MYFLT  
>>> value)
>>>       outputValueCalback_
>>>       )
>>>
>>> The same function through Python's help command:
>>> SetOutputValueCallback(self, PyObject pyfunc)
>>> But I can't get it to take by offering it a Python function as
>>> argument. No error, but it does nothing.
>>>
>>> With this one:
>>> PUBLIC void csoundSetChannelIOCallback        (       CSOUND  
>>> *        ,
>>>               CsoundChannelIOCallback_t       func
>>>       )
>>>
>>> I check the structure of CsoundChannelIOCallback_t and find;
>>> typedef void(* CsoundChannelIOCallback_t)(CSOUND *csound, const char
>>> *channelName, MYFLT *channelValuePtr, int channelType)
>>>
>>> And Python's help function gives:
>>> SetChannelIOCallback(self, CsoundChannelIOCallback_t func)
>>>
>>> So in one case I'm wondering how a pointer as argument translates to
>>> Python, and in the other, how to match the type
>>> CsoundChannelIOCallback in Python. It seems like it only wants the
>>> function, and there's no way to enter the channel name?
>>>
>>> Sorry if these are basic questions. Understanding this will open up
>>> lots of powerful-sounding capabilities that I've skipped until now.
>>>
>>> Thanks.
>>> -Chuckk
>>>
>>>
>>>
>>>
>>> --
>>> http://www.badmuthahubbard.com
>>>
>>> ------------------------------------------------------------------------------
>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>> Stay online with enterprise data centers and the best network in the
>>> business
>>> Choose flexible plans and management services without long-term
>>> contracts
>>> Personal 24x7 support from experience hosting pros just a phone call
>>> away.
>>> http://p.sf.net/sfu/theplanet-com
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>> ------------------------------------------------------------------------------
>> The Planet: dedicated and managed hosting, cloud storage, colocation
>> Stay online with enterprise data centers and the best network in  
>> the business
>> Choose flexible plans and management services without long-term  
>> contracts
>> Personal 24x7 support from experience hosting pros just a phone  
>> call away.
>> http://p.sf.net/sfu/theplanet-com
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>
>
>
> -- 
> http://www.badmuthahubbard.com
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the  
> business
> Choose flexible plans and management services without long-term  
> contracts
> Personal 24x7 support from experience hosting pros just a phone call  
> away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-01-27 12:37
FromChuckk Hubbard
SubjectRe: [Cs-dev] Python arguments from C++ documentation
Since the only job of the calling instance for MIDI is to trigger
notes from other instances, synchronized with its own audio output, I
was thinking of using turnoff right after outvalue.

-Chuckk

On Wed, Jan 27, 2010 at 12:35 PM, Victor Lazzarini
 wrote:
> I don't think there will be a lot of difference though, because Csound
> will call the python callback for every instance of outvalue, no
> matter what and this will happen at every k-period, unless you bypass
> outvalue in Csound using if-then (etc).
>
> Victor
>
>
> On 26 Jan 2010, at 22:35, Chuckk Hubbard wrote:
>
>> Okay, thanks Victor.
>> My problem with GetChannel() is that I want discrete messages, not
>> continuously changing values. I want to send MIDI notes from these
>> callbacks through other Csound instances (I hope), and it seems like a
>> waste of CPU to have Python checking for changes so rapidly. I guess
>> any way it works there will be timing problems according to -b, but if
>> I understand correctly, the callback of SetOutputValueCallback() would
>> be initiated from Csound, whereas GetChannel() has to be initiated by
>> Python. Of course, if you tell me there won't be any noticeable
>> difference, then I'll try it.
>>
>> -Chuckk
>>
>>
>> On Tue, Jan 26, 2010 at 8:09 PM, Victor Lazzarini
>>  wrote:
>>> Why do you need to set a callback? Can't you just use the
>>> GetChannel()/
>>> SetChannel() methods?
>>>
>>> The csoundSetChannelIOCallback() function is not yet implemented (we
>>> should mark it as that!).
>>>
>>> For Python, I have wrapped Csound::SetOutputValueCallback() to take a
>>> python callback instead of a C function pointer. It should work but I
>>> have not tested it.
>>>
>>> This callback will be called every time an opcode outvalue is used.
>>> You will need to then maintain and parse a list of channels to access
>>> the correct one. If you want a C example of how it's done lookup
>>> csoundapi_tilde sources.
>>>
>>>
>>> Victor
>>> On 26 Jan 2010, at 15:39, Chuckk Hubbard wrote:
>>>
>>>> Hi.
>>>> Sorry if this is the wrong list, happy to switch if it is.
>>>> I've been asking questions on the users' list lately on various
>>>> things, but one problem I keep running into is that I'm not sure how
>>>> to translate the C++ API documentation to Python arguments. For
>>>> instance, from the reference manual:
>>>> PUBLIC void csoundSetOutputValueCallback      (       CSOUND
>>>> *        ,
>>>>               void(*)(CSOUND *, const char *channelName, MYFLT
>>>> value)
>>>>       outputValueCalback_
>>>>       )
>>>>
>>>> The same function through Python's help command:
>>>> SetOutputValueCallback(self, PyObject pyfunc)
>>>> But I can't get it to take by offering it a Python function as
>>>> argument. No error, but it does nothing.
>>>>
>>>> With this one:
>>>> PUBLIC void csoundSetChannelIOCallback        (       CSOUND
>>>> *        ,
>>>>               CsoundChannelIOCallback_t       func
>>>>       )
>>>>
>>>> I check the structure of CsoundChannelIOCallback_t and find;
>>>> typedef void(* CsoundChannelIOCallback_t)(CSOUND *csound, const char
>>>> *channelName, MYFLT *channelValuePtr, int channelType)
>>>>
>>>> And Python's help function gives:
>>>> SetChannelIOCallback(self, CsoundChannelIOCallback_t func)
>>>>
>>>> So in one case I'm wondering how a pointer as argument translates to
>>>> Python, and in the other, how to match the type
>>>> CsoundChannelIOCallback in Python. It seems like it only wants the
>>>> function, and there's no way to enter the channel name?
>>>>
>>>> Sorry if these are basic questions. Understanding this will open up
>>>> lots of powerful-sounding capabilities that I've skipped until now.
>>>>
>>>> Thanks.
>>>> -Chuckk
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> http://www.badmuthahubbard.com
>>>>
>>>> ------------------------------------------------------------------------------
>>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>>> Stay online with enterprise data centers and the best network in the
>>>> business
>>>> Choose flexible plans and management services without long-term
>>>> contracts
>>>> Personal 24x7 support from experience hosting pros just a phone call
>>>> away.
>>>> http://p.sf.net/sfu/theplanet-com
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>> Stay online with enterprise data centers and the best network in
>>> the business
>>> Choose flexible plans and management services without long-term
>>> contracts
>>> Personal 24x7 support from experience hosting pros just a phone
>>> call away.
>>> http://p.sf.net/sfu/theplanet-com
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>
>>
>>
>> --
>> http://www.badmuthahubbard.com
>>
>> ------------------------------------------------------------------------------
>> The Planet: dedicated and managed hosting, cloud storage, colocation
>> Stay online with enterprise data centers and the best network in the
>> business
>> Choose flexible plans and management services without long-term
>> contracts
>> Personal 24x7 support from experience hosting pros just a phone call
>> away.
>> http://p.sf.net/sfu/theplanet-com
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>



-- 
http://www.badmuthahubbard.com

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/li

Date2010-01-27 12:56
FromVictor Lazzarini
SubjectRe: [Cs-dev] Python arguments from C++ documentation
and is  this instrument instantiated by Python or by csound score?
On 27 Jan 2010, at 12:37, Chuckk Hubbard wrote:

> Since the only job of the calling instance for MIDI is to trigger
> notes from other instances, synchronized with its own audio output, I
> was thinking of using turnoff right after outvalue.
>
> -Chuckk
>
> On Wed, Jan 27, 2010 at 12:35 PM, Victor Lazzarini
>  wrote:
>> I don't think there will be a lot of difference though, because  
>> Csound
>> will call the python callback for every instance of outvalue, no
>> matter what and this will happen at every k-period, unless you bypass
>> outvalue in Csound using if-then (etc).
>>
>> Victor
>>
>>
>> On 26 Jan 2010, at 22:35, Chuckk Hubbard wrote:
>>
>>> Okay, thanks Victor.
>>> My problem with GetChannel() is that I want discrete messages, not
>>> continuously changing values. I want to send MIDI notes from these
>>> callbacks through other Csound instances (I hope), and it seems  
>>> like a
>>> waste of CPU to have Python checking for changes so rapidly. I guess
>>> any way it works there will be timing problems according to -b,  
>>> but if
>>> I understand correctly, the callback of SetOutputValueCallback()  
>>> would
>>> be initiated from Csound, whereas GetChannel() has to be initiated  
>>> by
>>> Python. Of course, if you tell me there won't be any noticeable
>>> difference, then I'll try it.
>>>
>>> -Chuckk
>>>
>>>
>>> On Tue, Jan 26, 2010 at 8:09 PM, Victor Lazzarini
>>>  wrote:
>>>> Why do you need to set a callback? Can't you just use the
>>>> GetChannel()/
>>>> SetChannel() methods?
>>>>
>>>> The csoundSetChannelIOCallback() function is not yet implemented  
>>>> (we
>>>> should mark it as that!).
>>>>
>>>> For Python, I have wrapped Csound::SetOutputValueCallback() to  
>>>> take a
>>>> python callback instead of a C function pointer. It should work  
>>>> but I
>>>> have not tested it.
>>>>
>>>> This callback will be called every time an opcode outvalue is used.
>>>> You will need to then maintain and parse a list of channels to  
>>>> access
>>>> the correct one. If you want a C example of how it's done lookup
>>>> csoundapi_tilde sources.
>>>>
>>>>
>>>> Victor
>>>> On 26 Jan 2010, at 15:39, Chuckk Hubbard wrote:
>>>>
>>>>> Hi.
>>>>> Sorry if this is the wrong list, happy to switch if it is.
>>>>> I've been asking questions on the users' list lately on various
>>>>> things, but one problem I keep running into is that I'm not sure  
>>>>> how
>>>>> to translate the C++ API documentation to Python arguments. For
>>>>> instance, from the reference manual:
>>>>> PUBLIC void csoundSetOutputValueCallback      (       CSOUND
>>>>> *        ,
>>>>>               void(*)(CSOUND *, const char *channelName, MYFLT
>>>>> value)
>>>>>       outputValueCalback_
>>>>>       )
>>>>>
>>>>> The same function through Python's help command:
>>>>> SetOutputValueCallback(self, PyObject pyfunc)
>>>>> But I can't get it to take by offering it a Python function as
>>>>> argument. No error, but it does nothing.
>>>>>
>>>>> With this one:
>>>>> PUBLIC void csoundSetChannelIOCallback        (       CSOUND
>>>>> *        ,
>>>>>               CsoundChannelIOCallback_t       func
>>>>>       )
>>>>>
>>>>> I check the structure of CsoundChannelIOCallback_t and find;
>>>>> typedef void(* CsoundChannelIOCallback_t)(CSOUND *csound, const  
>>>>> char
>>>>> *channelName, MYFLT *channelValuePtr, int channelType)
>>>>>
>>>>> And Python's help function gives:
>>>>> SetChannelIOCallback(self, CsoundChannelIOCallback_t func)
>>>>>
>>>>> So in one case I'm wondering how a pointer as argument  
>>>>> translates to
>>>>> Python, and in the other, how to match the type
>>>>> CsoundChannelIOCallback in Python. It seems like it only wants the
>>>>> function, and there's no way to enter the channel name?
>>>>>
>>>>> Sorry if these are basic questions. Understanding this will open  
>>>>> up
>>>>> lots of powerful-sounding capabilities that I've skipped until  
>>>>> now.
>>>>>
>>>>> Thanks.
>>>>> -Chuckk
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> http://www.badmuthahubbard.com
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> The Planet: dedicated and managed hosting, cloud storage,  
>>>>> colocation
>>>>> Stay online with enterprise data centers and the best network in  
>>>>> the
>>>>> business
>>>>> Choose flexible plans and management services without long-term
>>>>> contracts
>>>>> Personal 24x7 support from experience hosting pros just a phone  
>>>>> call
>>>>> away.
>>>>> http://p.sf.net/sfu/theplanet-com
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> The Planet: dedicated and managed hosting, cloud storage,  
>>>> colocation
>>>> Stay online with enterprise data centers and the best network in
>>>> the business
>>>> Choose flexible plans and management services without long-term
>>>> contracts
>>>> Personal 24x7 support from experience hosting pros just a phone
>>>> call away.
>>>> http://p.sf.net/sfu/theplanet-com
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>
>>>
>>>
>>> --
>>> http://www.badmuthahubbard.com
>>>
>>> ------------------------------------------------------------------------------
>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>> Stay online with enterprise data centers and the best network in the
>>> business
>>> Choose flexible plans and management services without long-term
>>> contracts
>>> Personal 24x7 support from experience hosting pros just a phone call
>>> away.
>>> http://p.sf.net/sfu/theplanet-com
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>> ------------------------------------------------------------------------------
>> The Planet: dedicated and managed hosting, cloud storage, colocation
>> Stay online with enterprise data centers and the best network in  
>> the business
>> Choose flexible plans and management services without long-term  
>> contracts
>> Personal 24x7 support from experience hosting pros just a phone  
>> call away.
>> http://p.sf.net/sfu/theplanet-com
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>
>
>
> -- 
> http://www.badmuthahubbard.com
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the  
> business
> Choose flexible plans and management services without long-term  
> contracts
> Personal 24x7 support from experience hosting pros just a phone call  
> away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-01-27 17:14
FromChuckk Hubbard
SubjectRe: [Cs-dev] Python arguments from C++ documentation
It's currently done by Csound score, for a couple of reasons. I give
the Csound-based audio engine a higher priority, so I figured the
timing was better handled within Csound. Also, I didn't want to bother
calculating tempo in Python. Third, so folks can easily export a piece
as csd for external editing.
Maybe OSC would be the way to go for now, as someone suggested before.
Thanks again.
-Chuckk

On Wed, Jan 27, 2010 at 2:56 PM, Victor Lazzarini
 wrote:
> and is  this instrument instantiated by Python or by csound score?
> On 27 Jan 2010, at 12:37, Chuckk Hubbard wrote:
>
>> Since the only job of the calling instance for MIDI is to trigger
>> notes from other instances, synchronized with its own audio output, I
>> was thinking of using turnoff right after outvalue.
>>
>> -Chuckk
>>
>> On Wed, Jan 27, 2010 at 12:35 PM, Victor Lazzarini
>>  wrote:
>>> I don't think there will be a lot of difference though, because
>>> Csound
>>> will call the python callback for every instance of outvalue, no
>>> matter what and this will happen at every k-period, unless you bypass
>>> outvalue in Csound using if-then (etc).
>>>
>>> Victor
>>>
>>>
>>> On 26 Jan 2010, at 22:35, Chuckk Hubbard wrote:
>>>
>>>> Okay, thanks Victor.
>>>> My problem with GetChannel() is that I want discrete messages, not
>>>> continuously changing values. I want to send MIDI notes from these
>>>> callbacks through other Csound instances (I hope), and it seems
>>>> like a
>>>> waste of CPU to have Python checking for changes so rapidly. I guess
>>>> any way it works there will be timing problems according to -b,
>>>> but if
>>>> I understand correctly, the callback of SetOutputValueCallback()
>>>> would
>>>> be initiated from Csound, whereas GetChannel() has to be initiated
>>>> by
>>>> Python. Of course, if you tell me there won't be any noticeable
>>>> difference, then I'll try it.
>>>>
>>>> -Chuckk
>>>>
>>>>
>>>> On Tue, Jan 26, 2010 at 8:09 PM, Victor Lazzarini
>>>>  wrote:
>>>>> Why do you need to set a callback? Can't you just use the
>>>>> GetChannel()/
>>>>> SetChannel() methods?
>>>>>
>>>>> The csoundSetChannelIOCallback() function is not yet implemented
>>>>> (we
>>>>> should mark it as that!).
>>>>>
>>>>> For Python, I have wrapped Csound::SetOutputValueCallback() to
>>>>> take a
>>>>> python callback instead of a C function pointer. It should work
>>>>> but I
>>>>> have not tested it.
>>>>>
>>>>> This callback will be called every time an opcode outvalue is used.
>>>>> You will need to then maintain and parse a list of channels to
>>>>> access
>>>>> the correct one. If you want a C example of how it's done lookup
>>>>> csoundapi_tilde sources.
>>>>>
>>>>>
>>>>> Victor
>>>>> On 26 Jan 2010, at 15:39, Chuckk Hubbard wrote:
>>>>>
>>>>>> Hi.
>>>>>> Sorry if this is the wrong list, happy to switch if it is.
>>>>>> I've been asking questions on the users' list lately on various
>>>>>> things, but one problem I keep running into is that I'm not sure
>>>>>> how
>>>>>> to translate the C++ API documentation to Python arguments. For
>>>>>> instance, from the reference manual:
>>>>>> PUBLIC void csoundSetOutputValueCallback      (       CSOUND
>>>>>> *        ,
>>>>>>               void(*)(CSOUND *, const char *channelName, MYFLT
>>>>>> value)
>>>>>>       outputValueCalback_
>>>>>>       )
>>>>>>
>>>>>> The same function through Python's help command:
>>>>>> SetOutputValueCallback(self, PyObject pyfunc)
>>>>>> But I can't get it to take by offering it a Python function as
>>>>>> argument. No error, but it does nothing.
>>>>>>
>>>>>> With this one:
>>>>>> PUBLIC void csoundSetChannelIOCallback        (       CSOUND
>>>>>> *        ,
>>>>>>               CsoundChannelIOCallback_t       func
>>>>>>       )
>>>>>>
>>>>>> I check the structure of CsoundChannelIOCallback_t and find;
>>>>>> typedef void(* CsoundChannelIOCallback_t)(CSOUND *csound, const
>>>>>> char
>>>>>> *channelName, MYFLT *channelValuePtr, int channelType)
>>>>>>
>>>>>> And Python's help function gives:
>>>>>> SetChannelIOCallback(self, CsoundChannelIOCallback_t func)
>>>>>>
>>>>>> So in one case I'm wondering how a pointer as argument
>>>>>> translates to
>>>>>> Python, and in the other, how to match the type
>>>>>> CsoundChannelIOCallback in Python. It seems like it only wants the
>>>>>> function, and there's no way to enter the channel name?
>>>>>>
>>>>>> Sorry if these are basic questions. Understanding this will open
>>>>>> up
>>>>>> lots of powerful-sounding capabilities that I've skipped until
>>>>>> now.
>>>>>>
>>>>>> Thanks.
>>>>>> -Chuckk
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> http://www.badmuthahubbard.com
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>> colocation
>>>>>> Stay online with enterprise data centers and the best network in
>>>>>> the
>>>>>> business
>>>>>> Choose flexible plans and management services without long-term
>>>>>> contracts
>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>> call
>>>>>> away.
>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>> colocation
>>>>> Stay online with enterprise data centers and the best network in
>>>>> the business
>>>>> Choose flexible plans and management services without long-term
>>>>> contracts
>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>> call away.
>>>>> http://p.sf.net/sfu/theplanet-com
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> http://www.badmuthahubbard.com
>>>>
>>>> ------------------------------------------------------------------------------
>>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>>> Stay online with enterprise data centers and the best network in the
>>>> business
>>>> Choose flexible plans and management services without long-term
>>>> contracts
>>>> Personal 24x7 support from experience hosting pros just a phone call
>>>> away.
>>>> http://p.sf.net/sfu/theplanet-com
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>> Stay online with enterprise data centers and the best network in
>>> the business
>>> Choose flexible plans and management services without long-term
>>> contracts
>>> Personal 24x7 support from experience hosting pros just a phone
>>> call away.
>>> http://p.sf.net/sfu/theplanet-com
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>
>>
>>
>> --
>> http://www.badmuthahubbard.com
>>
>> ------------------------------------------------------------------------------
>> The Planet: dedicated and managed hosting, cloud storage, colocation
>> Stay online with enterprise data centers and the best network in the
>> business
>> Choose flexible plans and management services without long-term
>> contracts
>> Personal 24x7 support from experience hosting pros just a phone call
>> away.
>> http://p.sf.net/sfu/theplanet-com
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>



-- 
http://www.badmuthahubbard.com

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/c

Date2010-01-27 17:19
FromVictor Lazzarini
SubjectRe: [Cs-dev] Python arguments from C++ documentation
Anyway, the outvalue callback should do the trick. I am not sure why  
nothing is happening.
I'll try and investigate.

Victor
On 27 Jan 2010, at 17:14, Chuckk Hubbard wrote:

> It's currently done by Csound score, for a couple of reasons. I give
> the Csound-based audio engine a higher priority, so I figured the
> timing was better handled within Csound. Also, I didn't want to bother
> calculating tempo in Python. Third, so folks can easily export a piece
> as csd for external editing.
> Maybe OSC would be the way to go for now, as someone suggested before.
> Thanks again.
> -Chuckk
>
> On Wed, Jan 27, 2010 at 2:56 PM, Victor Lazzarini
>  wrote:
>> and is  this instrument instantiated by Python or by csound score?
>> On 27 Jan 2010, at 12:37, Chuckk Hubbard wrote:
>>
>>> Since the only job of the calling instance for MIDI is to trigger
>>> notes from other instances, synchronized with its own audio  
>>> output, I
>>> was thinking of using turnoff right after outvalue.
>>>
>>> -Chuckk
>>>
>>> On Wed, Jan 27, 2010 at 12:35 PM, Victor Lazzarini
>>>  wrote:
>>>> I don't think there will be a lot of difference though, because
>>>> Csound
>>>> will call the python callback for every instance of outvalue, no
>>>> matter what and this will happen at every k-period, unless you  
>>>> bypass
>>>> outvalue in Csound using if-then (etc).
>>>>
>>>> Victor
>>>>
>>>>
>>>> On 26 Jan 2010, at 22:35, Chuckk Hubbard wrote:
>>>>
>>>>> Okay, thanks Victor.
>>>>> My problem with GetChannel() is that I want discrete messages, not
>>>>> continuously changing values. I want to send MIDI notes from these
>>>>> callbacks through other Csound instances (I hope), and it seems
>>>>> like a
>>>>> waste of CPU to have Python checking for changes so rapidly. I  
>>>>> guess
>>>>> any way it works there will be timing problems according to -b,
>>>>> but if
>>>>> I understand correctly, the callback of SetOutputValueCallback()
>>>>> would
>>>>> be initiated from Csound, whereas GetChannel() has to be initiated
>>>>> by
>>>>> Python. Of course, if you tell me there won't be any noticeable
>>>>> difference, then I'll try it.
>>>>>
>>>>> -Chuckk
>>>>>
>>>>>
>>>>> On Tue, Jan 26, 2010 at 8:09 PM, Victor Lazzarini
>>>>>  wrote:
>>>>>> Why do you need to set a callback? Can't you just use the
>>>>>> GetChannel()/
>>>>>> SetChannel() methods?
>>>>>>
>>>>>> The csoundSetChannelIOCallback() function is not yet implemented
>>>>>> (we
>>>>>> should mark it as that!).
>>>>>>
>>>>>> For Python, I have wrapped Csound::SetOutputValueCallback() to
>>>>>> take a
>>>>>> python callback instead of a C function pointer. It should work
>>>>>> but I
>>>>>> have not tested it.
>>>>>>
>>>>>> This callback will be called every time an opcode outvalue is  
>>>>>> used.
>>>>>> You will need to then maintain and parse a list of channels to
>>>>>> access
>>>>>> the correct one. If you want a C example of how it's done lookup
>>>>>> csoundapi_tilde sources.
>>>>>>
>>>>>>
>>>>>> Victor
>>>>>> On 26 Jan 2010, at 15:39, Chuckk Hubbard wrote:
>>>>>>
>>>>>>> Hi.
>>>>>>> Sorry if this is the wrong list, happy to switch if it is.
>>>>>>> I've been asking questions on the users' list lately on various
>>>>>>> things, but one problem I keep running into is that I'm not sure
>>>>>>> how
>>>>>>> to translate the C++ API documentation to Python arguments. For
>>>>>>> instance, from the reference manual:
>>>>>>> PUBLIC void csoundSetOutputValueCallback      (       CSOUND
>>>>>>> *        ,
>>>>>>>               void(*)(CSOUND *, const char *channelName, MYFLT
>>>>>>> value)
>>>>>>>       outputValueCalback_
>>>>>>>       )
>>>>>>>
>>>>>>> The same function through Python's help command:
>>>>>>> SetOutputValueCallback(self, PyObject pyfunc)
>>>>>>> But I can't get it to take by offering it a Python function as
>>>>>>> argument. No error, but it does nothing.
>>>>>>>
>>>>>>> With this one:
>>>>>>> PUBLIC void csoundSetChannelIOCallback        (       CSOUND
>>>>>>> *        ,
>>>>>>>               CsoundChannelIOCallback_t       func
>>>>>>>       )
>>>>>>>
>>>>>>> I check the structure of CsoundChannelIOCallback_t and find;
>>>>>>> typedef void(* CsoundChannelIOCallback_t)(CSOUND *csound, const
>>>>>>> char
>>>>>>> *channelName, MYFLT *channelValuePtr, int channelType)
>>>>>>>
>>>>>>> And Python's help function gives:
>>>>>>> SetChannelIOCallback(self, CsoundChannelIOCallback_t func)
>>>>>>>
>>>>>>> So in one case I'm wondering how a pointer as argument
>>>>>>> translates to
>>>>>>> Python, and in the other, how to match the type
>>>>>>> CsoundChannelIOCallback in Python. It seems like it only wants  
>>>>>>> the
>>>>>>> function, and there's no way to enter the channel name?
>>>>>>>
>>>>>>> Sorry if these are basic questions. Understanding this will open
>>>>>>> up
>>>>>>> lots of powerful-sounding capabilities that I've skipped until
>>>>>>> now.
>>>>>>>
>>>>>>> Thanks.
>>>>>>> -Chuckk
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> http://www.badmuthahubbard.com
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>>> colocation
>>>>>>> Stay online with enterprise data centers and the best network in
>>>>>>> the
>>>>>>> business
>>>>>>> Choose flexible plans and management services without long-term
>>>>>>> contracts
>>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>>> call
>>>>>>> away.
>>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>> colocation
>>>>>> Stay online with enterprise data centers and the best network in
>>>>>> the business
>>>>>> Choose flexible plans and management services without long-term
>>>>>> contracts
>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>> call away.
>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> http://www.badmuthahubbard.com
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> The Planet: dedicated and managed hosting, cloud storage,  
>>>>> colocation
>>>>> Stay online with enterprise data centers and the best network in  
>>>>> the
>>>>> business
>>>>> Choose flexible plans and management services without long-term
>>>>> contracts
>>>>> Personal 24x7 support from experience hosting pros just a phone  
>>>>> call
>>>>> away.
>>>>> http://p.sf.net/sfu/theplanet-com
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> The Planet: dedicated and managed hosting, cloud storage,  
>>>> colocation
>>>> Stay online with enterprise data centers and the best network in
>>>> the business
>>>> Choose flexible plans and management services without long-term
>>>> contracts
>>>> Personal 24x7 support from experience hosting pros just a phone
>>>> call away.
>>>> http://p.sf.net/sfu/theplanet-com
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>
>>>
>>>
>>> --
>>> http://www.badmuthahubbard.com
>>>
>>> ------------------------------------------------------------------------------
>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>> Stay online with enterprise data centers and the best network in the
>>> business
>>> Choose flexible plans and management services without long-term
>>> contracts
>>> Personal 24x7 support from experience hosting pros just a phone call
>>> away.
>>> http://p.sf.net/sfu/theplanet-com
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>> ------------------------------------------------------------------------------
>> The Planet: dedicated and managed hosting, cloud storage, colocation
>> Stay online with enterprise data centers and the best network in  
>> the business
>> Choose flexible plans and management services without long-term  
>> contracts
>> Personal 24x7 support from experience hosting pros just a phone  
>> call away.
>> http://p.sf.net/sfu/theplanet-com
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>
>
>
> -- 
> http://www.badmuthahubbard.com
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the  
> business
> Choose flexible plans and management services without long-term  
> contracts
> Personal 24x7 support from experience hosting pros just a phone call  
> away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-01-27 20:08
FromChuckk Hubbard
SubjectRe: [Cs-dev] Python arguments from C++ documentation
Okay, but don't rush on my part. Like you said, there are other ways,
and while I might compile Csound from CVS for myself, I don't think
I'll publish a version of Rationale that requires it.

-Chuckk

On Wed, Jan 27, 2010 at 7:19 PM, Victor Lazzarini
 wrote:
> Anyway, the outvalue callback should do the trick. I am not sure why
> nothing is happening.
> I'll try and investigate.
>
> Victor
> On 27 Jan 2010, at 17:14, Chuckk Hubbard wrote:
>
>> It's currently done by Csound score, for a couple of reasons. I give
>> the Csound-based audio engine a higher priority, so I figured the
>> timing was better handled within Csound. Also, I didn't want to bother
>> calculating tempo in Python. Third, so folks can easily export a piece
>> as csd for external editing.
>> Maybe OSC would be the way to go for now, as someone suggested before.
>> Thanks again.
>> -Chuckk
>>
>> On Wed, Jan 27, 2010 at 2:56 PM, Victor Lazzarini
>>  wrote:
>>> and is  this instrument instantiated by Python or by csound score?
>>> On 27 Jan 2010, at 12:37, Chuckk Hubbard wrote:
>>>
>>>> Since the only job of the calling instance for MIDI is to trigger
>>>> notes from other instances, synchronized with its own audio
>>>> output, I
>>>> was thinking of using turnoff right after outvalue.
>>>>
>>>> -Chuckk
>>>>
>>>> On Wed, Jan 27, 2010 at 12:35 PM, Victor Lazzarini
>>>>  wrote:
>>>>> I don't think there will be a lot of difference though, because
>>>>> Csound
>>>>> will call the python callback for every instance of outvalue, no
>>>>> matter what and this will happen at every k-period, unless you
>>>>> bypass
>>>>> outvalue in Csound using if-then (etc).
>>>>>
>>>>> Victor
>>>>>
>>>>>
>>>>> On 26 Jan 2010, at 22:35, Chuckk Hubbard wrote:
>>>>>
>>>>>> Okay, thanks Victor.
>>>>>> My problem with GetChannel() is that I want discrete messages, not
>>>>>> continuously changing values. I want to send MIDI notes from these
>>>>>> callbacks through other Csound instances (I hope), and it seems
>>>>>> like a
>>>>>> waste of CPU to have Python checking for changes so rapidly. I
>>>>>> guess
>>>>>> any way it works there will be timing problems according to -b,
>>>>>> but if
>>>>>> I understand correctly, the callback of SetOutputValueCallback()
>>>>>> would
>>>>>> be initiated from Csound, whereas GetChannel() has to be initiated
>>>>>> by
>>>>>> Python. Of course, if you tell me there won't be any noticeable
>>>>>> difference, then I'll try it.
>>>>>>
>>>>>> -Chuckk
>>>>>>
>>>>>>
>>>>>> On Tue, Jan 26, 2010 at 8:09 PM, Victor Lazzarini
>>>>>>  wrote:
>>>>>>> Why do you need to set a callback? Can't you just use the
>>>>>>> GetChannel()/
>>>>>>> SetChannel() methods?
>>>>>>>
>>>>>>> The csoundSetChannelIOCallback() function is not yet implemented
>>>>>>> (we
>>>>>>> should mark it as that!).
>>>>>>>
>>>>>>> For Python, I have wrapped Csound::SetOutputValueCallback() to
>>>>>>> take a
>>>>>>> python callback instead of a C function pointer. It should work
>>>>>>> but I
>>>>>>> have not tested it.
>>>>>>>
>>>>>>> This callback will be called every time an opcode outvalue is
>>>>>>> used.
>>>>>>> You will need to then maintain and parse a list of channels to
>>>>>>> access
>>>>>>> the correct one. If you want a C example of how it's done lookup
>>>>>>> csoundapi_tilde sources.
>>>>>>>
>>>>>>>
>>>>>>> Victor
>>>>>>> On 26 Jan 2010, at 15:39, Chuckk Hubbard wrote:
>>>>>>>
>>>>>>>> Hi.
>>>>>>>> Sorry if this is the wrong list, happy to switch if it is.
>>>>>>>> I've been asking questions on the users' list lately on various
>>>>>>>> things, but one problem I keep running into is that I'm not sure
>>>>>>>> how
>>>>>>>> to translate the C++ API documentation to Python arguments. For
>>>>>>>> instance, from the reference manual:
>>>>>>>> PUBLIC void csoundSetOutputValueCallback      (       CSOUND
>>>>>>>> *        ,
>>>>>>>>               void(*)(CSOUND *, const char *channelName, MYFLT
>>>>>>>> value)
>>>>>>>>       outputValueCalback_
>>>>>>>>       )
>>>>>>>>
>>>>>>>> The same function through Python's help command:
>>>>>>>> SetOutputValueCallback(self, PyObject pyfunc)
>>>>>>>> But I can't get it to take by offering it a Python function as
>>>>>>>> argument. No error, but it does nothing.
>>>>>>>>
>>>>>>>> With this one:
>>>>>>>> PUBLIC void csoundSetChannelIOCallback        (       CSOUND
>>>>>>>> *        ,
>>>>>>>>               CsoundChannelIOCallback_t       func
>>>>>>>>       )
>>>>>>>>
>>>>>>>> I check the structure of CsoundChannelIOCallback_t and find;
>>>>>>>> typedef void(* CsoundChannelIOCallback_t)(CSOUND *csound, const
>>>>>>>> char
>>>>>>>> *channelName, MYFLT *channelValuePtr, int channelType)
>>>>>>>>
>>>>>>>> And Python's help function gives:
>>>>>>>> SetChannelIOCallback(self, CsoundChannelIOCallback_t func)
>>>>>>>>
>>>>>>>> So in one case I'm wondering how a pointer as argument
>>>>>>>> translates to
>>>>>>>> Python, and in the other, how to match the type
>>>>>>>> CsoundChannelIOCallback in Python. It seems like it only wants
>>>>>>>> the
>>>>>>>> function, and there's no way to enter the channel name?
>>>>>>>>
>>>>>>>> Sorry if these are basic questions. Understanding this will open
>>>>>>>> up
>>>>>>>> lots of powerful-sounding capabilities that I've skipped until
>>>>>>>> now.
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>> -Chuckk
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> http://www.badmuthahubbard.com
>>>>>>>>
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>>>> colocation
>>>>>>>> Stay online with enterprise data centers and the best network in
>>>>>>>> the
>>>>>>>> business
>>>>>>>> Choose flexible plans and management services without long-term
>>>>>>>> contracts
>>>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>>>> call
>>>>>>>> away.
>>>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>>>> _______________________________________________
>>>>>>>> Csound-devel mailing list
>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>>> colocation
>>>>>>> Stay online with enterprise data centers and the best network in
>>>>>>> the business
>>>>>>> Choose flexible plans and management services without long-term
>>>>>>> contracts
>>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>>> call away.
>>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> http://www.badmuthahubbard.com
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>> colocation
>>>>>> Stay online with enterprise data centers and the best network in
>>>>>> the
>>>>>> business
>>>>>> Choose flexible plans and management services without long-term
>>>>>> contracts
>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>> call
>>>>>> away.
>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>> colocation
>>>>> Stay online with enterprise data centers and the best network in
>>>>> the business
>>>>> Choose flexible plans and management services without long-term
>>>>> contracts
>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>> call away.
>>>>> http://p.sf.net/sfu/theplanet-com
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> http://www.badmuthahubbard.com
>>>>
>>>> ------------------------------------------------------------------------------
>>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>>> Stay online with enterprise data centers and the best network in the
>>>> business
>>>> Choose flexible plans and management services without long-term
>>>> contracts
>>>> Personal 24x7 support from experience hosting pros just a phone call
>>>> away.
>>>> http://p.sf.net/sfu/theplanet-com
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>> Stay online with enterprise data centers and the best network in
>>> the business
>>> Choose flexible plans and management services without long-term
>>> contracts
>>> Personal 24x7 support from experience hosting pros just a phone
>>> call away.
>>> http://p.sf.net/sfu/theplanet-com
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>
>>
>>
>> --
>> http://www.badmuthahubbard.com
>>
>> ------------------------------------------------------------------------------
>> The Planet: dedicated and managed hosting, cloud storage, colocation
>> Stay online with enterprise data centers and the best network in the
>> business
>> Choose flexible plans and management services without long-term
>> contracts
>> Personal 24x7 support from experience hosting pros just a phone call
>> away.
>> http://p.sf.net/sfu/theplanet-com
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>



-- 
http://www.badmuthahubbard.com

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listi

Date2010-01-27 20:33
FromVictor Lazzarini
SubjectRe: [Cs-dev] Python arguments from C++ documentation
Ok, it's working, so this is what you do:

cs = Csound()
cs.PreCompile()

def MyCallback(chan, value): print (chan, value)

cs.SetOutputValueCallback(MyCallback)

cs.Compile()

cs.Perform()

and it should work (it does here).

The callback has to take two arguments, that is why you probably could  
not make it work.

Victor


On 27 Jan 2010, at 20:08, Chuckk Hubbard wrote:

> Okay, but don't rush on my part. Like you said, there are other ways,
> and while I might compile Csound from CVS for myself, I don't think
> I'll publish a version of Rationale that requires it.
>
> -Chuckk
>
> On Wed, Jan 27, 2010 at 7:19 PM, Victor Lazzarini
>  wrote:
>> Anyway, the outvalue callback should do the trick. I am not sure why
>> nothing is happening.
>> I'll try and investigate.
>>
>> Victor
>> On 27 Jan 2010, at 17:14, Chuckk Hubbard wrote:
>>
>>> It's currently done by Csound score, for a couple of reasons. I give
>>> the Csound-based audio engine a higher priority, so I figured the
>>> timing was better handled within Csound. Also, I didn't want to  
>>> bother
>>> calculating tempo in Python. Third, so folks can easily export a  
>>> piece
>>> as csd for external editing.
>>> Maybe OSC would be the way to go for now, as someone suggested  
>>> before.
>>> Thanks again.
>>> -Chuckk
>>>
>>> On Wed, Jan 27, 2010 at 2:56 PM, Victor Lazzarini
>>>  wrote:
>>>> and is  this instrument instantiated by Python or by csound score?
>>>> On 27 Jan 2010, at 12:37, Chuckk Hubbard wrote:
>>>>
>>>>> Since the only job of the calling instance for MIDI is to trigger
>>>>> notes from other instances, synchronized with its own audio
>>>>> output, I
>>>>> was thinking of using turnoff right after outvalue.
>>>>>
>>>>> -Chuckk
>>>>>
>>>>> On Wed, Jan 27, 2010 at 12:35 PM, Victor Lazzarini
>>>>>  wrote:
>>>>>> I don't think there will be a lot of difference though, because
>>>>>> Csound
>>>>>> will call the python callback for every instance of outvalue, no
>>>>>> matter what and this will happen at every k-period, unless you
>>>>>> bypass
>>>>>> outvalue in Csound using if-then (etc).
>>>>>>
>>>>>> Victor
>>>>>>
>>>>>>
>>>>>> On 26 Jan 2010, at 22:35, Chuckk Hubbard wrote:
>>>>>>
>>>>>>> Okay, thanks Victor.
>>>>>>> My problem with GetChannel() is that I want discrete messages,  
>>>>>>> not
>>>>>>> continuously changing values. I want to send MIDI notes from  
>>>>>>> these
>>>>>>> callbacks through other Csound instances (I hope), and it seems
>>>>>>> like a
>>>>>>> waste of CPU to have Python checking for changes so rapidly. I
>>>>>>> guess
>>>>>>> any way it works there will be timing problems according to -b,
>>>>>>> but if
>>>>>>> I understand correctly, the callback of SetOutputValueCallback()
>>>>>>> would
>>>>>>> be initiated from Csound, whereas GetChannel() has to be  
>>>>>>> initiated
>>>>>>> by
>>>>>>> Python. Of course, if you tell me there won't be any noticeable
>>>>>>> difference, then I'll try it.
>>>>>>>
>>>>>>> -Chuckk
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Jan 26, 2010 at 8:09 PM, Victor Lazzarini
>>>>>>>  wrote:
>>>>>>>> Why do you need to set a callback? Can't you just use the
>>>>>>>> GetChannel()/
>>>>>>>> SetChannel() methods?
>>>>>>>>
>>>>>>>> The csoundSetChannelIOCallback() function is not yet  
>>>>>>>> implemented
>>>>>>>> (we
>>>>>>>> should mark it as that!).
>>>>>>>>
>>>>>>>> For Python, I have wrapped Csound::SetOutputValueCallback() to
>>>>>>>> take a
>>>>>>>> python callback instead of a C function pointer. It should work
>>>>>>>> but I
>>>>>>>> have not tested it.
>>>>>>>>
>>>>>>>> This callback will be called every time an opcode outvalue is
>>>>>>>> used.
>>>>>>>> You will need to then maintain and parse a list of channels to
>>>>>>>> access
>>>>>>>> the correct one. If you want a C example of how it's done  
>>>>>>>> lookup
>>>>>>>> csoundapi_tilde sources.
>>>>>>>>
>>>>>>>>
>>>>>>>> Victor
>>>>>>>> On 26 Jan 2010, at 15:39, Chuckk Hubbard wrote:
>>>>>>>>
>>>>>>>>> Hi.
>>>>>>>>> Sorry if this is the wrong list, happy to switch if it is.
>>>>>>>>> I've been asking questions on the users' list lately on  
>>>>>>>>> various
>>>>>>>>> things, but one problem I keep running into is that I'm not  
>>>>>>>>> sure
>>>>>>>>> how
>>>>>>>>> to translate the C++ API documentation to Python arguments.  
>>>>>>>>> For
>>>>>>>>> instance, from the reference manual:
>>>>>>>>> PUBLIC void csoundSetOutputValueCallback      (       CSOUND
>>>>>>>>> *        ,
>>>>>>>>>               void(*)(CSOUND *, const char *channelName, MYFLT
>>>>>>>>> value)
>>>>>>>>>       outputValueCalback_
>>>>>>>>>       )
>>>>>>>>>
>>>>>>>>> The same function through Python's help command:
>>>>>>>>> SetOutputValueCallback(self, PyObject pyfunc)
>>>>>>>>> But I can't get it to take by offering it a Python function as
>>>>>>>>> argument. No error, but it does nothing.
>>>>>>>>>
>>>>>>>>> With this one:
>>>>>>>>> PUBLIC void csoundSetChannelIOCallback        (       CSOUND
>>>>>>>>> *        ,
>>>>>>>>>               CsoundChannelIOCallback_t       func
>>>>>>>>>       )
>>>>>>>>>
>>>>>>>>> I check the structure of CsoundChannelIOCallback_t and find;
>>>>>>>>> typedef void(* CsoundChannelIOCallback_t)(CSOUND *csound,  
>>>>>>>>> const
>>>>>>>>> char
>>>>>>>>> *channelName, MYFLT *channelValuePtr, int channelType)
>>>>>>>>>
>>>>>>>>> And Python's help function gives:
>>>>>>>>> SetChannelIOCallback(self, CsoundChannelIOCallback_t func)
>>>>>>>>>
>>>>>>>>> So in one case I'm wondering how a pointer as argument
>>>>>>>>> translates to
>>>>>>>>> Python, and in the other, how to match the type
>>>>>>>>> CsoundChannelIOCallback in Python. It seems like it only wants
>>>>>>>>> the
>>>>>>>>> function, and there's no way to enter the channel name?
>>>>>>>>>
>>>>>>>>> Sorry if these are basic questions. Understanding this will  
>>>>>>>>> open
>>>>>>>>> up
>>>>>>>>> lots of powerful-sounding capabilities that I've skipped until
>>>>>>>>> now.
>>>>>>>>>
>>>>>>>>> Thanks.
>>>>>>>>> -Chuckk
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> http://www.badmuthahubbard.com
>>>>>>>>>
>>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>>>>> colocation
>>>>>>>>> Stay online with enterprise data centers and the best  
>>>>>>>>> network in
>>>>>>>>> the
>>>>>>>>> business
>>>>>>>>> Choose flexible plans and management services without long- 
>>>>>>>>> term
>>>>>>>>> contracts
>>>>>>>>> Personal 24x7 support from experience hosting pros just a  
>>>>>>>>> phone
>>>>>>>>> call
>>>>>>>>> away.
>>>>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>>>>> _______________________________________________
>>>>>>>>> Csound-devel mailing list
>>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>>
>>>>>>>>
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>>>> colocation
>>>>>>>> Stay online with enterprise data centers and the best network  
>>>>>>>> in
>>>>>>>> the business
>>>>>>>> Choose flexible plans and management services without long-term
>>>>>>>> contracts
>>>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>>>> call away.
>>>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>>>> _______________________________________________
>>>>>>>> Csound-devel mailing list
>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> http://www.badmuthahubbard.com
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>>> colocation
>>>>>>> Stay online with enterprise data centers and the best network in
>>>>>>> the
>>>>>>> business
>>>>>>> Choose flexible plans and management services without long-term
>>>>>>> contracts
>>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>>> call
>>>>>>> away.
>>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>> colocation
>>>>>> Stay online with enterprise data centers and the best network in
>>>>>> the business
>>>>>> Choose flexible plans and management services without long-term
>>>>>> contracts
>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>> call away.
>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> http://www.badmuthahubbard.com
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> The Planet: dedicated and managed hosting, cloud storage,  
>>>>> colocation
>>>>> Stay online with enterprise data centers and the best network in  
>>>>> the
>>>>> business
>>>>> Choose flexible plans and management services without long-term
>>>>> contracts
>>>>> Personal 24x7 support from experience hosting pros just a phone  
>>>>> call
>>>>> away.
>>>>> http://p.sf.net/sfu/theplanet-com
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> The Planet: dedicated and managed hosting, cloud storage,  
>>>> colocation
>>>> Stay online with enterprise data centers and the best network in
>>>> the business
>>>> Choose flexible plans and management services without long-term
>>>> contracts
>>>> Personal 24x7 support from experience hosting pros just a phone
>>>> call away.
>>>> http://p.sf.net/sfu/theplanet-com
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>
>>>
>>>
>>> --
>>> http://www.badmuthahubbard.com
>>>
>>> ------------------------------------------------------------------------------
>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>> Stay online with enterprise data centers and the best network in the
>>> business
>>> Choose flexible plans and management services without long-term
>>> contracts
>>> Personal 24x7 support from experience hosting pros just a phone call
>>> away.
>>> http://p.sf.net/sfu/theplanet-com
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>> ------------------------------------------------------------------------------
>> The Planet: dedicated and managed hosting, cloud storage, colocation
>> Stay online with enterprise data centers and the best network in  
>> the business
>> Choose flexible plans and management services without long-term  
>> contracts
>> Personal 24x7 support from experience hosting pros just a phone  
>> call away.
>> http://p.sf.net/sfu/theplanet-com
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>
>
>
> -- 
> http://www.badmuthahubbard.com
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the  
> business
> Choose flexible plans and management services without long-term  
> contracts
> Personal 24x7 support from experience hosting pros just a phone call  
> away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-01-28 16:40
FromChuckk Hubbard
SubjectRe: [Cs-dev] Python arguments from C++ documentation
Great, thanks! Yes, the arguments were throwing me off; I had tried
*args, and had tried several numbers of arguments, but I was also
including 'self' as the first argument, for some reason.
It works like a charm, using this kind of queer Csound instrument:

gival init 0

instr 1
turnoff
outvalue "num", gival
gival = gival + 1
endin

-Chuckk

On Wed, Jan 27, 2010 at 10:33 PM, Victor Lazzarini
 wrote:
> Ok, it's working, so this is what you do:
>
> cs = Csound()
> cs.PreCompile()
>
> def MyCallback(chan, value): print (chan, value)
>
> cs.SetOutputValueCallback(MyCallback)
>
> cs.Compile()
>
> cs.Perform()
>
> and it should work (it does here).
>
> The callback has to take two arguments, that is why you probably could
> not make it work.
>
> Victor
>
>
> On 27 Jan 2010, at 20:08, Chuckk Hubbard wrote:
>
>> Okay, but don't rush on my part. Like you said, there are other ways,
>> and while I might compile Csound from CVS for myself, I don't think
>> I'll publish a version of Rationale that requires it.
>>
>> -Chuckk
>>
>> On Wed, Jan 27, 2010 at 7:19 PM, Victor Lazzarini
>>  wrote:
>>> Anyway, the outvalue callback should do the trick. I am not sure why
>>> nothing is happening.
>>> I'll try and investigate.
>>>
>>> Victor
>>> On 27 Jan 2010, at 17:14, Chuckk Hubbard wrote:
>>>
>>>> It's currently done by Csound score, for a couple of reasons. I give
>>>> the Csound-based audio engine a higher priority, so I figured the
>>>> timing was better handled within Csound. Also, I didn't want to
>>>> bother
>>>> calculating tempo in Python. Third, so folks can easily export a
>>>> piece
>>>> as csd for external editing.
>>>> Maybe OSC would be the way to go for now, as someone suggested
>>>> before.
>>>> Thanks again.
>>>> -Chuckk
>>>>
>>>> On Wed, Jan 27, 2010 at 2:56 PM, Victor Lazzarini
>>>>  wrote:
>>>>> and is  this instrument instantiated by Python or by csound score?
>>>>> On 27 Jan 2010, at 12:37, Chuckk Hubbard wrote:
>>>>>
>>>>>> Since the only job of the calling instance for MIDI is to trigger
>>>>>> notes from other instances, synchronized with its own audio
>>>>>> output, I
>>>>>> was thinking of using turnoff right after outvalue.
>>>>>>
>>>>>> -Chuckk
>>>>>>
>>>>>> On Wed, Jan 27, 2010 at 12:35 PM, Victor Lazzarini
>>>>>>  wrote:
>>>>>>> I don't think there will be a lot of difference though, because
>>>>>>> Csound
>>>>>>> will call the python callback for every instance of outvalue, no
>>>>>>> matter what and this will happen at every k-period, unless you
>>>>>>> bypass
>>>>>>> outvalue in Csound using if-then (etc).
>>>>>>>
>>>>>>> Victor
>>>>>>>
>>>>>>>
>>>>>>> On 26 Jan 2010, at 22:35, Chuckk Hubbard wrote:
>>>>>>>
>>>>>>>> Okay, thanks Victor.
>>>>>>>> My problem with GetChannel() is that I want discrete messages,
>>>>>>>> not
>>>>>>>> continuously changing values. I want to send MIDI notes from
>>>>>>>> these
>>>>>>>> callbacks through other Csound instances (I hope), and it seems
>>>>>>>> like a
>>>>>>>> waste of CPU to have Python checking for changes so rapidly. I
>>>>>>>> guess
>>>>>>>> any way it works there will be timing problems according to -b,
>>>>>>>> but if
>>>>>>>> I understand correctly, the callback of SetOutputValueCallback()
>>>>>>>> would
>>>>>>>> be initiated from Csound, whereas GetChannel() has to be
>>>>>>>> initiated
>>>>>>>> by
>>>>>>>> Python. Of course, if you tell me there won't be any noticeable
>>>>>>>> difference, then I'll try it.
>>>>>>>>
>>>>>>>> -Chuckk
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, Jan 26, 2010 at 8:09 PM, Victor Lazzarini
>>>>>>>>  wrote:
>>>>>>>>> Why do you need to set a callback? Can't you just use the
>>>>>>>>> GetChannel()/
>>>>>>>>> SetChannel() methods?
>>>>>>>>>
>>>>>>>>> The csoundSetChannelIOCallback() function is not yet
>>>>>>>>> implemented
>>>>>>>>> (we
>>>>>>>>> should mark it as that!).
>>>>>>>>>
>>>>>>>>> For Python, I have wrapped Csound::SetOutputValueCallback() to
>>>>>>>>> take a
>>>>>>>>> python callback instead of a C function pointer. It should work
>>>>>>>>> but I
>>>>>>>>> have not tested it.
>>>>>>>>>
>>>>>>>>> This callback will be called every time an opcode outvalue is
>>>>>>>>> used.
>>>>>>>>> You will need to then maintain and parse a list of channels to
>>>>>>>>> access
>>>>>>>>> the correct one. If you want a C example of how it's done
>>>>>>>>> lookup
>>>>>>>>> csoundapi_tilde sources.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Victor
>>>>>>>>> On 26 Jan 2010, at 15:39, Chuckk Hubbard wrote:
>>>>>>>>>
>>>>>>>>>> Hi.
>>>>>>>>>> Sorry if this is the wrong list, happy to switch if it is.
>>>>>>>>>> I've been asking questions on the users' list lately on
>>>>>>>>>> various
>>>>>>>>>> things, but one problem I keep running into is that I'm not
>>>>>>>>>> sure
>>>>>>>>>> how
>>>>>>>>>> to translate the C++ API documentation to Python arguments.
>>>>>>>>>> For
>>>>>>>>>> instance, from the reference manual:
>>>>>>>>>> PUBLIC void csoundSetOutputValueCallback      (       CSOUND
>>>>>>>>>> *        ,
>>>>>>>>>>               void(*)(CSOUND *, const char *channelName, MYFLT
>>>>>>>>>> value)
>>>>>>>>>>       outputValueCalback_
>>>>>>>>>>       )
>>>>>>>>>>
>>>>>>>>>> The same function through Python's help command:
>>>>>>>>>> SetOutputValueCallback(self, PyObject pyfunc)
>>>>>>>>>> But I can't get it to take by offering it a Python function as
>>>>>>>>>> argument. No error, but it does nothing.
>>>>>>>>>>
>>>>>>>>>> With this one:
>>>>>>>>>> PUBLIC void csoundSetChannelIOCallback        (       CSOUND
>>>>>>>>>> *        ,
>>>>>>>>>>               CsoundChannelIOCallback_t       func
>>>>>>>>>>       )
>>>>>>>>>>
>>>>>>>>>> I check the structure of CsoundChannelIOCallback_t and find;
>>>>>>>>>> typedef void(* CsoundChannelIOCallback_t)(CSOUND *csound,
>>>>>>>>>> const
>>>>>>>>>> char
>>>>>>>>>> *channelName, MYFLT *channelValuePtr, int channelType)
>>>>>>>>>>
>>>>>>>>>> And Python's help function gives:
>>>>>>>>>> SetChannelIOCallback(self, CsoundChannelIOCallback_t func)
>>>>>>>>>>
>>>>>>>>>> So in one case I'm wondering how a pointer as argument
>>>>>>>>>> translates to
>>>>>>>>>> Python, and in the other, how to match the type
>>>>>>>>>> CsoundChannelIOCallback in Python. It seems like it only wants
>>>>>>>>>> the
>>>>>>>>>> function, and there's no way to enter the channel name?
>>>>>>>>>>
>>>>>>>>>> Sorry if these are basic questions. Understanding this will
>>>>>>>>>> open
>>>>>>>>>> up
>>>>>>>>>> lots of powerful-sounding capabilities that I've skipped until
>>>>>>>>>> now.
>>>>>>>>>>
>>>>>>>>>> Thanks.
>>>>>>>>>> -Chuckk
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> http://www.badmuthahubbard.com
>>>>>>>>>>
>>>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>>>>>> colocation
>>>>>>>>>> Stay online with enterprise data centers and the best
>>>>>>>>>> network in
>>>>>>>>>> the
>>>>>>>>>> business
>>>>>>>>>> Choose flexible plans and management services without long-
>>>>>>>>>> term
>>>>>>>>>> contracts
>>>>>>>>>> Personal 24x7 support from experience hosting pros just a
>>>>>>>>>> phone
>>>>>>>>>> call
>>>>>>>>>> away.
>>>>>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>>>>>> _______________________________________________
>>>>>>>>>> Csound-devel mailing list
>>>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>>>>> colocation
>>>>>>>>> Stay online with enterprise data centers and the best network
>>>>>>>>> in
>>>>>>>>> the business
>>>>>>>>> Choose flexible plans and management services without long-term
>>>>>>>>> contracts
>>>>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>>>>> call away.
>>>>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>>>>> _______________________________________________
>>>>>>>>> Csound-devel mailing list
>>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> http://www.badmuthahubbard.com
>>>>>>>>
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>>>> colocation
>>>>>>>> Stay online with enterprise data centers and the best network in
>>>>>>>> the
>>>>>>>> business
>>>>>>>> Choose flexible plans and management services without long-term
>>>>>>>> contracts
>>>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>>>> call
>>>>>>>> away.
>>>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>>>> _______________________________________________
>>>>>>>> Csound-devel mailing list
>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>>> colocation
>>>>>>> Stay online with enterprise data centers and the best network in
>>>>>>> the business
>>>>>>> Choose flexible plans and management services without long-term
>>>>>>> contracts
>>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>>> call away.
>>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> http://www.badmuthahubbard.com
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>> colocation
>>>>>> Stay online with enterprise data centers and the best network in
>>>>>> the
>>>>>> business
>>>>>> Choose flexible plans and management services without long-term
>>>>>> contracts
>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>> call
>>>>>> away.
>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>> colocation
>>>>> Stay online with enterprise data centers and the best network in
>>>>> the business
>>>>> Choose flexible plans and management services without long-term
>>>>> contracts
>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>> call away.
>>>>> http://p.sf.net/sfu/theplanet-com
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> http://www.badmuthahubbard.com
>>>>
>>>> ------------------------------------------------------------------------------
>>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>>> Stay online with enterprise data centers and the best network in the
>>>> business
>>>> Choose flexible plans and management services without long-term
>>>> contracts
>>>> Personal 24x7 support from experience hosting pros just a phone call
>>>> away.
>>>> http://p.sf.net/sfu/theplanet-com
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>> Stay online with enterprise data centers and the best network in
>>> the business
>>> Choose flexible plans and management services without long-term
>>> contracts
>>> Personal 24x7 support from experience hosting pros just a phone
>>> call away.
>>> http://p.sf.net/sfu/theplanet-com
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>
>>
>>
>> --
>> http://www.badmuthahubbard.com
>>
>> ------------------------------------------------------------------------------
>> The Planet: dedicated and managed hosting, cloud storage, colocation
>> Stay online with enterprise data centers and the best network in the
>> business
>> Choose flexible plans and management services without long-term
>> contracts
>> Personal 24x7 support from experience hosting pros just a phone call
>> away.
>> http://p.sf.net/sfu/theplanet-com
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>



-- 
http://www.badmuthahubbard.com

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-dev