SunVox for ZGE

Use of external libraries (DLLs) from ZGE.

Moderator: Moderators

User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 » Thu Dec 27, 2012 8:27 pm

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.

User avatar
VilleK
Site Admin
Posts: 2194
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK » Fri Dec 28, 2012 8:46 am

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.

User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 » Fri Dec 28, 2012 10:51 am

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.
Attachments
SunVoxDemo.zip
Demo project + apk
(497.3 KiB) Downloaded 578 times

User avatar
VilleK
Site Admin
Posts: 2194
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK » Fri Dec 28, 2012 2:56 pm

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.

User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski » Fri Dec 28, 2012 3:17 pm

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,. :(
iterationGAMES.com

User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 » Fri Dec 28, 2012 4:31 pm

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.

User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski » Sat Dec 29, 2012 1:54 pm

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..,
iterationGAMES.com

User avatar
VilleK
Site Admin
Posts: 2194
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK » Sat Dec 29, 2012 4:20 pm

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.

User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 » Sat Dec 29, 2012 4:36 pm

Dear friends, look at this...
Attachments
SunVoxDemo.zgeproj
ZGE project file
(9.95 KiB) Downloaded 544 times
ZGE SunVox Demo-debug.apk
sunvox lib is working :-)
(500.04 KiB) Downloaded 510 times
Last edited by Rado1 on Sat Dec 29, 2012 4:39 pm, edited 1 time in total.

User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 » Sat Dec 29, 2012 4:37 pm

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?

User avatar
VilleK
Site Admin
Posts: 2194
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK » Sun Dec 30, 2012 8:53 am

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.

User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 » Sun Dec 30, 2012 2:13 pm

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.

User avatar
VilleK
Site Admin
Posts: 2194
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK » Mon Dec 31, 2012 11:58 am

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.

User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 » Mon Dec 31, 2012 12:06 pm

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.

User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 » Tue Apr 23, 2013 9:52 pm

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.
Attachments
SunVoxDemo3.zgeproj
SunVox demo #3
(93.06 KiB) Downloaded 732 times

Post Reply