sunvox_lib questions

Multi-platform modular music creation studio
Post Reply
Synthcrab
Posts: 4
Joined: Sun Oct 19, 2014 11:20 pm

sunvox_lib questions

Post by Synthcrab »

I'm doing some experimenting with the sunvox library and so far it works quite well. I do have a couple of questions about its functions and a some requests.
I'm using a C# to winx64.dll wrapper, but I've found it to be mostly consistent to the C syntax in the API page.

Firstly, some sunvox songs (such as nt's Berlin FM) are quite CPU heavy. In real-time applications the 64bit version might be have buffer underruns while the 32bit version fares better. I was wondering which parts of the x64 engine are more demanding so i can keep those in check when making more complicated projects.
Also, would a lofi-x64 version be possible?

As for functions, I have some trouble getting correct output of sv_get_module_scope2(). The data it returns is almost right but there is a slight crackling in the output. When checking the values it looks like 3 to 10 samples of data at the end of the previous buffer are at the start of the new buffer, which causes the crackling. Is this a bug or am i doing something wrong? This happens both with sv_audio_callback() and built-in output.
for reference, my code looks something like this.

Code: Select all

//dummy buffer is just used to trigger a callback
SunVox.sv_audio_callback(dummybuffer, dummybuffer.Length / 2, 0, SunVox.sv_get_ticks());

SunVox.sv_get_module_scope2(sunvoxSlot, moduleNum, 0, tempBuffer, (uint)tempBuffer.Length);

//convert mono int16 to stereo interleaved float32 of double size
for (int i = 0; i < tempBuffer.Length; i++)
        {
            floatConversion = tempBuffer[i] / 32768f;
            data[i + i] = floatConversion;
            data[i + i + 1] = floatConversion;
        }
Lastly, sv_get_number_of_patterns() seems to only return the closest multiple of 16 that the number of patterns fits in and not the exact number of patterns. Is this again a bug or am i doing something wrong?
User avatar
NightRadio
Site Admin
Posts: 3941
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: sunvox_lib questions

Post by NightRadio »

Firstly, some sunvox songs (such as nt's Berlin FM) are quite CPU heavy. In real-time applications the 64bit version might be have buffer underruns while the 32bit version fares better.
Hm, it's interesting...
You can try to check the CPU usage (module editor menu) in different SunVox versions. Maybe some specific modules...

sv_get_module_scope2(). The data it returns is almost right but there is a slight crackling in the output
sv_get_module_scope2() is only for visualization. It can't be used as the audio source since its accuracy depends on the system timer

sv_get_number_of_patterns() seems to only return the closest multiple of 16 that the number of patterns fits in and not the exact number of patterns.
The following functions do not return the actual number of objects, but return the number of slots.
Some slots may contain objects, and some may be empty.
sv_get_number_of_patterns()
sv_get_number_of_modules()
For example, sv_get_pattern_lines() will return -1 in case of the empty pattern slot.
I will try to explain this in more detail in the documentation...
Post Reply