[Cs-dev] Android channel reversal
Date | 2014-07-29 18:09 |
From | hcenteno |
Subject | [Cs-dev] Android channel reversal |
Hello, On an Android app, when starting and stopping Csound, about 1 out of 10 times the channels would output L-R reversed. nchnls is set to 2 and the same behaviour happened with outch, outs and outc. The reversal coincides with this message in logCat, although sometimes the message appears without causing reversal: I/AudioTrack﹕ track is underrun status. skip wait time. The message sometimes repeats more 2 or 3 times in a row. Sometimes the channels would revers a few milliseconds after sound starts to output. The orchestra uses diskin2 but I also tested with soundin and got the same results. I tested with an oscil signal on one channel and diskin2 on the other and the reversal still happened. If I instantiate CsoundObj with useAudioTrack set to true, there are no reversals and no track underrun messages. I'm using the latest Android Csound library and a Galaxy S3 running KitKat 4.4.2 Hector -- View this message in context: http://csound.1045644.n5.nabble.com/Android-channel-reversal-tp5736512.html Sent from the Csound - Dev mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/csound-deve |
Date | 2014-07-29 19:50 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android channel reversal |
What do you do when you starting/stopping? What is the sequence of operations? Looks like rtopensl might not be safely closed or reinitialised. ======================== Dr Victor Lazzarini Senior Lecturer NUI Maynooth, Ireland victor dot lazzarini at nuim dot ie On 29 Jul 2014, at 18:09, hcenteno |
Date | 2014-07-29 23:11 |
From | hcenteno |
Subject | Re: [Cs-dev] Android channel reversal |
Thanks Victor for asking, For instantiating CsoundObj I do (once during the app's life cycle): csoundObj = new CsoundObj(); csoundObj.messagePoster = this; csoundObj.setMessageLoggingEnabled(true); csoundObj.addCompletionListener(this); csoundObj.addValueCacheable(new CsoundValueCacheable() { ... // I'm setting up a few CsoundObj.getInputChannelPtrs here }); Then to start I'm doing - A series of calls to csound.setOption to set some flags - csoundObj.startCsound(csdFile) to start Csound - Then I trigger instruments using csoundObj.sendScore calls. I'm only calling csoundObj.stopCsound() for stopping. Best, Hector -- View this message in context: http://csound.1045644.n5.nabble.com/Android-channel-reversal-tp5736512p5736526.html Sent from the Csound - Dev mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2014-07-29 23:21 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android channel reversal |
Do you re-instantiate CsoundObj and do all the init startup things you describe, after a stop? ======================== Dr Victor Lazzarini Senior Lecturer NUI Maynooth, Ireland victor dot lazzarini at nuim dot ie On 29 Jul 2014, at 23:11, hcenteno |
Date | 2014-07-29 23:33 |
From | hcenteno |
Subject | Re: [Cs-dev] Android channel reversal |
No, I don't re-instantiate or do the init part after stopping. I found that I didn't need it to get everything working again after stopping (the cacheables, messages, completion listener, etc). I do set the flags again before restarting Csound since those seem to be gone after stopping. -- View this message in context: http://csound.1045644.n5.nabble.com/Android-channel-reversal-tp5736512p5736528.html Sent from the Csound - Dev mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2014-07-29 23:51 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android channel reversal |
Can you try re-instantiating and doing the init part? That would tell us whether the problem is related to this partial re-start. ======================== Dr Victor Lazzarini Senior Lecturer NUI Maynooth, Ireland victor dot lazzarini at nuim dot ie On 29 Jul 2014, at 23:33, hcenteno |
Date | 2014-07-30 00:09 |
From | hcenteno |
Subject | Re: [Cs-dev] Android channel reversal |
I just tried re-instantiating and initializing and the reversal and the underrun messages still happened. -- View this message in context: http://csound.1045644.n5.nabble.com/Android-channel-reversal-tp5736512p5736530.html Sent from the Csound - Dev mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2014-07-30 00:21 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android channel reversal |
Do they happen after you stop, or after you restart? ======================== Dr Victor Lazzarini Senior Lecturer NUI Maynooth, Ireland victor dot lazzarini at nuim dot ie On 30 Jul 2014, at 00:09, hcenteno |
Date | 2014-07-30 01:38 |
From | hcenteno |
Subject | Re: [Cs-dev] Android channel reversal |
Both the channel reversal and the underrun messages happen right after starting, when sound just starts to be heard. Sometimes I can hear the channels swapping a few milliseconds after starting. The underrun message sometimes happens without any reversal. -- View this message in context: http://csound.1045644.n5.nabble.com/Android-channel-reversal-tp5736512p5736532.html Sent from the Csound - Dev mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2014-07-30 01:45 |
From | hcenteno |
Subject | Re: [Cs-dev] Android channel reversal |
... once the channels swap they remain swapped until I stop and restart Csound (via a button on the app's UI). They would swap again randomly about 1 out of 10 times I start playback (from stopped state). -- View this message in context: http://csound.1045644.n5.nabble.com/Android-channel-reversal-tp5736512p5736533.html Sent from the Csound - Dev mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2014-07-30 09:19 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android channel reversal |
Do you hear dropouts when the underrun happens? By what you’re describing, in one of the audiotrack’s buffer layers there is an underrun of one (or an odd number of) sample, which offsets all subsequent buffers. As they are interleaved, the channels get reversed. However, I don’t see anything in the Csound android code that can cause that. What values of -b and -B do you use? You can try increasing -B. ======================== Dr Victor Lazzarini Senior Lecturer NUI Maynooth, Ireland victor dot lazzarini at nuim dot ie On 30 Jul 2014, at 01:45, hcenteno |
Date | 2014-07-30 15:57 |
From | hcenteno |
Subject | Re: [Cs-dev] Android channel reversal |
Hello Victor, Thank you! That's the explanation for the channel reversal I was trying to find. To answer your question, no, I don't hear any dropouts. It seems that the buffer underruns happen only when Csound is just starting because otherwise performance is clean and uneventful (with or without channels reversed). I'll experiment with different -b and -B values. Right now I'm using: --output=dac --iobufsamps=-1 --hardwarebufsamps=2048 --control-rate=480 --sample-rate=48000 Since I'm using -1 for -b then -b=ksmps, which equates to: ksmps=100 -b 100 -B 2048 Maybe -b is too small. I'll try with a larger negative value for -b. I'm still wondering why when not using OpenSL (audioTrack = true) I don't get this problem. Does using OpenSL really improve performance as compared to AudioTrack? I think there is a thread here discussing that so I'll revisit it. Thanks again! -- View this message in context: http://csound.1045644.n5.nabble.com/Android-channel-reversal-tp5736512p5736544.html Sent from the Csound - Dev mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2014-07-30 16:03 |
From | hcenteno |
Subject | Re: [Cs-dev] Android channel reversal |
on the AudioTrack vs OpenSL question, I found this: "OpenSL ES usage can't affect audio quality because it is just a wrapper over AudioTrack class in Android OS, so basically it is the same but when OpenSL ES used in native app it allows to skip calls to JNI interface and to avoid interacting with Dalvik Java virtual machine. But in terms of quality, the same 16-bit output is used because it is max when Android OS allows. Usage of OpenSL ES helped to minimize CPU usage due to absence of above said overhead." I wonder if there will be any improvements now that Google has completely dropped Dalvik in favour of ART for the next Android release (code-named "L"). I've read of some improvements in audio latency in L and that they are finally adding native support for USB audio. -- View this message in context: http://csound.1045644.n5.nabble.com/Android-channel-reversal-tp5736512p5736545.html Sent from the Csound - Dev mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2014-07-30 16:26 |
From | Michael Gogins |
Subject | Re: [Cs-dev] Android channel reversal |
Attachments | None None |
There are number of big changes in L. I am really looking forward to this. One thing is that I am hoping that WebGL will work in the Android SDK WebView class. If so then Android Csound will have first-class access via JavaScript in its CsHtml5 element to a complete, state of the art OpenGL renderer. Android Csound already has access to the Canvas element and can draw whatever you like on it. WebGL is even more powerful because of the three dimensions, easy animation, and shaders.
I agree that audio latency is a big deal and am curious to see what will happen with ART and Web Audio. Regards, Mike ----------------------------------------------------- Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Wed, Jul 30, 2014 at 11:03 AM, hcenteno <hcengar@gmail.com> wrote: on the AudioTrack vs OpenSL question, I found this: |
Date | 2014-07-30 18:36 |
From | hcenteno |
Subject | Re: [Cs-dev] Android channel reversal |
So I tried different sizes of -B and -b but I still got the message: I/AudioTrack﹕ track is underrun status. skip wait time. Repeated once or sometimes twice right after starting performance... but I should have mentioned that I'm using two diskin2 opcodes so maybe the underrun happens while the files are being opened. The underruns don't bother me at all, it is just the ocasional channel reversal that is problematic. I wonder if there is something that can be done to avoid that buffer offset when dropping buffers. Is this offset happening in the OpenSL or AudioTrack internals? Thanks! -- View this message in context: http://csound.1045644.n5.nabble.com/Android-channel-reversal-tp5736512p5736548.html Sent from the Csound - Dev mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net https://lists.sourceforge.ne |
Date | 2014-07-30 19:34 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android channel reversal |
I would suggest these settings ksmps=64 -b 512 -B 2048 Re: audiotrack, it might depend on the hardware, but rtopensl should be more efficient. ======================== Dr Victor Lazzarini Senior Lecturer NUI Maynooth, Ireland victor dot lazzarini at nuim dot ie On 30 Jul 2014, at 09:19, Victor Lazzarini |
Date | 2014-08-13 03:01 |
From | Michael Gogins |
Subject | Re: [Cs-dev] Android channel reversal |
Attachments | None None |
A bit off topic but not completely. The OpenSL driver in the code for the Csound6 android app may do something similar. In addition the audio output is easily overburdened and becomes very glitchy in thicker textures. I've added code to print the frames per buffer and frames per second reported by the android AudioManager. On my tablet that is 960 and 48000. If I set ksmps and sr accordingly, things go better but are still not perfect. Regards, On Jul 30, 2014 2:34 PM, "Victor Lazzarini" <Victor.Lazzarini@nuim.ie> wrote:
I would suggest these settings |