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

SunVox for ZGE

Post by Rado1 »

I'm pleased to announce that ZGE can play SunVox files from now as an alternative to tracker files (.XM, .IT, .S3M, .MOD, ...) played by the Bass library.

SunVox is an excellent free tracker with modular synthesizer. It produces pretty small files, smaller than obvious tracker files - SunVox files usually do not contain samples, all sounds are generated in runtime. BTW I tried several trackers, loopers, and various music production SW, but SunVox is one of the most easy-to-learn and productive tools.

The SunVox Dynamic Library DLL can be downloaded from here. Please note, this is not the "official" DLL (yet), and it was produced by NightRadio (author of SunVox) specially for ZGE on my request. The library is larger than bass.dll, but it can be compensated by small music files. So, it is up to you which music player you choose for your projects. The library is provided just for Win32, Linux and OSX at the moment, however, there are plans also for Android.

Attached, you can find a simple demo project showing you a basic usage of the library. You need to download the DLL and copy it to the same directory.

The SunVox dll was more-or-less an experimental software up to now, used freely by people. Anyway, I asked for licensing and still waiting for the answer. I hope it's free and allowed to be used in our ZGE projects. (SunVox itself is distributed under the BSD license.)

Ville, if you think it's appropriate, you can put the SunVox external library to the distributed ZGE's Lib files and also to the "Add from library..." menu.
Attachments
SunVoxDemo.zip
SunVox demo project
(6.16 KiB) Downloaded 1158 times
Last edited by Rado1 on Fri Aug 31, 2012 6:08 pm, edited 1 time in total.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:)

Super! Been a fan of SunVox for a long time, and think it's a perfect* fit for ZGameEditor. Seems like it's not open source anymore though?

*Even though you lose a bit of performance compared to traditional MOD players.

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

Post by Rado1 »

Kjell wrote:Even though you lose a bit of performance compared to traditional MOD players.
Sure, runtime generation of sounds is always more processor-consuming than playing samples.

FYI here's the answer regarding to licensing and usage of the sunvox library: "Yes, you can use it freely. Only one requirement - mention about sunvox library somewhere in app description / about window." Good.
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

yup,. this is very cool,. Thanks so much for pulling this together Rado1!

Let us know if/when you are able to get Android support as well, as I am for the most part focusing on getting some more stuff into the the Play Store. SunVox will indeed get a nice logo/link placement in any game I make using it.

Just purchased SunVox for android to compose with,. and also to support Alexander Zolotov.
iterationGAMES.com
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Good work Rado1, I'm glad you could convince them to release another version of the DLL. Hope they make it that way from now on because it should be more easily to use from more languages if the function names are unmangled. And it would be cool if we could add support for the Android version later.

I'll add the external lib to ZGE library of course!
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

FYI the official distribution of the SunVox library has been extended by unmangled version of the dll used in ZGE, see the windows/lib_x86 directory. It's recommended to use this stable version in ZGE for future.

The dll has been updated with new release of SunVox 1.7.2 coming with some improvements of the engine. BTW Also the licensing conditions have been added.

Ville - could you please update the SV init constant section of the external library to the following:

Code: Select all

const int SV_INIT_FLAG_NO_DEBUG_OUTPUT = 1 << 0;
const int SV_INIT_FLAG_USER_AUDIO_CALLBACK = 1 << 1;
const int SV_INIT_FLAG_AUDIO_INT16 = 1 << 2;
const int SV_INIT_FLAG_AUDIO_FLOAT32 = 1 << 3;
const int SV_INIT_FLAG_ONE_THREAD =  1 << 4;
It seems that SV engine supports either single- or multi-threded execution now.
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

multi-threaded = nice! So how can we set the dll to run on a separate thread from the game? That would allow near limitlessly complex moduals to play,. or just keep more reasonable music tracks from sucking cpu form the game.

I noticed the; sv_send_event() function and this seems to make using single sounds from Sunvox as game effects possible,. i will build an example of that.

what does sv_get_module_flags() return? I am interested in getting some pattern data out for the possibility of synchronizing to game events,. music linked gameplay?

also I see that the dll offers; get_module_scope() I imagine that is the wave data shown on the modules in the tracker,. this could be interesting for music visualizations,. etc. any way to dump the data into an array in zge?

again, thanks for setting this up Rado1, as you can see it inspires me! (hoping for android support soon!!) also hoping NightRadio will add more pattern manipulation functions to the dll,. so the game can switch looping patterns or pattern blocks.
iterationGAMES.com
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Ok, here is a tests setup for using the SV sound as game effects,. one strangeness I found is that the module called is one number higher than in the SV file. Any idea why?

I think some rather interesting sounds will now be possible using the SV generators and effects (building our own networks) with the ability to modify the modules on the fly using this sv_send_event() function. Interesting stuff!
Attachments
SunVox_FX_test.zip
a .sunvox and a .zgeproj
(2.74 KiB) Downloaded 1044 times
iterationGAMES.com
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

jph_wacheski wrote:multi-threaded = nice! So how can we set the dll to run on a separate thread from the game? That would allow near limitlessly complex moduals to play,. or just keep more reasonable music tracks from sucking cpu form the game.
Is not the sunvox.dll running always in a separate thread? I checked it by process explorer, but I can be wrong, having no experience with windows threads. I also tried to experiment with the SV_INIT_FLAG_ONE_THREAD but no observable difference when used or not. I actually do not know what's its meaning.
jph_wacheski wrote:what does sv_get_module_flags() return? I am interested in getting some pattern data out for the possibility of synchronizing to game events,. music linked gameplay?
One of the following flags:

Code: Select all

const int SV_MODULE_FLAG_EXISTS = 1;
const int SV_MODULE_FLAG_EFFECT = 2;
const int SV_MODULE_INPUTS_OFF = 16;
const int SV_MODULE_INPUTS_MASK = 255 << SV_MODULE_INPUTS_OFF;
const int SV_MODULE_OUTPUTS_OFF = 16 + 8;
const int SV_MODULE_OUTPUTS_MASK = 255 << SV_MODULE_OUTPUTS_OFF;
As you know, the library allows you to obtain more information about modules, but I thought it is not useful for obvious ZGE applications. In addition I was not sure about usage of some of these functions, such as sv_get_module_flags(). I forgot to remove it. Do you think it can be useful? If so there are also other functions not included in ZGE adapter: tsv_get_module_inputs() and tsv_get_module_inputs() probably telling about the structure of modules. But they return int* and I did not know how to map them to ZGE. There are also functions such as tsv_get_module_xy() or tsv_get_module_color(), but we probably do not need to draw graph of modules in ZGE appplications.
jph_wacheski wrote:also I see that the dll offers; get_module_scope() I imagine that is the wave data shown on the modules in the tracker,. this could be interesting for music visualizations,. etc. any way to dump the data into an array in zge?
Aha, I was not sure about its semantic. If you are right, then it would be interesting to have this information. However, I do not know how to translate

void* tsv_get_module_scope(int slot, int mod_num, int channel, int* offset, int* size)

to ZGE. What to do with void* and int*?
jph_wacheski wrote:(hoping for android support soon!!) also hoping NightRadio will add more pattern manipulation functions to the dll,. so the game can switch looping patterns or pattern blocks.
I hope so.
jph_wacheski wrote:Ok, here is a tests setup for using the SV sound as game effects,. one strangeness I found is that the module called is one number higher than in the SV file. Any idea why?
Jph - really cool. I tested your demo with different instruments (eg. DrumSynth) and effects and I had a lot of fun. No clue why this +1 numbering.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Rado,
Rado1 wrote:What to do with void* and int*?
Use a xptr parameter in your ZLibrary. However, you can't use this as return type ( atm ), so you'd need to write a small wrapper for those functions. For example "void* foo(int bar, int* zed)" becomes "void fooWrapper(int bar, int* zed, void* data)".

K
darkhog
Posts: 58
Joined: Sun Sep 09, 2012 7:59 pm

Post by darkhog »

How can I detect if song ended? I.e. one of latest SunVox versions (don't remember if 1.7.1 or 1.7.2) have nice effect 30 which stops song when it is reached. Your lib handles this effect (checked), but how can I detect if it was reached?
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

sv_end_of_song() returns 0 if song is playing now, 1 if stopped. BTW in your case you probably want to use sv_set_autostop(int slot, int autostop) to disable looping - set autostop parameter to 1.
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Hi Rado,. has the Android .so for this been released yet? I would really like to use SunVox music in my new Android game. Failing that, was there not another library that you had rigged up for playing .xm mods? Please point to the thread so I can try that,. thanks a bunch!
iterationGAMES.com
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Hi Jph,
jph_wacheski wrote:has the Android .so for this been released yet?
it has not been released yet, AKAIK :( I tried to support also LibModPlug in ZGE, but has not obtained a clear definition of API, so after several unsuccessful trials I stopped this effort. We definitely need to find a library for playing mod files in our paid games (we can use bass only for free games). Any ideas?
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Android .so is now ready!

Post by jph_wacheski »

And there was much rejoicing,. .

http://www.warmplace.ru/
25th December 2012]
[Site news : SunVox development]
SunVox Dynamic Library for developers has been updated to v1.7.3. You can use this library to play SunVox songs in your Windows/Linux/OSX/Android applications.
What is new:
-added Android version (but now only tested with Pixilang applications);
-new functions: sv_lock_slot(), sv_unlock_slot(), sv_pattern_mute();
-some bugs fixed.
First one to posts a working sample .zgeproj gets a cookie! (or a pat on the head)
I will attempt after I dig out from under all this snow!
iterationGAMES.com
Post Reply