Csound Csound-dev Csound-tekno Search About

[Csnd] CsoundAndroid: communication with channels

Date2012-09-17 21:08
FromTarmo Johannes
Subject[Csnd] CsoundAndroid: communication with channels
Hi,

I am  slowly learning how to write an android app using Csound.  It goes 
pretty well and seems extremely interesting!

I have some questions about handling Csound  (data) channels.

It is great that there are convenience functions CsoundObj.addSlider and 
CsoundObj.addButton 
-- by the way, what does the parameter 'type' mean in 
public CsoundValueCacheable addButton(Button button, String channelName,int 
type)? --

but

 A 
when I need to send a value from some other widget or operation to csound via 
a csound channel, following the CsoundAndroidExamples,  I figured out 
following way. Please comment, if it is correct to do so (works, at least):

1) declare a variable for the channel. like
private CsoundMYFLTArray beatsChannel;

2) in definition of  CsoundObj.addValueCacheable add
to function 'setup()' something like
beatsChannel = csoundObj.getInputChannelPtr("beats");

3) in updateValuesToCsound() something like:
beatsChannel = csoundObj.getInputChannelPtr("beats"); // beats being a 
variable of float, defined elsewhere

4) to cleanup() something like
beatsChannel.Clear();
beatsChannel = null;


It is probalby not so easy or perhaps not even possible, but Steven, Victor, 
have you considered to add a convenience function like 
CsoundObj,setChannel(String name, float value)  that would just do all the 
work?


B
and what I have to do to read values from csound channel by an android 
activity?

There is function in CsoundObj
public CsoundMYFLTArray getInputChannelPtr(String channelName)

that uses constants CSOUND_CONTROL_CHANNEL |  CSOUND_INPUT_CHANNEL
thus it would not probalby work for output from Csound?

Should there be a function something like getOutputChannelPtr or how does it 
work?

Can I use somehow CsoundObj.getCsound() to write somehow my own readChannel() 
function or seomething like this?

thanks,
tarmo








Date2012-09-18 11:04
FromSteven Yi
SubjectRe: [Csnd] CsoundAndroid: communication with channels
Hi Tarmo,

The CsoundValueCacheable interface is used for controlled reads/writes
from/to Csound.  In general, the four method work as:

setup - used to cache channels (CsoundMYFLTArray is used in Java, they
hold references to MYFLT* underneath), and do any other setup
interactions with Csound

updateValueToCsound - here the csoundValueCacheable should write value
to csound if necessary. Typically you would use the CsoundMYFLTArray's
that you cached in the setup here.

updateValueFromCsound - here the csoundValueCacheable should read
values from csound if necessary. Typically you would use the
CsoundMYFLTArray's that you cached in the setup here.

cleanup - here you should clean up any listeners to UI elements and
anything else that would leave references around and cause memory
leaks

The idea with setup is to cache pointers so that you don't have to
look for the pointer again during runtime.  It's more efficient to do
so, as the lookup for the pointer by channel name is not negligible.

Also, we could add a CsoundObj.setChannel(String name, float value) as
a convenience function.  I imagine it would useful if you're doing a
one-time value set, instead of a continuous control channel.  Is this
the use case which you were thinking of using this?

You also have the freedom to bypass the CsoundObj class altogether and
just use the Csound class.  I'd still use CsoundObj to start as it
will create the underlying Csound class and hook it up for use with
OpenSL.  After that, you can use csoundObj.getCsound() to get the
Csound API class and use the standard Csound5 API methods for grabbing
channels, table data, etc.

Hope that helps!
steven

On Mon, Sep 17, 2012 at 9:08 PM, Tarmo Johannes
 wrote:
> Hi,
>
> I am  slowly learning how to write an android app using Csound.  It goes
> pretty well and seems extremely interesting!
>
> I have some questions about handling Csound  (data) channels.
>
> It is great that there are convenience functions CsoundObj.addSlider and
> CsoundObj.addButton
> -- by the way, what does the parameter 'type' mean in
> public CsoundValueCacheable addButton(Button button, String channelName,int
> type)? --
>
> but
>
>  A
> when I need to send a value from some other widget or operation to csound via
> a csound channel, following the CsoundAndroidExamples,  I figured out
> following way. Please comment, if it is correct to do so (works, at least):
>
> 1) declare a variable for the channel. like
> private CsoundMYFLTArray beatsChannel;
>
> 2) in definition of  CsoundObj.addValueCacheable add
> to function 'setup()' something like
> beatsChannel = csoundObj.getInputChannelPtr("beats");
>
> 3) in updateValuesToCsound() something like:
> beatsChannel = csoundObj.getInputChannelPtr("beats"); // beats being a
> variable of float, defined elsewhere
>
> 4) to cleanup() something like
> beatsChannel.Clear();
> beatsChannel = null;
>
>
> It is probalby not so easy or perhaps not even possible, but Steven, Victor,
> have you considered to add a convenience function like
> CsoundObj,setChannel(String name, float value)  that would just do all the
> work?
>
>
> B
> and what I have to do to read values from csound channel by an android
> activity?
>
> There is function in CsoundObj
> public CsoundMYFLTArray getInputChannelPtr(String channelName)
>
> that uses constants CSOUND_CONTROL_CHANNEL |  CSOUND_INPUT_CHANNEL
> thus it would not probalby work for output from Csound?
>
> Should there be a function something like getOutputChannelPtr or how does it
> work?
>
> Can I use somehow CsoundObj.getCsound() to write somehow my own readChannel()
> function or seomething like this?
>
> thanks,
> tarmo
>
>
>
>
>
>
>
>
>
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>

Date2012-09-18 15:47
FromTarmo Johannes
SubjectRe: [Csnd] CsoundAndroid: communication with channels

Thank you, Steven.

 

it definitely cleared some things.

I will try out the solution later.

 

 

> Also, we could add a CsoundObj.setChannel(String name, float value) as

> a convenience function. I imagine it would useful if you're doing a

> one-time value set, instead of a continuous control channel. Is this

> the use case which you were thinking of using this?

 

Yes, perhaps it would be handy in some cases. I understood now that it more efficient to use updateValueToCsound in most cases.

 

+ thanks for the android project in the other mail! It is very helpful to see other examples!

 

greetings,

tarmo

 

On Tuesday 18 September 2012 11:04:29 Steven Yi wrote:

> Hi Tarmo,

>

> The CsoundValueCacheable interface is used for controlled reads/writes

> from/to Csound. In general, the four method work as:

>

> setup - used to cache channels (CsoundMYFLTArray is used in Java, they

> hold references to MYFLT* underneath), and do any other setup

> interactions with Csound

>

> updateValueToCsound - here the csoundValueCacheable should write value

> to csound if necessary. Typically you would use the CsoundMYFLTArray's

> that you cached in the setup here.

>

> updateValueFromCsound - here the csoundValueCacheable should read

> values from csound if necessary. Typically you would use the

> CsoundMYFLTArray's that you cached in the setup here.

>

> cleanup - here you should clean up any listeners to UI elements and

> anything else that would leave references around and cause memory

> leaks

>

> The idea with setup is to cache pointers so that you don't have to

> look for the pointer again during runtime. It's more efficient to do

> so, as the lookup for the pointer by channel name is not negligible.

>

> Also, we could add a CsoundObj.setChannel(String name, float value) as

> a convenience function. I imagine it would useful if you're doing a

> one-time value set, instead of a continuous control channel. Is this

> the use case which you were thinking of using this?

>

> You also have the freedom to bypass the CsoundObj class altogether and

> just use the Csound class. I'd still use CsoundObj to start as it

> will create the underlying Csound class and hook it up for use with

> OpenSL. After that, you can use csoundObj.getCsound() to get the

> Csound API class and use the standard Csound5 API methods for grabbing

> channels, table data, etc.

>

> Hope that helps!

> steven

>

> On Mon, Sep 17, 2012 at 9:08 PM, Tarmo Johannes

>

> <tarmo.johannes@otsakool.edu.ee> wrote:

> > Hi,

> >

> > I am slowly learning how to write an android app using Csound. It goes

> > pretty well and seems extremely interesting!

> >

> > I have some questions about handling Csound (data) channels.

> >

> > It is great that there are convenience functions CsoundObj.addSlider and

> > CsoundObj.addButton

> > -- by the way, what does the parameter 'type' mean in

> > public CsoundValueCacheable addButton(Button button, String

> > channelName,int

> > type)? --

> >

> > but

> >

> > A

> >

> > when I need to send a value from some other widget or operation to csound

> > via a csound channel, following the CsoundAndroidExamples, I figured out

> > following way. Please comment, if it is correct to do so (works, at

> > least):

> >

> > 1) declare a variable for the channel. like

> > private CsoundMYFLTArray beatsChannel;

> >

> > 2) in definition of CsoundObj.addValueCacheable add

> > to function 'setup()' something like

> > beatsChannel = csoundObj.getInputChannelPtr("beats");

> >

> > 3) in updateValuesToCsound() something like:

> > beatsChannel = csoundObj.getInputChannelPtr("beats"); // beats being a

> > variable of float, defined elsewhere

> >

> > 4) to cleanup() something like

> > beatsChannel.Clear();

> > beatsChannel = null;

> >

> >

> > It is probalby not so easy or perhaps not even possible, but Steven,

> > Victor, have you considered to add a convenience function like

> > CsoundObj,setChannel(String name, float value) that would just do all the

> > work?

> >

> >

> > B

> > and what I have to do to read values from csound channel by an android

> > activity?

> >

> > There is function in CsoundObj

> > public CsoundMYFLTArray getInputChannelPtr(String channelName)

> >

> > that uses constants CSOUND_CONTROL_CHANNEL | CSOUND_INPUT_CHANNEL

> > thus it would not probalby work for output from Csound?

> >

> > Should there be a function something like getOutputChannelPtr or how does

> > it work?

> >

> > Can I use somehow CsoundObj.getCsound() to write somehow my own

> > readChannel() function or seomething like this?

> >

> > thanks,

> > tarmo

> >

> >

> >

> >

> >

> >

> >

> >

> >

> > Send bugs reports to the Sourceforge bug tracker

> >

> > https://sourceforge.net/tracker/?group_id=81968&atid=564599

> >

> > Discussions of bugs and features can be posted here

> > To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe

> > csound"

> Send bugs reports to the Sourceforge bug tracker

> https://sourceforge.net/tracker/?group_id=81968&atid=564599

> Discussions of bugs and features can be posted here

> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe

> csound"


Date2012-09-18 16:25
FromSteven Yi
SubjectRe: [Csnd] CsoundAndroid: communication with channels
Hi Tarmo,

Happy to assist!  Also to note, the VoiceTouch application has a
SpinnerValueCacheable class used to wrap and bind spinners to
channels.  I think I'll probably look at adding this to the CsoundObj
API for Android for future releases.

If you have other questions, please ask away.  I think the more people
ask questions, the easier it is to see places where the project can be
improved for everyone.

Good luck with your projects and looking forward to what you come up with!

steven


On Tue, Sep 18, 2012 at 3:47 PM, Tarmo Johannes
 wrote:
> Thank you, Steven.
>
>
>
> it definitely cleared some things.
>
> I will try out the solution later.
>
>
>
>
>
>> Also, we could add a CsoundObj.setChannel(String name, float value) as
>
>> a convenience function. I imagine it would useful if you're doing a
>
>> one-time value set, instead of a continuous control channel. Is this
>
>> the use case which you were thinking of using this?
>
>
>
> Yes, perhaps it would be handy in some cases. I understood now that it more
> efficient to use updateValueToCsound in most cases.
>
>
>
> + thanks for the android project in the other mail! It is very helpful to
> see other examples!
>
>
>
> greetings,
>
> tarmo
>
>
>
> On Tuesday 18 September 2012 11:04:29 Steven Yi wrote:
>
>> Hi Tarmo,
>
>>
>
>> The CsoundValueCacheable interface is used for controlled reads/writes
>
>> from/to Csound. In general, the four method work as:
>
>>
>
>> setup - used to cache channels (CsoundMYFLTArray is used in Java, they
>
>> hold references to MYFLT* underneath), and do any other setup
>
>> interactions with Csound
>
>>
>
>> updateValueToCsound - here the csoundValueCacheable should write value
>
>> to csound if necessary. Typically you would use the CsoundMYFLTArray's
>
>> that you cached in the setup here.
>
>>
>
>> updateValueFromCsound - here the csoundValueCacheable should read
>
>> values from csound if necessary. Typically you would use the
>
>> CsoundMYFLTArray's that you cached in the setup here.
>
>>
>
>> cleanup - here you should clean up any listeners to UI elements and
>
>> anything else that would leave references around and cause memory
>
>> leaks
>
>>
>
>> The idea with setup is to cache pointers so that you don't have to
>
>> look for the pointer again during runtime. It's more efficient to do
>
>> so, as the lookup for the pointer by channel name is not negligible.
>
>>
>
>> Also, we could add a CsoundObj.setChannel(String name, float value) as
>
>> a convenience function. I imagine it would useful if you're doing a
>
>> one-time value set, instead of a continuous control channel. Is this
>
>> the use case which you were thinking of using this?
>
>>
>
>> You also have the freedom to bypass the CsoundObj class altogether and
>
>> just use the Csound class. I'd still use CsoundObj to start as it
>
>> will create the underlying Csound class and hook it up for use with
>
>> OpenSL. After that, you can use csoundObj.getCsound() to get the
>
>> Csound API class and use the standard Csound5 API methods for grabbing
>
>> channels, table data, etc.
>
>>
>
>> Hope that helps!
>
>> steven
>
>>
>
>> On Mon, Sep 17, 2012 at 9:08 PM, Tarmo Johannes
>
>>
>
>>  wrote:
>
>> > Hi,
>
>> >
>
>> > I am slowly learning how to write an android app using Csound. It goes
>
>> > pretty well and seems extremely interesting!
>
>> >
>
>> > I have some questions about handling Csound (data) channels.
>
>> >
>
>> > It is great that there are convenience functions CsoundObj.addSlider and
>
>> > CsoundObj.addButton
>
>> > -- by the way, what does the parameter 'type' mean in
>
>> > public CsoundValueCacheable addButton(Button button, String
>
>> > channelName,int
>
>> > type)? --
>
>> >
>
>> > but
>
>> >
>
>> > A
>
>> >
>
>> > when I need to send a value from some other widget or operation to
>> > csound
>
>> > via a csound channel, following the CsoundAndroidExamples, I figured out
>
>> > following way. Please comment, if it is correct to do so (works, at
>
>> > least):
>
>> >
>
>> > 1) declare a variable for the channel. like
>
>> > private CsoundMYFLTArray beatsChannel;
>
>> >
>
>> > 2) in definition of CsoundObj.addValueCacheable add
>
>> > to function 'setup()' something like
>
>> > beatsChannel = csoundObj.getInputChannelPtr("beats");
>
>> >
>
>> > 3) in updateValuesToCsound() something like:
>
>> > beatsChannel = csoundObj.getInputChannelPtr("beats"); // beats being a
>
>> > variable of float, defined elsewhere
>
>> >
>
>> > 4) to cleanup() something like
>
>> > beatsChannel.Clear();
>
>> > beatsChannel = null;
>
>> >
>
>> >
>
>> > It is probalby not so easy or perhaps not even possible, but Steven,
>
>> > Victor, have you considered to add a convenience function like
>
>> > CsoundObj,setChannel(String name, float value) that would just do all
>> > the
>
>> > work?
>
>> >
>
>> >
>
>> > B
>
>> > and what I have to do to read values from csound channel by an android
>
>> > activity?
>
>> >
>
>> > There is function in CsoundObj
>
>> > public CsoundMYFLTArray getInputChannelPtr(String channelName)
>
>> >
>
>> > that uses constants CSOUND_CONTROL_CHANNEL | CSOUND_INPUT_CHANNEL
>
>> > thus it would not probalby work for output from Csound?
>
>> >
>
>> > Should there be a function something like getOutputChannelPtr or how
>> > does
>
>> > it work?
>
>> >
>
>> > Can I use somehow CsoundObj.getCsound() to write somehow my own
>
>> > readChannel() function or seomething like this?
>
>> >
>
>> > thanks,
>
>> > tarmo
>
>> >
>
>> >
>
>> >
>
>> >
>
>> >
>
>> >
>
>> >
>
>> >
>
>> >
>
>> > Send bugs reports to the Sourceforge bug tracker
>
>> >
>
>> > https://sourceforge.net/tracker/?group_id=81968&atid=564599
>
>> >
>
>> > Discussions of bugs and features can be posted here
>
>> > To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>
>> > csound"
>
>> Send bugs reports to the Sourceforge bug tracker
>
>> https://sourceforge.net/tracker/?group_id=81968&atid=564599
>
>> Discussions of bugs and features can be posted here
>
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>
>> csound"

Date2012-09-22 07:01
FromTarmo Johannes
SubjectRe: [Csnd] CsoundAndroid: communication with channels
Hello,

I did some experimenting and I get it now - 
I thought it would not work to register an outputchannel (read values from 
Csound)  in the CsoundValueCacheable setup function with
getInputChannelPtr

but it works! It is possible to read the values from channel with function
updateValuesFromCsound() flawlessly.

I have now a test app working where I read some controlling values from 
android seekbars and radiobuttons, feed them to csound, csound makes some 
sounds and puts up some trigering flags in another channel. The android 
activyty watches  that channel and sends out according OSC  messages to 
desktop (using javaOSC). I am happy!

I need to polish the code a bit, I plan to write down some steps what I did to 
get the adnroid-csound project work - without knowing much java and eclipse-
android business, it was a lot of experimenting anad trial-and-error (mostly 
the latter ;) ) and the tutorial could save some time and trouble for others.

greetings,
tarmo



On Tuesday 18 September 2012 16:25:55 Steven Yi wrote:
> Hi Tarmo,
> 
> Happy to assist!  Also to note, the VoiceTouch application has a
> SpinnerValueCacheable class used to wrap and bind spinners to
> channels.  I think I'll probably look at adding this to the CsoundObj
> API for Android for future releases.
> 
> If you have other questions, please ask away.  I think the more people
> ask questions, the easier it is to see places where the project can be
> improved for everyone.
> 
> Good luck with your projects and looking forward to what you come up with!
> 
> steven
> 
> 
> On Tue, Sep 18, 2012 at 3:47 PM, Tarmo Johannes
> 
>  wrote:
> > Thank you, Steven.
> > 
> > 
> > 
> > it definitely cleared some things.
> > 
> > I will try out the solution later.
> > 
> >> Also, we could add a CsoundObj.setChannel(String name, float value) as
> >> 
> >> a convenience function. I imagine it would useful if you're doing a
> >> 
> >> one-time value set, instead of a continuous control channel. Is this
> >> 
> >> the use case which you were thinking of using this?
> > 
> > Yes, perhaps it would be handy in some cases. I understood now that it
> > more
> > efficient to use updateValueToCsound in most cases.
> > 
> > 
> > 
> > + thanks for the android project in the other mail! It is very helpful to
> > see other examples!
> > 
> > 
> > 
> > greetings,
> > 
> > tarmo
> > 
> > On Tuesday 18 September 2012 11:04:29 Steven Yi wrote:
> >> Hi Tarmo,
> >> 
> >> 
> >> 
> >> The CsoundValueCacheable interface is used for controlled reads/writes
> >> 
> >> from/to Csound. In general, the four method work as:
> >> 
> >> 
> >> 
> >> setup - used to cache channels (CsoundMYFLTArray is used in Java, they
> >> 
> >> hold references to MYFLT* underneath), and do any other setup
> >> 
> >> interactions with Csound
> >> 
> >> 
> >> 
> >> updateValueToCsound - here the csoundValueCacheable should write value
> >> 
> >> to csound if necessary. Typically you would use the CsoundMYFLTArray's
> >> 
> >> that you cached in the setup here.
> >> 
> >> 
> >> 
> >> updateValueFromCsound - here the csoundValueCacheable should read
> >> 
> >> values from csound if necessary. Typically you would use the
> >> 
> >> CsoundMYFLTArray's that you cached in the setup here.
> >> 
> >> 
> >> 
> >> cleanup - here you should clean up any listeners to UI elements and
> >> 
> >> anything else that would leave references around and cause memory
> >> 
> >> leaks
> >> 
> >> 
> >> 
> >> The idea with setup is to cache pointers so that you don't have to
> >> 
> >> look for the pointer again during runtime. It's more efficient to do
> >> 
> >> so, as the lookup for the pointer by channel name is not negligible.
> >> 
> >> 
> >> 
> >> Also, we could add a CsoundObj.setChannel(String name, float value) as
> >> 
> >> a convenience function. I imagine it would useful if you're doing a
> >> 
> >> one-time value set, instead of a continuous control channel. Is this
> >> 
> >> the use case which you were thinking of using this?
> >> 
> >> 
> >> 
> >> You also have the freedom to bypass the CsoundObj class altogether and
> >> 
> >> just use the Csound class. I'd still use CsoundObj to start as it
> >> 
> >> will create the underlying Csound class and hook it up for use with
> >> 
> >> OpenSL. After that, you can use csoundObj.getCsound() to get the
> >> 
> >> Csound API class and use the standard Csound5 API methods for grabbing
> >> 
> >> channels, table data, etc.
> >> 
> >> 
> >> 
> >> Hope that helps!
> >> 
> >> steven
> >> 
> >> 
> >> 
> >> On Mon, Sep 17, 2012 at 9:08 PM, Tarmo Johannes
> >> 
> >>  wrote:
> >> > Hi,
> >> > 
> >> > 
> >> > 
> >> > I am slowly learning how to write an android app using Csound. It goes
> >> > 
> >> > pretty well and seems extremely interesting!
> >> > 
> >> > 
> >> > 
> >> > I have some questions about handling Csound (data) channels.
> >> > 
> >> > 
> >> > 
> >> > It is great that there are convenience functions CsoundObj.addSlider
> >> > and
> >> > 
> >> > CsoundObj.addButton
> >> > 
> >> > -- by the way, what does the parameter 'type' mean in
> >> > 
> >> > public CsoundValueCacheable addButton(Button button, String
> >> > 
> >> > channelName,int
> >> > 
> >> > type)? --
> >> > 
> >> > 
> >> > 
> >> > but
> >> > 
> >> > 
> >> > 
> >> > A
> >> > 
> >> > 
> >> > 
> >> > when I need to send a value from some other widget or operation to
> >> > csound
> >> > 
> >> > via a csound channel, following the CsoundAndroidExamples, I figured
> >> > out
> >> > 
> >> > following way. Please comment, if it is correct to do so (works, at
> >> > 
> >> > least):
> >> > 
> >> > 
> >> > 
> >> > 1) declare a variable for the channel. like
> >> > 
> >> > private CsoundMYFLTArray beatsChannel;
> >> > 
> >> > 
> >> > 
> >> > 2) in definition of CsoundObj.addValueCacheable add
> >> > 
> >> > to function 'setup()' something like
> >> > 
> >> > beatsChannel = csoundObj.getInputChannelPtr("beats");
> >> > 
> >> > 
> >> > 
> >> > 3) in updateValuesToCsound() something like:
> >> > 
> >> > beatsChannel = csoundObj.getInputChannelPtr("beats"); // beats being a
> >> > 
> >> > variable of float, defined elsewhere
> >> > 
> >> > 
> >> > 
> >> > 4) to cleanup() something like
> >> > 
> >> > beatsChannel.Clear();
> >> > 
> >> > beatsChannel = null;
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > It is probalby not so easy or perhaps not even possible, but Steven,
> >> > 
> >> > Victor, have you considered to add a convenience function like
> >> > 
> >> > CsoundObj,setChannel(String name, float value) that would just do all
> >> > the
> >> > 
> >> > work?
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > B
> >> > 
> >> > and what I have to do to read values from csound channel by an android
> >> > 
> >> > activity?
> >> > 
> >> > 
> >> > 
> >> > There is function in CsoundObj
> >> > 
> >> > public CsoundMYFLTArray getInputChannelPtr(String channelName)
> >> > 
> >> > 
> >> > 
> >> > that uses constants CSOUND_CONTROL_CHANNEL | CSOUND_INPUT_CHANNEL
> >> > 
> >> > thus it would not probalby work for output from Csound?
> >> > 
> >> > 
> >> > 
> >> > Should there be a function something like getOutputChannelPtr or how
> >> > does
> >> > 
> >> > it work?
> >> > 
> >> > 
> >> > 
> >> > Can I use somehow CsoundObj.getCsound() to write somehow my own
> >> > 
> >> > readChannel() function or seomething like this?
> >> > 
> >> > 
> >> > 
> >> > thanks,
> >> > 
> >> > tarmo
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > Send bugs reports to the Sourceforge bug tracker
> >> > 
> >> > 
> >> > 
> >> > https://sourceforge.net/tracker/?group_id=81968&atid=564599
> >> > 
> >> > 
> >> > 
> >> > Discussions of bugs and features can be posted here
> >> > 
> >> > To unsubscribe, send email sympa@lists.bath.ac.uk with body
> >> > "unsubscribe
> >> > 
> >> > csound"
> >> 
> >> Send bugs reports to the Sourceforge bug tracker
> >> 
> >> https://sourceforge.net/tracker/?group_id=81968&atid=564599
> >> 
> >> Discussions of bugs and features can be posted here
> >> 
> >> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> >> 
> >> csound"
> 
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"

Date2012-09-23 00:31
FromSteven Yi
SubjectRe: [Csnd] CsoundAndroid: communication with channels
Very glad to hear you have things working for you!  I'm sure many will
appreciate hearing your experiences!

steven

On Sat, Sep 22, 2012 at 7:01 AM, Tarmo Johannes
 wrote:
> Hello,
>
> I did some experimenting and I get it now -
> I thought it would not work to register an outputchannel (read values from
> Csound)  in the CsoundValueCacheable setup function with
> getInputChannelPtr
>
> but it works! It is possible to read the values from channel with function
> updateValuesFromCsound() flawlessly.
>
> I have now a test app working where I read some controlling values from
> android seekbars and radiobuttons, feed them to csound, csound makes some
> sounds and puts up some trigering flags in another channel. The android
> activyty watches  that channel and sends out according OSC  messages to
> desktop (using javaOSC). I am happy!
>
> I need to polish the code a bit, I plan to write down some steps what I did to
> get the adnroid-csound project work - without knowing much java and eclipse-
> android business, it was a lot of experimenting anad trial-and-error (mostly
> the latter ;) ) and the tutorial could save some time and trouble for others.
>
> greetings,
> tarmo
>
>
>
> On Tuesday 18 September 2012 16:25:55 Steven Yi wrote:
>> Hi Tarmo,
>>
>> Happy to assist!  Also to note, the VoiceTouch application has a
>> SpinnerValueCacheable class used to wrap and bind spinners to
>> channels.  I think I'll probably look at adding this to the CsoundObj
>> API for Android for future releases.
>>
>> If you have other questions, please ask away.  I think the more people
>> ask questions, the easier it is to see places where the project can be
>> improved for everyone.
>>
>> Good luck with your projects and looking forward to what you come up with!
>>
>> steven
>>
>>
>> On Tue, Sep 18, 2012 at 3:47 PM, Tarmo Johannes
>>
>>  wrote:
>> > Thank you, Steven.
>> >
>> >
>> >
>> > it definitely cleared some things.
>> >
>> > I will try out the solution later.
>> >
>> >> Also, we could add a CsoundObj.setChannel(String name, float value) as
>> >>
>> >> a convenience function. I imagine it would useful if you're doing a
>> >>
>> >> one-time value set, instead of a continuous control channel. Is this
>> >>
>> >> the use case which you were thinking of using this?
>> >
>> > Yes, perhaps it would be handy in some cases. I understood now that it
>> > more
>> > efficient to use updateValueToCsound in most cases.
>> >
>> >
>> >
>> > + thanks for the android project in the other mail! It is very helpful to
>> > see other examples!
>> >
>> >
>> >
>> > greetings,
>> >
>> > tarmo
>> >
>> > On Tuesday 18 September 2012 11:04:29 Steven Yi wrote:
>> >> Hi Tarmo,
>> >>
>> >>
>> >>
>> >> The CsoundValueCacheable interface is used for controlled reads/writes
>> >>
>> >> from/to Csound. In general, the four method work as:
>> >>
>> >>
>> >>
>> >> setup - used to cache channels (CsoundMYFLTArray is used in Java, they
>> >>
>> >> hold references to MYFLT* underneath), and do any other setup
>> >>
>> >> interactions with Csound
>> >>
>> >>
>> >>
>> >> updateValueToCsound - here the csoundValueCacheable should write value
>> >>
>> >> to csound if necessary. Typically you would use the CsoundMYFLTArray's
>> >>
>> >> that you cached in the setup here.
>> >>
>> >>
>> >>
>> >> updateValueFromCsound - here the csoundValueCacheable should read
>> >>
>> >> values from csound if necessary. Typically you would use the
>> >>
>> >> CsoundMYFLTArray's that you cached in the setup here.
>> >>
>> >>
>> >>
>> >> cleanup - here you should clean up any listeners to UI elements and
>> >>
>> >> anything else that would leave references around and cause memory
>> >>
>> >> leaks
>> >>
>> >>
>> >>
>> >> The idea with setup is to cache pointers so that you don't have to
>> >>
>> >> look for the pointer again during runtime. It's more efficient to do
>> >>
>> >> so, as the lookup for the pointer by channel name is not negligible.
>> >>
>> >>
>> >>
>> >> Also, we could add a CsoundObj.setChannel(String name, float value) as
>> >>
>> >> a convenience function. I imagine it would useful if you're doing a
>> >>
>> >> one-time value set, instead of a continuous control channel. Is this
>> >>
>> >> the use case which you were thinking of using this?
>> >>
>> >>
>> >>
>> >> You also have the freedom to bypass the CsoundObj class altogether and
>> >>
>> >> just use the Csound class. I'd still use CsoundObj to start as it
>> >>
>> >> will create the underlying Csound class and hook it up for use with
>> >>
>> >> OpenSL. After that, you can use csoundObj.getCsound() to get the
>> >>
>> >> Csound API class and use the standard Csound5 API methods for grabbing
>> >>
>> >> channels, table data, etc.
>> >>
>> >>
>> >>
>> >> Hope that helps!
>> >>
>> >> steven
>> >>
>> >>
>> >>
>> >> On Mon, Sep 17, 2012 at 9:08 PM, Tarmo Johannes
>> >>
>> >>  wrote:
>> >> > Hi,
>> >> >
>> >> >
>> >> >
>> >> > I am slowly learning how to write an android app using Csound. It goes
>> >> >
>> >> > pretty well and seems extremely interesting!
>> >> >
>> >> >
>> >> >
>> >> > I have some questions about handling Csound (data) channels.
>> >> >
>> >> >
>> >> >
>> >> > It is great that there are convenience functions CsoundObj.addSlider
>> >> > and
>> >> >
>> >> > CsoundObj.addButton
>> >> >
>> >> > -- by the way, what does the parameter 'type' mean in
>> >> >
>> >> > public CsoundValueCacheable addButton(Button button, String
>> >> >
>> >> > channelName,int
>> >> >
>> >> > type)? --
>> >> >
>> >> >
>> >> >
>> >> > but
>> >> >
>> >> >
>> >> >
>> >> > A
>> >> >
>> >> >
>> >> >
>> >> > when I need to send a value from some other widget or operation to
>> >> > csound
>> >> >
>> >> > via a csound channel, following the CsoundAndroidExamples, I figured
>> >> > out
>> >> >
>> >> > following way. Please comment, if it is correct to do so (works, at
>> >> >
>> >> > least):
>> >> >
>> >> >
>> >> >
>> >> > 1) declare a variable for the channel. like
>> >> >
>> >> > private CsoundMYFLTArray beatsChannel;
>> >> >
>> >> >
>> >> >
>> >> > 2) in definition of CsoundObj.addValueCacheable add
>> >> >
>> >> > to function 'setup()' something like
>> >> >
>> >> > beatsChannel = csoundObj.getInputChannelPtr("beats");
>> >> >
>> >> >
>> >> >
>> >> > 3) in updateValuesToCsound() something like:
>> >> >
>> >> > beatsChannel = csoundObj.getInputChannelPtr("beats"); // beats being a
>> >> >
>> >> > variable of float, defined elsewhere
>> >> >
>> >> >
>> >> >
>> >> > 4) to cleanup() something like
>> >> >
>> >> > beatsChannel.Clear();
>> >> >
>> >> > beatsChannel = null;
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > It is probalby not so easy or perhaps not even possible, but Steven,
>> >> >
>> >> > Victor, have you considered to add a convenience function like
>> >> >
>> >> > CsoundObj,setChannel(String name, float value) that would just do all
>> >> > the
>> >> >
>> >> > work?
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > B
>> >> >
>> >> > and what I have to do to read values from csound channel by an android
>> >> >
>> >> > activity?
>> >> >
>> >> >
>> >> >
>> >> > There is function in CsoundObj
>> >> >
>> >> > public CsoundMYFLTArray getInputChannelPtr(String channelName)
>> >> >
>> >> >
>> >> >
>> >> > that uses constants CSOUND_CONTROL_CHANNEL | CSOUND_INPUT_CHANNEL
>> >> >
>> >> > thus it would not probalby work for output from Csound?
>> >> >
>> >> >
>> >> >
>> >> > Should there be a function something like getOutputChannelPtr or how
>> >> > does
>> >> >
>> >> > it work?
>> >> >
>> >> >
>> >> >
>> >> > Can I use somehow CsoundObj.getCsound() to write somehow my own
>> >> >
>> >> > readChannel() function or seomething like this?
>> >> >
>> >> >
>> >> >
>> >> > thanks,
>> >> >
>> >> > tarmo
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > Send bugs reports to the Sourceforge bug tracker
>> >> >
>> >> >
>> >> >
>> >> > https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> >> >
>> >> >
>> >> >
>> >> > Discussions of bugs and features can be posted here
>> >> >
>> >> > To unsubscribe, send email sympa@lists.bath.ac.uk with body
>> >> > "unsubscribe
>> >> >
>> >> > csound"
>> >>
>> >> Send bugs reports to the Sourceforge bug tracker
>> >>
>> >> https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> >>
>> >> Discussions of bugs and features can be posted here
>> >>
>> >> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> >>
>> >> csound"
>>
>> Send bugs reports to the Sourceforge bug tracker
>>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>
>
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>