[Cs-dev] CsoundObj/CsoundAndroid design questions
Date | 2014-06-26 15:53 |
From | Michael Gogins |
Subject | [Cs-dev] CsoundObj/CsoundAndroid design questions |
Attachments | None None |
I have a question about the design for Csound channels in CsoundObj and CsoundAndroid.
The context for my question is that I have placed a WebView into the Csound6 app for Android. This WebView may contain an HTML 5 page loaded from a <CsHtml5> element in the csd file. This page will contain both HTML markup and JavaScript code, including references to JavaScript libraries such as Three.js and dat.GUI. The Csound app will push into the JavaScript context of this page a reference to an interface to the running instance of Csound. The page may then use form widgets, OpenGL ES objects, touches, and whatnot to create events that JavaScript will handle and use to control Csound by calling methods on the Csound interface.
The main jobs of the Csound interface will be: (1) To send signals to named Csound control channels. (2) To receive signals from named Csound control channels.
(3) To schedule Csound score events for performance by the running Csound. (4) To send new orchestra Code to Csound for compilation (live coding). My question may now make sense. The CsoundObj and CsoundAndroid design for channels uses cached values. Why was this done instead of simply calling the Csound API (inherited by AndroidCsound) directly?
Is thread safety a reason? Is setting up the values before Csound begins to run a reason? Any insight is appreciated. Regards, Mike ----------------------------------------------------- Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com |
Date | 2014-06-26 16:44 |
From | Steven Yi |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
Hi Michael, The design process allows for a lot of flexibility but also for thread-safety and performance. * The ValueCacheable can be used for single items, such as wrapping a slider or dropdown. * The ValueCacheable can be used to do any number of items. If the app designer wants to do all value transfers to/from Csound, they can do it in a single cacheable. (The MultiTouch example shows this) * The examples show ValueCacheables retrieving and storing the channel pointer, then setting/getting from the channel pointer directly. This is better for performance than using SetChannel or GetChannel does a hash lookup of the channel each time a values sets/gets, rather than a single one-time lookup. * The cacheable is read from/written to at precise times, namely at block boundaries. This ensures the value is consistent for the duration of the processing of the block. This makes it safe for threading. In general, the user still has to use the API for getting channel pointers if they are creating their own ValueCacheable. The ValueCacheable though adds a lifecycle to the process so that it values will be initialized at start, things are cleaned up when Csound stops, and values are read/written at block boundaries. Also, common bindings for widgets could be encapsulated and made reusable. To note, while the CsoundObj API is designed around the ValueCacheable, it is not necessary to use it. The user has ultimate discretion to ignore the cacheable system and use the standard Java Csound API if they like, or build their own system on top of the ValueCacheable if they have use cases that fall outside of the original design. I haven't done much WebView code since Android 1.5/1.6 era, so I'm not sure if there is anything new for interoperability between the WebView's JS code and the Java side. It might be possible to create a JavaScriptValueCacheable that could take in a function name for reading and another for writing, then call into the webview via the JS functions to transfer values. It could go something like: [in JS] function jsCallbackFunctionName(value) { // update slider with value } var cacheable = cacheableFactory.createFloatCacheable("jsCallbackFunctionName"); cacheable.setValue(40); where cacheableFactory would be some class to create cacheables and would have CsoundObj wrapped in its constructor. So the Java-side would prepare that with something like: CacheableFactory cf = new CachableFactory(csoundObj); webView.someFunctionToSetVar("cacheableFactory", cf); // I don't remember how interop works here... Hope that's useful! steven On Thu, Jun 26, 2014 at 10:53 AM, Michael Gogins |
Date | 2014-06-26 17:21 |
From | Michael Gogins |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
Attachments | None None |
Very helpful indeed! Thanks a lot. Best, On Jun 26, 2014 11:45 AM, "Steven Yi" <stevenyi@gmail.com> wrote:
Hi Michael, |
Date | 2014-06-29 16:21 |
From | Rory Walsh |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
Btw Mike, I do plan on porting Cabbage to Android in the near future. I do think however that your proposed plan will offer more versatility. I might give it a go this week. I'll be sure to let you know how it goes :) On 26 June 2014 18:21, Michael Gogins |
Date | 2014-06-29 16:25 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
What are you going to call it? Turnips? ======================== Dr Victor Lazzarini Senior Lecturer NUI Maynooth, Ireland victor dot lazzarini at nuim dot ie On 29 Jun 2014, at 16:21, Rory Walsh |
Date | 2014-06-29 16:38 |
From | Rory Walsh |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
That could lead to some confusion. I might just stick with Cabbage :) You must be a little relieved after last night!? Had Chile a little more self belief I think they could have won it. Let's see which Dutch team shows up tonight. We'll either see a 90 minute kung-fu contest led by Nigel De Jong, or an exhibition of football led by Robben and Van Perie. You just never know with that team! On 29 June 2014 17:25, Victor Lazzarini |
Date | 2014-06-29 17:33 |
From | Michael Gogins |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
Attachments | None None |
Cabbage on Android. Would that continue to use JUCE? Or would you base it on the CsoundObj class that I use? Or would you start from scratch? I should have this working in a day or so. I'm not finding that WebGL stuff shows up in the Android WebView on my devices, but JavaScript does work, so I'm pretty confident I can achieve my main goal, user-defined graphical interfaces for Csound on Android.
If you plan to use CsoundObj (i.e. the CsoundAndroid library) let me know if there are any additional features you need. Regards, Mike ----------------------------------------------------- Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Sun, Jun 29, 2014 at 11:38 AM, Rory Walsh <rorywalsh@ear.ie> wrote: That could lead to some confusion. I might just stick with Cabbage :) |
Date | 2014-06-29 18:22 |
From | Rory Walsh |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
Good question, and I'll certainly need some help in understanding how to pull it all together. For now I've managed to deploy a few simple JUCE applications to Android. This turned out to be very simple but I need to delve a little further to understand how it all works. You guys know better that I how this technology works, but it looks like JUCE provides hooks to generic JAVA functions that interface with the OS. So the ability to run c/c++ code on Android is possible via the NDK? The upside is I can use the exact same C++ code I use for Cabbage on Android. That's all pretty neat for the GUI side of things, but I assume it will a lot more work to link to Csound? Feedback is most welcome! On 29 June 2014 18:33, Michael Gogins |
Date | 2014-06-29 18:30 |
From | Steven Yi |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
Attachments | None None |
You can link to the libcsound.so library from JUCE C++ code I believe. Tarmo did something similar when building a QT example and didn't use any of the Java stuff. On Jun 29, 2014 1:23 PM, "Rory Walsh" <rorywalsh@ear.ie> wrote:
Good question, and I'll certainly need some help in understanding how |
Date | 2014-06-29 18:43 |
From | Rory Walsh |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
Happy days. I'll let you know how I get on! On 29 June 2014 19:30, Steven Yi |
Date | 2014-06-30 15:04 |
From | Felipe Sateler |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
On 29 Jun 2014 11:39, "Rory Walsh" |
Date | 2014-06-30 15:13 |
From | Rory Walsh |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
And today's thoughts go to the Mexicans. They must feel absolutely robbe(en)d! On 30 June 2014 16:04, Felipe Sateler |
Date | 2014-06-30 20:32 |
From | Michael Gogins |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
Attachments | None None |
I have finished this in a basic sort of way and pushed it to git. Over the next few days I will polish it up and post it to SourceForge with an example. User defined sliders work fine, I'm not sure the WebGL stuff on Android is ready for prime time. Regards, On Jun 26, 2014 12:21 PM, "Michael Gogins" <michael.gogins@gmail.com> wrote:
|
Date | 2014-06-30 20:58 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
That was the closest you’ll ever get. ======================== Dr Victor Lazzarini Senior Lecturer NUI Maynooth, Ireland victor dot lazzarini at nuim dot ie On 30 Jun 2014, at 15:04, Felipe Sateler |
Date | 2014-06-30 21:54 |
From | Rory Walsh |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
Attachments | None None |
Written like you really believe it!
On 30 Jun 2014 21:58, "Victor Lazzarini" <Victor.Lazzarini@nuim.ie> wrote:
That was the closest you’ll ever get. |
Date | 2014-06-30 22:16 |
From | jpff@cs.bath.ac.uk |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
Attachments | None |
Date | 2014-06-30 22:31 |
From | Rory Walsh |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
Attachments | None None |
Did you not see the game? Chile were bowled over, and Brazil simply chucked their way through to the next round! (Is that good criket speak?!)
On 30 Jun 2014 23:17, <jpff@cs.bath.ac.uk> wrote:
I am confused -- New Zealand v West Indies? Oxford U v Cambridge U? |
Date | 2014-06-30 22:35 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
John was talking about sport; this is religion. ======================== Dr Victor Lazzarini Senior Lecturer NUI Maynooth, Ireland victor dot lazzarini at nuim dot ie On 30 Jun 2014, at 22:31, Rory Walsh |
Date | 2014-06-30 23:17 |
From | Rory Walsh |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
Attachments | None None |
In that case they should rename the 'Christ the Redeemer' statue in Rio to 'Christ, the main striker up front in a 4-4-2 formation!' ;)
On 30 Jun 2014 23:35, "Victor Lazzarini" <Victor.Lazzarini@nuim.ie> wrote:
John was talking about sport; this is religion. |
Date | 2014-06-30 23:28 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
It’s a 4-3-3 actually. But it’s not Catholic at all. ======================== Dr Victor Lazzarini Senior Lecturer NUI Maynooth, Ireland victor dot lazzarini at nuim dot ie On 30 Jun 2014, at 23:17, Rory Walsh |
Date | 2014-07-01 12:03 |
From | Rory Walsh |
Subject | Re: [Cs-dev] CsoundObj/CsoundAndroid design questions |
Returning to the original thread, I managed to build Cabbage for Android. No Csound support just yet, it's the next thing to look at. I'm quite impressed by how easy it was to port an entire C++ project to Android using JUCE. On 1 July 2014 00:28, Victor Lazzarini |