Page 2 of 6

Posted: Thu Dec 27, 2012 8:27 pm
by Rado1
Hi, each my trial to use sunvox library on android failed. The debug log says:

E/ZgeAndroid( 8664): failed to load: /data/data/com.rado1.SVDemo/lib/./sunvox.so

I tried all armeabi and armeabi-v7a, Stdcall and Cdecl... I have no other idea how make it working now :-( Any ideas?

Question: is an external library loaded only at the time of 1st call of an included function? If the project contained just ZExternalLibrary component without any call, the debug log did not contain any "Trying to load lib" comment and the application started.

Posted: Fri Dec 28, 2012 8:46 am
by VilleK
Yes it tries to load the library when it first executes a function. The stdcall/cdecl setting is not used on Android, it always uses the arm-abi calling convention.

A library can fail to load if it requires another library that isn't found. I can't find any information about which Android version is required for this sunvox-lib, maybe it requires a higher version that the one you are testing on? So it tries to link with another library that is missing on your device.

Perhaps ask on the sunvox forum which version is required? And please post your code with apk so we can test too on our devices.

Posted: Fri Dec 28, 2012 10:51 am
by Rado1
I used my old demo project for SunVox library, see the attachment. I temporarily commented the whole functionality except of sv_init() and sv_deinit() calls. This was tested on Android 4.0.4 (CyanogenMod) and Android 4.2.1, which is the latest version. The first step to achieve is to make the app running.

Posted: Fri Dec 28, 2012 2:56 pm
by VilleK
It's not working here either.

With this command (from Android ndk) "arm-linux-androideabi-readelf.exe -d sunvox.so" I can see it requires the following so-files:

[liblog.so]
[libandroid.so]
[libm.so]
[libOpenSLES.so]
[libc.so]
[libdl.so]

libOpenSLES is included in Android level 9 API and upwards. I thought maybe that it also required that ZGE to use at least level 9 but I tried that and still get the same error. So no clue so far.

Posted: Fri Dec 28, 2012 3:17 pm
by jph_wacheski
I just posted on NightRadio's forum to see what he can tell us,. .

http://www.warmplace.ru/forum/viewtopic.php?f=3&t=2402

I attempted hacking around with it,. alas, to no avail.

and there was much sadness in the land,. :(

Posted: Fri Dec 28, 2012 4:31 pm
by Rado1
VilleK wrote:[liblog.so]
[libandroid.so]
[libm.so]
[libOpenSLES.so]
[libc.so]
[libdl.so]
I found all these libraries on my device in the /system/lib directory. There may be another reason why sunvox.so cannot be loaded (?). Let see what NightRadio will answer.

Posted: Sat Dec 29, 2012 1:54 pm
by jph_wacheski
Hello!
I'm not familiar with ZGameEditor. But as a guess - may be you need to load libOpenSLES.so before sunvox.so loading?
I tested it in Pixilang, but Pixilang has all these libraries included by default (during Pixilang build).
not much help,. . :(
Do post if you think of anything new,.

Otherwise, I have built some decent ambient tunes using the ZGE sound engine,. I could go with ambient since rhythmic music does not play back well due to timing issues. I will continue my android game and perhaps add some sampled loops for beats? Perhaps I can make that work with the more ambient parts. Has anyone tried midi playback on android? I will test that too..,

Posted: Sat Dec 29, 2012 4:20 pm
by VilleK
Ok I tried various things and what got it working was renaming the file to: libsunvox.so

And setting the same name in ZExternalLibrary.BeforeInitExp

Let me know if it works for you too.

Posted: Sat Dec 29, 2012 4:36 pm
by Rado1
Dear friends, look at this...

Posted: Sat Dec 29, 2012 4:37 pm
by Rado1
Ahhh, I did not notice Ville you was the first ... :? I was working on the same thing in parallel.

One thing I noticed is that the music file could not be loaded from "/assets/test.sunvox", I renamed it to "libmusic.so" and put to libs directory. I would prefer if .sunvox files can be loaded from the assets directory, if possible.

Ville, is the lib*.so format of library file names mandatory just for ZGE or is it a general convention for all (most?) Android applications?

Posted: Sun Dec 30, 2012 8:53 am
by VilleK
We had the same idea :)

The lib*-thing seems to be a Linux convention but I did not think it was enforced. Perhaps the Android APK installer doesn't unpack files without the lib-prefix.

Asset files are never extracted from the apk so they can only be read from Java (or via the File component that call Java APIs). The general work-around seems to be putting files in the lib-folder, at least last time I googled on this.

Posted: Sun Dec 30, 2012 2:13 pm
by Rado1
VilleK wrote:Asset files are never extracted from the apk so they can only be read from Java (or via the File component that call Java APIs). The general work-around seems to be putting files in the lib-folder, at least last time I googled on this.
I see, the File component uses the Java API to extract files from /assets/ directory, but this is not working for functions from external libraries which access files.

Posted: Mon Dec 31, 2012 11:58 am
by VilleK
Rado1 wrote:I see, the File component uses the Java API to extract files from /assets/ directory, but this is not working for functions from external libraries which access files.
Correct. Imo, for best flexibility the SunVox API should have a function for opening a file from memory so we could use the File component with asset files and pass the buffer.

Posted: Mon Dec 31, 2012 12:06 pm
by Rado1
VilleK wrote:Correct. Imo, for best flexibility the SunVox API should have a function for opening a file from memory so we could use the File component with asset files and pass the buffer.
I also had this idea, unfortunately, SunVox lib does not offer this possibility now. I asked for it on the Sunvox forum.

Posted: Tue Apr 23, 2013 9:52 pm
by Rado1
New release of SunVox library is here. It provides some new features such as loading .sunvox files directly from memory, more information about modules and patterns, support for "audio feedback" (it seems to be a buffer for the played data), etc. I have not tried all the features yet.

Attached, you will find a simple demo of SunVox player loading input directly from the File component. From now, it is not necessary for Android versions to put .sunvox files to the libs/armeabi directory and to rename them to lib*.so. To run the demo, download the latest SunVox library and put the dll to the same directory as .zgeproj file. For Android, put the sunvox.so to the libs/armeabi directory and rename it to libsunvox.so. Have a fun!

Ville, could you please put the latest SunVox ZExternalLibrary to ZGE? It is included in the demo project. Thanks.