|
10-17-2017, 09:41 AM
|
#1
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
Synchronising a display to bar and buffer size
On my wave display control there’s a bit of a gap between isPlaying becoming true, and wave data appearing at *in1 and *in2. It’s related to the host’s buffer size, but I thought this would be compensated for.
I know that some (maybe all?) hosts do a little pre-processing before the playhead so I tried putting in the following code to check when the next bar is been reached, which helped the control restart on a new bar if playback was initiated part way through a bar, but the timing is still out.
Is there a way I can account for this?
Code:
// Get the Bar position, used to reset the counter if the host was started not on a beat.
if (!m_WasPlaying && isPlaying) {
ResetDisplays();
FIRSTPLAYSYNCED = false;
// prevBar = -1;
prevBar = 1000000;
}
m_WasPlaying = isPlaying;
ITimeInfo TI; // declare a ITimeInfo var
int currentBar;
// Processing Loop
for (int s = 0; s < nFrames; ++s, ++scin1, ++scin2, ++in1, ++in2, ++out1, ++out2) {
GetTime(&TI);
double currentBeat = TI.mPPQPos;
char debugString[100];
currentBar = (int)(currentBeat/4);
// Check if the playhead has crossed a bar line, and sync the redraw when it does. Only happens once per play.
if (currentBar > prevBar && FIRSTPLAYSYNCED == false) {
ResetDisplays();
pWaveDisplay->ResetCounters();
FIRSTPLAYSYNCED = true;
}
prevBar = currentBar;
|
|
|
10-17-2017, 09:45 AM
|
#2
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Are you by some chance testing with Reaper? (It has by default a preprocessing amount of 200 milliseconds, which I suppose can throw off visual displays easily.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
10-17-2017, 10:01 AM
|
#3
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
Testing audio units in both Ableton and Logic, but I suspect that the predelay and buffer size is the problem. Well, not necessarily the problem, but likely the cause.
|
|
|
10-18-2017, 03:08 AM
|
#4
|
Human being with feelings
Join Date: Nov 2014
Location: Leiden, the Netherlands
Posts: 36
|
Hi Bobflip,
I'm not sure I understand the context properly, but I think TI.mPPQPos will return the same value for the whole buffer. So this value will not increment by itself calling it in your loop. Could this be the source of your issue?
Regards, JD
|
|
|
10-18-2017, 05:20 AM
|
#5
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
Quote:
Originally Posted by JD Young
Hi Bobflip,
I'm not sure I understand the context properly, but I think TI.mPPQPos will return the same value for the whole buffer. So this value will not increment by itself calling it in your loop. Could this be the source of your issue?
Regards, JD
|
Aha... potentially. I had moved it into the loop hoping for better accuracy. How else can I check that the next bar has been reached?
|
|
|
10-18-2017, 03:08 PM
|
#6
|
Human being with feelings
Join Date: Nov 2014
Location: Leiden, the Netherlands
Posts: 36
|
Hi Bobflip,
I use different ITimeInfo values for calculating the next bar PPQ position, and then increment the buffer PPQ position myself in the loop. (for AAX and RTAS I have added the implementation to some of this info to IPlug myself). So you need to calculate the next bar in PPQ as well as the increment amount per sample in PPQ. I would recommend finding the steinberg VST SDK online documentation about this, to see how this ports to VST in IPlug, especially the "LastBar" attribute. However, prepare from some serious research and testing to get this thing stable for all hosts and formats
JD
|
|
|
10-18-2017, 03:56 PM
|
#7
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
Oof, that's not the answer I wanted to hear, hahah! Thanks though :-)
I shall have a look into it, though sounds pretty complicated. For the time being I may simply add a Sequencer Retardation knob into the prefs, and work this out for v1.1.
|
|
|
10-20-2017, 04:44 AM
|
#8
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
Ok, so I’ve been investigating but I’m struggling to figure this one one out. samplesToNextClock looks ideal, but though it’s in the VST TimeInfo struct I can’t access it in IPlug’s ITimeInfo, and can’t see anything else in there that looks similar.
All the VST TimeInfo parameters that seem like they’d be able to help me get the information I need to calculate things I can't find in IPlug, LastBar only seems to change at the same time as the currentBar variable I’ve calculated. I don’t know how I’d update an ITimeInfo’s PPQ to find the next bar (I only know of the GetTime() function), and can’t find how to get the PPQ value to calculate the samples per PPQ, so I’m really not sure how to progress here.
|
|
|
10-20-2017, 02:41 PM
|
#9
|
Human being with feelings
Join Date: Nov 2014
Location: Leiden, the Netherlands
Posts: 36
|
Hi Bobflip,
Yeah, it took me a while to figure this one out tbh, especially for AAX and RTAS. I'm not sure if you are planning a full release including this scheme, but maybe we can discuss over email or skype one of these days, as it might take some time to discuss. Can't hurt somebody double-checking my implementation Feel free to email me at jchdejong@gmail.com. Hopefully the exact implementation you need is less confusing than mine, or somebody else has found an easier solution!
Regards, JD (Jochem)
|
|
|
10-20-2017, 02:48 PM
|
#10
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
I am indeed aiming for a proper release... very soon in fact! My plug is very close to completion, and this is one of the last issues to sort. Also the biggest one... the others are (I believe) much more straightforward.
Thanks for the offer of an email chat, I really appreciate it! I'll drop you a line :-)
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 06:41 PM.
|