SunVox Dynamic Library for developers - android

Multi-platform modular music creation studio
Post Reply
User avatar
jph
Posts: 53
Joined: Sat Sep 01, 2012 6:20 pm
Location: Ontario, Canada
Contact:

SunVox Dynamic Library for developers - android

Post by jph »

Thanks for doing the Android build of the SunVox engine! (I have a couple games under development that will really benefit from some great sounding SunVox music)
We are have some issues getting it working on android with ZGameEditor,. Any help with the dependencies would be much appreciated;
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.
From this thread; http://www.emix8.org/forum/viewtopic.php?p=5858#5858
User avatar
NightRadio
Site Admin
Posts: 3548
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: SunVox Dynamic Library for developers - android

Post by NightRadio »

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).
User avatar
Rado1
Posts: 12
Joined: Wed Aug 29, 2012 1:38 pm

Re: SunVox Dynamic Library for developers - android

Post by Rado1 »

Hi, we finally made the SunVox library working in ZGameEditor. A simple trick was to rename sunvox.so to libsunvox.so which is now loaded correctly. The library is working fine in ZGE on Android.
User avatar
NightRadio
Site Admin
Posts: 3548
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: SunVox Dynamic Library for developers - android

Post by NightRadio »

Ah, ok :) Thank you for this info
User avatar
Rado1
Posts: 12
Joined: Wed Aug 29, 2012 1:38 pm

Re: SunVox Dynamic Library for developers - android

Post by Rado1 »

Hi NightRadio, would it be possible to extend the sunvox library API for a variant of the sv_load function taking the input not from a file but from memory? The reason is that on Android it is not possible to open a file from the app's assets folder by the current sv_load function, because the files are compressed there. For instance, ZGameEditor is able to uncompress these files to memory and to pass the pointer to this memory block to, e.g., a function from external library.
User avatar
NightRadio
Site Admin
Posts: 3548
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: SunVox Dynamic Library for developers - android

Post by NightRadio »

No problem :) I will add such functions.
User avatar
Rado1
Posts: 12
Joined: Wed Aug 29, 2012 1:38 pm

Re: SunVox Dynamic Library for developers - android

Post by Rado1 »

Hi,

having sv_load_from_memory() function and some more functions to obtain detailed information about modules, patterns, etc. in the new SunVox library is great! Thanks NightRadio. BTW there already exists its port to ZGameEditor and it works perfectly on Windows and Android. If you are interested in, check this forum.

However, I would be glad if I have clarified some of my questions and issues:

1. How to use sv_audio_callback()? What's its original purpose? My idea was to use it to visualize played signal in runtime, is it correct/feasible? I tried different parameters, but playing was always "chopped"/unsmooth.

2. Setting of sv_set_autostop() takes effect only if it goes after sv_play(). If sv_stop() was called in meantime without consequent sv_set_autostop(), the setting of the previous sv_set_autostop() call is forgotten. I would expect that setting of sv_set_autostop() is remembered also after also calling sv_stop().

3. When sv_set_autostop(x, 0) is used the music playing is repeated but no sound is produced in a next loop. As a workaround I use sv_set_autostop(x, 1), then checking sv_end_of_song(x), and if true, calling sv_load*(x, ...) and sv_play(x) again. My expectation is that if sv_set_autostop(x, 0) is used, the music playing is repeated automatically, without another sv_load*() and sv_play() calls.
User avatar
NightRadio
Site Admin
Posts: 3548
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: SunVox Dynamic Library for developers - android

Post by NightRadio »

Thank you for ZGE port!
1. How to use sv_audio_callback()? What's its original purpose?
With sv_audio_callback() you can ignore the built-in SunVox sound output mechanism and use some other sound system.
Here is an example:

Code: Select all

int channels = 2;
sv_init( 0, 44100, channels, SV_INIT_FLAG_USER_AUDIO_CALLBACK | SV_INIT_FLAG_AUDIO_FLOAT32 );
sv_open_slot( 0 );
//Now i want to get 32 frames of sound from the SunVox engine:
float buf[ 32 * channels ];
//SunVox wants to know when this piece of sound will be played by you:
unsigned int output_time = sv_get_ticks(); //Let's assume it will be played immediately
sv_audio_callback( buf, 32, 0, output_time );
//... and now you can do something with sound in buf[]: save it to disk, or send it to sound card
2. Setting of sv_set_autostop() takes effect only if it goes after sv_play(). If sv_stop() was called in meantime without consequent sv_set_autostop(), the setting of the previous sv_set_autostop() call is forgotten.
You are right. I will fix it in the next update.
3. When sv_set_autostop(x, 0) is used the music playing is repeated but no sound is produced in a next loop.
Hm... It works fine for me.
Craig Borten
Posts: 1
Joined: Wed Oct 30, 2013 10:30 am

Re: SunVox Dynamic Library for developers - android

Post by Craig Borten »

Hi, thanks for posting the example. So I can ignore the built-in SunVox sound output mechanism with sv_audio_callback(). Glad to hear that. I am gonna try to use some other sound system just now. I hope it will work.

____________________________
Outlook Help
www.outlookhelpnow.com
Post Reply