I'm trying to sync playback on multiple slots. I noticed sv_set_event_t was added to the latest DLL release.
Can I use the sv_send_event event to control playback? If I could tell them all to start at the same time, I'm hoping that would sync the slots.
I noticed that I can change the BPM like so:
sv_send_event(0, 0, 0, 0, 0, 0x001F, bpm);
Is there an online reference for other special event control?
Thx!
Use sv_send_event to start/play from beginning
Re: Use sv_send_event to start/play from beginning
The ctl and ctl_val arguments to sv_send_event correspond to the CCEE and XXYY columns in the tracker.
So, the 0x001F you used is 1F in the EE column, which is the "Set BPM to XXYY" effect.
Any effect that works in the EE column in the tracker should work in sv_send_event.
So, the 0x001F you used is 1F in the EE column, which is the "Set BPM to XXYY" effect.
Any effect that works in the EE column in the tracker should work in sv_send_event.
- NightRadio
- Site Admin
- Posts: 3944
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: Use sv_send_event to start/play from beginning
In this code:If I could tell them all to start at the same time, I'm hoping that would sync the slots.
sv_send_event( slot1, ... )
sv_send_event( slot2, ... )
the events will be processed at approximately the same time.
But if you want to use the exact time value, try the following way:
Code: Select all
int evt_t = 500; //event time in the future relative to the current moment; in milliseconds;
evt_t = sv_get_ticks() + evt_t * sv_get_ticks_per_second() / 1000;
sv_set_event_t( slot1, 1, evt_t );
sv_send_event( slot1, ... );
sv_set_event_t( slot1, 0, 0 ); //back to automatic time setting
sv_set_event_t( slot2, 1, evt_t );
sv_send_event( slot2, ... );
sv_set_event_t( slot2, 0, 0 ); //back to automatic time setting
Re: Use sv_send_event to start/play from beginning
To clarify, I was hoping to start the timeline playback with sv_set_event().
When I do this, the slots do not start playing at the same time (slot 0 and 1 are not in sync):
So, I was hoping to use the new sv_set_event_t() with sv_set_event() to replace sv_play_from_beginning().
When I do this, the slots do not start playing at the same time (slot 0 and 1 are not in sync):
Code: Select all
sv_play_from_beginning(0);
sv_play_from_beginning(1);
So, I was hoping to use the new sv_set_event_t() with sv_set_event() to replace sv_play_from_beginning().
Code: Select all
sv_set_event_t(...);
sv_set_event( 0, 0, 0, 0, ??, ?? ); // What module and value to Play song?
sv_set_event( 1, 0, 0, 0, ??, ?? ); // What module and value to Play song?
Last edited by grig on Sun Mar 15, 2020 1:15 am, edited 4 times in total.
Re: Use sv_send_event to start/play from beginning
Is there a "Play" effect in the CCEE column of the tracker?queries wrote: ↑Fri Mar 13, 2020 10:54 pm The ctl and ctl_val arguments to sv_send_event correspond to the CCEE and XXYY columns in the tracker.
So, the 0x001F you used is 1F in the EE column, which is the "Set BPM to XXYY" effect.
Any effect that works in the EE column in the tracker should work in sv_send_event.
Re: Use sv_send_event to start/play from beginning
I just found this in the manual:
"30 - stop playing the song;"
Is there a Start playing the song?
OR another way to sync timeline playback on multiple slots?
"30 - stop playing the song;"
Is there a Start playing the song?
OR another way to sync timeline playback on multiple slots?
- NightRadio
- Site Admin
- Posts: 3944
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: Use sv_send_event to start/play from beginning
sv_send_event( slot, 0, NOTECMD_PLAY, 0, 0, 0, 0 );Is there a Start playing the song?
Re: Use sv_send_event to start/play from beginning
It seems that when I schedule an event with sv_set_event_t(), I must wait for the event to occur, before scheduling the next event. Is that correct?
- NightRadio
- Site Admin
- Posts: 3944
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: Use sv_send_event to start/play from beginning
No.It seems that when I schedule an event with sv_set_event_t(), I must wait for the event to occur, before scheduling the next event. Is that correct?
But remember, that the SunVox will try to read events in the same order in which they were sent, regardless of time.
The SunVox engine can't proceed to the next events until the current event is processed.
Example:
sv_set_event_t( slot, 1, sv_get_ticks() + sv_get_ticks_per_second() * 2 ); //event(s) must happen after two seconds
sv_send_event( EVT1 );
sv_set_event_t( slot, 1, sv_get_ticks() + sv_get_ticks_per_second() ); //event(s) must happen after a second
sv_send_event( EVT2 );
What we expect: ... 1sec ... EVT2 ... 1sec ... EVT1 ...
What we actually get: ... 2sec ... EVT1 ... EVT2 ...
What will happen in the engine:
1) read the next event;
2) got EVT1;
3) can we process it? No. Waiting 2 seconds....
4) process EVT1;
5) read the next event;
6) got EVT2;
7) can we process it? Yes. Because one second has already passed;
8) process EVT2;
Correct code for this example:
sv_set_event_t( slot, 1, sv_get_ticks() + sv_get_ticks_per_second() ); //event(s) must happen after a second
sv_send_event( EVT2 );
sv_set_event_t( slot, 1, sv_get_ticks() + sv_get_ticks_per_second() * 2 ); //event(s) must happen after two seconds
sv_send_event( EVT1 );
Re: Use sv_send_event to start/play from beginning
Thanks again - this was very helpful!