Csound Csound-dev Csound-tekno Search About

[Csnd-dev] CsoundAndroid getChannel problem

Date2023-09-07 21:57
FromTarmo Johannes
Subject[Csnd-dev] CsoundAndroid getChannel problem
Hi!

It is probably hard to guess but does anyone have a clue?

I am working on a Qt based Csound project that I want to make work on both desktop and Android. I use the Csound API via C++ (thus no Java), including AndroidCsound.hpp and linking against the -lcsoundandroid -lsndfile -lc++_shared libraries.  CsoundAndroid is  from official Csound downloads:

Everything works fine but I discovered Csound->GetChannel is malfunctioning  - it return always a very small number as if reading from some wrong place in the memory. No error messages.
On desktop it works as expected.

I remembered to have GetChannel functioning correctly in the past, I built the app with csound-android-6.12.0 (that used to work) and everything was correct.

I tried to make a build with 6.16 and 6.17 to figure out when the change can have happened but these builds caused some runtime errors (dlopen failed: cannot locate symbol "__emutls_get_address") and I gave up.

If it of any help, the project is up on:

In this case it is fine for me to stick with 6.12 but would be better to figure out, where is the reason.

Do you have any idea?

Thanks!
tarmo

Date2023-09-07 23:34
FromSteven Yi
SubjectRe: [Csnd-dev] CsoundAndroid getChannel problem
Only thing I can think of from the top of my head is checking if USE_DOUBLE is set correctly. 

On Thu, Sep 7, 2023 at 4:58 PM Tarmo Johannes <trmjhnns@gmail.com> wrote:
Hi!

It is probably hard to guess but does anyone have a clue?

I am working on a Qt based Csound project that I want to make work on both desktop and Android. I use the Csound API via C++ (thus no Java), including AndroidCsound.hpp and linking against the -lcsoundandroid -lsndfile -lc++_shared libraries.  CsoundAndroid is  from official Csound downloads:

Everything works fine but I discovered Csound->GetChannel is malfunctioning  - it return always a very small number as if reading from some wrong place in the memory. No error messages.
On desktop it works as expected.

I remembered to have GetChannel functioning correctly in the past, I built the app with csound-android-6.12.0 (that used to work) and everything was correct.

I tried to make a build with 6.16 and 6.17 to figure out when the change can have happened but these builds caused some runtime errors (dlopen failed: cannot locate symbol "__emutls_get_address") and I gave up.

If it of any help, the project is up on:

In this case it is fine for me to stick with 6.12 but would be better to figure out, where is the reason.

Do you have any idea?

Thanks!
tarmo

Date2023-09-22 11:34
FromTarmo Johannes
SubjectRe: [Csnd-dev] CsoundAndroid getChannel problem
Hi,

I came back to this project and had strange findings:

With CsoundAndroid 6.18  it does not matter - if I both set or do not set USE_DOUBLE -  MYFLT is always set to double and the results of all get functions, like   Csound->GetSr(), Csound->GetChannel()  are wrong (giving extremely small values).

With CsoundAndroid 6.12, when i do not set USE_DOUBLE then MYFLT stands for float and the return values are correct.

This problem happens only with the android, build on Desktop it is always right. I am testing it on a Samsung S9+ device, arm64 architecture, I use the arm64-v64 libraries to link the app against to:

  LIBS +=  -L/home/tarmo/src/csound-android-6.12.0/CsoundForAndroid/CsoundAndroid/src/main/jniLibs/arm64-v8a/ -lcsoundandroid -lsndfile -lc++_shared
(or the ones for csound-android-6.18.0 for the other build).

Does it make any sense?

How can I force MYFLT to be float? With Csound 6.18 just non defining USE_DOUBLE is not enough.


Thanks!
tarmo


Kontakt Steven Yi (<stevenyi@gmail.com>) kirjutas kuupäeval R, 8. september 2023 kell 01:34:
Only thing I can think of from the top of my head is checking if USE_DOUBLE is set correctly. 

On Thu, Sep 7, 2023 at 4:58 PM Tarmo Johannes <trmjhnns@gmail.com> wrote:
Hi!

It is probably hard to guess but does anyone have a clue?

I am working on a Qt based Csound project that I want to make work on both desktop and Android. I use the Csound API via C++ (thus no Java), including AndroidCsound.hpp and linking against the -lcsoundandroid -lsndfile -lc++_shared libraries.  CsoundAndroid is  from official Csound downloads:

Everything works fine but I discovered Csound->GetChannel is malfunctioning  - it return always a very small number as if reading from some wrong place in the memory. No error messages.
On desktop it works as expected.

I remembered to have GetChannel functioning correctly in the past, I built the app with csound-android-6.12.0 (that used to work) and everything was correct.

I tried to make a build with 6.16 and 6.17 to figure out when the change can have happened but these builds caused some runtime errors (dlopen failed: cannot locate symbol "__emutls_get_address") and I gave up.

If it of any help, the project is up on:

In this case it is fine for me to stick with 6.12 but would be better to figure out, where is the reason.

Do you have any idea?

Thanks!
tarmo

Date2023-09-22 11:51
FromGiovanni Bedetti
SubjectRe: [Csnd-dev] CsoundAndroid getChannel problem
Hi Tarmo,

not sure how to do it in Android, but in CsoundUnity (written in C#) we do something like this to force Android and iOS devices to interpret MYFLT as a float:

https://github.com/rorywalsh/CsoundUnity/blob/470893372c06da09f7b5de5d1b3f3ed50e277f22/Runtime/CsoundUnity.cs#L38-L42

#if UNITY_EDITOR || UNITY_STANDALONE
using MYFLT = System.Double;
#elif UNITY_ANDROID || UNITY_IOS
using MYFLT = System.Single;
#endif

Hope this helps!


Il giorno ven 22 set 2023 alle ore 11:35 Tarmo Johannes <trmjhnns@gmail.com> ha scritto:
Hi,

I came back to this project and had strange findings:

With CsoundAndroid 6.18  it does not matter - if I both set or do not set USE_DOUBLE -  MYFLT is always set to double and the results of all get functions, like   Csound->GetSr(), Csound->GetChannel()  are wrong (giving extremely small values).

With CsoundAndroid 6.12, when i do not set USE_DOUBLE then MYFLT stands for float and the return values are correct.

This problem happens only with the android, build on Desktop it is always right. I am testing it on a Samsung S9+ device, arm64 architecture, I use the arm64-v64 libraries to link the app against to:

  LIBS +=  -L/home/tarmo/src/csound-android-6.12.0/CsoundForAndroid/CsoundAndroid/src/main/jniLibs/arm64-v8a/ -lcsoundandroid -lsndfile -lc++_shared
(or the ones for csound-android-6.18.0 for the other build).

Does it make any sense?

How can I force MYFLT to be float? With Csound 6.18 just non defining USE_DOUBLE is not enough.


Thanks!
tarmo


Kontakt Steven Yi (<stevenyi@gmail.com>) kirjutas kuupäeval R, 8. september 2023 kell 01:34:
Only thing I can think of from the top of my head is checking if USE_DOUBLE is set correctly. 

On Thu, Sep 7, 2023 at 4:58 PM Tarmo Johannes <trmjhnns@gmail.com> wrote:
Hi!

It is probably hard to guess but does anyone have a clue?

I am working on a Qt based Csound project that I want to make work on both desktop and Android. I use the Csound API via C++ (thus no Java), including AndroidCsound.hpp and linking against the -lcsoundandroid -lsndfile -lc++_shared libraries.  CsoundAndroid is  from official Csound downloads:

Everything works fine but I discovered Csound->GetChannel is malfunctioning  - it return always a very small number as if reading from some wrong place in the memory. No error messages.
On desktop it works as expected.

I remembered to have GetChannel functioning correctly in the past, I built the app with csound-android-6.12.0 (that used to work) and everything was correct.

I tried to make a build with 6.16 and 6.17 to figure out when the change can have happened but these builds caused some runtime errors (dlopen failed: cannot locate symbol "__emutls_get_address") and I gave up.

If it of any help, the project is up on:

In this case it is fine for me to stick with 6.12 but would be better to figure out, where is the reason.

Do you have any idea?

Thanks!
tarmo