COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

Reply
 
Thread Tools Display Modes
Old 10-17-2017, 09:41 AM   #1
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 341
Default 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;
Bobflip is offline   Reply With Quote
Old 10-17-2017, 09:45 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

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.
Xenakios is offline   Reply With Quote
Old 10-17-2017, 10:01 AM   #3
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 341
Default

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.
Bobflip is offline   Reply With Quote
Old 10-18-2017, 03:08 AM   #4
JD Young
Human being with feelings
 
JD Young's Avatar
 
Join Date: Nov 2014
Location: Leiden, the Netherlands
Posts: 36
Default

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
__________________
www.soundspot.audio / www.noiz-lab.com
JD Young is offline   Reply With Quote
Old 10-18-2017, 05:20 AM   #5
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 341
Default

Quote:
Originally Posted by JD Young View Post
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?
Bobflip is offline   Reply With Quote
Old 10-18-2017, 03:08 PM   #6
JD Young
Human being with feelings
 
JD Young's Avatar
 
Join Date: Nov 2014
Location: Leiden, the Netherlands
Posts: 36
Default

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
__________________
www.soundspot.audio / www.noiz-lab.com
JD Young is offline   Reply With Quote
Old 10-18-2017, 03:56 PM   #7
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 341
Default

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.
Bobflip is offline   Reply With Quote
Old 10-20-2017, 04:44 AM   #8
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 341
Default

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.
Bobflip is offline   Reply With Quote
Old 10-20-2017, 02:41 PM   #9
JD Young
Human being with feelings
 
JD Young's Avatar
 
Join Date: Nov 2014
Location: Leiden, the Netherlands
Posts: 36
Default

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)
__________________
www.soundspot.audio / www.noiz-lab.com
JD Young is offline   Reply With Quote
Old 10-20-2017, 02:48 PM   #10
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 341
Default

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 :-)
Bobflip is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:19 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.