Master Clock / Song Position

Post Reply
User avatar
UNZ
Posts: 782
Joined: Mon Nov 21, 2011 9:42 pm
Contact:

Master Clock / Song Position

Post 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?

wde
Posts: 324
Joined: Sun Jan 08, 2012 9:28 am

Re: Master Clock / Song Position

Post 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)

User avatar
UNZ
Posts: 782
Joined: Mon Nov 21, 2011 9:42 pm
Contact:

Re: Master Clock / Song Position

Post 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.

mute
Posts: 402
Joined: Mon Nov 21, 2011 8:30 pm

Re: Master Clock / Song Position

Post 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?

User avatar
IXix
Posts: 1061
Joined: Wed Nov 23, 2011 3:24 pm

Re: Master Clock / Song Position

Post 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/

Post Reply