Page 1 of 1

Master Clock / Song Position

Posted: Mon Aug 22, 2022 10:44 am
by UNZ
Haven't researched this yet very fondly, but it looks like there is no easy way to just get an accurate song position in Buzz? You'd think it's in MasterInfo, but nope, all relative to the current tick, and subtick info is relative to current tick also..

i guess these two would help, but they return an int and no documentation on what that int is supposed to be:
virtual int GetSongPosition();
virtual int GetAudioFrame();

what i'm trying to do is to react to changes in the transport i.e. when song position changes, jump ahead in my sample playing too. I remember BTDSys audio track did this.

PVST must also somehow do this, as it needs to support things like kVstTransportChanged and audioMasterGetTime.

So, it's apparently possible to at least approximate, just asking before i waste time figuring this out myself.
How do you get an accurate song position and detect jumps?

Re: Master Clock / Song Position

Posted: Mon Aug 22, 2022 2:54 pm
by wde
I'd assume GetSongPosition() returns current tick.

On the managed side you can do this to get position in samples:

Code: Select all

double avgSamplesPerTick = (60.0 * host.MasterInfo.SamplesPerSec) / (host.MasterInfo.BeatsPerMin * host.MasterInfo.TicksPerBeat);
int pos = (int)(song.PlayPosition * avgSamplesPerTick + host.MasterInfo.PosInTick);
Detecting jumps could be something like

Code: Select all

if (pos - prevPos > SamplesPerSubTick)...
(or compare ticks & subticks)

Re: Master Clock / Song Position

Posted: Mon Aug 22, 2022 8:13 pm
by UNZ
thanks, yeah i had a hunch it was ticks and that you'd have to resort to subtick granularity to detect transport jump. should be good enough i guess.

Re: Master Clock / Song Position

Posted: Fri Sep 02, 2022 12:49 am
by mute
BTDSys LiveJumpHack did a lot towards this... is the source still around? I once hosted it and it was also on sourceforge...but nowadays I dunno?

Re: Master Clock / Song Position

Posted: Fri Sep 02, 2022 8:43 am
by IXix
mute wrote: Fri Sep 02, 2022 12:49 am BTDSys LiveJumpHack did a lot towards this... is the source still around? I once hosted it and it was also on sourceforge...but nowadays I dunno?
Still there, dusty and unloved... https://sourceforge.net/p/btdsys/code/H ... /LiveJump/