SunVox DLL audio_callback only works intermittently [FIXED]

Found a bug? Post it here.
Post Reply
User avatar
queries
Posts: 316
Joined: Tue May 10, 2016 9:51 pm

SunVox DLL audio_callback only works intermittently [FIXED]

Post by queries »

I was trying to use the sv_audio_callback function in SunVox DLL, and am running into a peculiar issue that I can't figure out just yet.

Whenever I would use it in a way similar to that used by the "test5.cpp" example code, all I got in the buffer were zeros.

Wondering if I was calling it incorrectly, I tried compiling the actual test5.cpp example, then running it and inspecting the output it gave. It was also writing out zeros! This was on both MacOS (10.11.6) and Linux (Xubuntu 16.04 distribution).

At some point later in the day, I tried my code again, and it started working as I expected it to. I was able to use it to successfully export songs to WAV files, and to do some spectrogram visualization.

Now that I'm trying the same code again this morning, it's not working again, despite zero modifications. :unknown:

SunVox itself works fine. The PixiLang example works (and appears to use the sv_audio_callback function in the DLL). Normal playback through audio out using the DLL works.

I'll try it later in the day to see if it's somehow related to clock time.
User avatar
queries
Posts: 316
Joined: Tue May 10, 2016 9:51 pm

Re: SunVox DLL audio_callback only works intermittently

Post by queries »

At the time I'm writing this, both the export tool I wrote, and the "test5.cpp" example, work as desired in OS X.

Again, no changes that I've made to code or environment. Just time of day is all I can figure so far.

Still doesn't work inside a Linux VM (still outputs all zeros).

Going to try it on other computers to see what results I get.
User avatar
queries
Posts: 316
Joined: Tue May 10, 2016 9:51 pm

Re: SunVox DLL audio_callback only works intermittently

Post by queries »

So strange. Still works on one MacOSX 10.11 machine... but outputs zeros on a MacOSX 10.7 machine... and on another Linux box (my web hosting account).
User avatar
NightRadio
Site Admin
Posts: 3941
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: SunVox DLL audio_callback only works intermittently

Post by NightRadio »

Please try to change the line 71 in test5.cpp
from: sv_audio_callback( buf, frames_num, 0, 0 );
to: sv_audio_callback( buf, frames_num, 0, sv_get_ticks() );

This is the reason of described bug. Sometimes the timestamp of the PLAY command is greater than 0, so the SunVox starts to wait for this command infinitely :)
User avatar
queries
Posts: 316
Joined: Tue May 10, 2016 9:51 pm

Re: SunVox DLL audio_callback only works intermittently

Post by queries »

Just what I needed... No longer stuck!

I shall now continue my work to document and manipulate this great software you've provided us. :)

I am curious, what is the advantage of using anything other than the current sv_get_ticks() when calling sv_audio_callback?
User avatar
NightRadio
Site Admin
Posts: 3941
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: SunVox DLL audio_callback only works intermittently

Post by NightRadio »

I am curious, what is the advantage of using anything other than the current sv_get_ticks() when calling sv_audio_callback?
It is actually the time, when the buffer comes out of the sound card.
SunVox needs it for correct user events (from the UI side) handling.
For example, if you write something like sv_get_ticks() - sv_get_ticks_per_second() * 60 (output time in past), it will delay all the user events for a minute.
Post Reply