COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 06-13-2017, 11:26 PM   #1
earlevel
Human being with feelings
 
Join Date: Dec 2015
Posts: 331
Default OnIdle timer for AU

IPlug has an OnIdle handler, but it's not call on AU—there is no related timer. (It was lacking in AAX, but I added it via a heartbeat supplied by the AAX host. VST has a timer implemented and hooked to OnIdle. So, just AU appears lacking.)

My plugin has the option to lock to tempo changes. At a glance, I don't think AU sends tempo changes, looks like it has to be polled. So, obviously I want a regular heartbeat timer at a priority higher than graphics but lower than the audio thread. Calling back for tempo is not something I want to do from ProcessDoubleReplacing, for instance.

I don't want to implement from scratch, because I'd have to implement and test/debug on both Mac and PC (only Mac if I confine the change to AU, though it would make some sense to make a solution that doesn't rely on format). At that point I'd just as soon look at JUCE. Am I missing something already there? Has someone else done this?

Last edited by earlevel; 06-14-2017 at 03:03 PM.
earlevel is offline   Reply With Quote
Old 06-14-2017, 12:12 AM   #2
1eqinfinity
Human being with feelings
 
Join Date: Apr 2014
Posts: 84
Default

Quote:
Originally Posted by earlevel View Post
Calling back for tempo is not something I want to do from ProcessDoubleReplacing, for instance.
If your plugin shouldn't do tempo related stuff with sample precision then requesting tempo outside of the frame processing loop in ProcessDoubleReplacing() could be functional. But of course this does live you with floating precision that depends on sample rate and block size.
I have not found another way (not that I tried hard though) and in one of my experiments had to stick with requesting tempo even from inside of the frame loop.
__________________
soundcloud.com/crimsonbrain
1eqinfinity is offline   Reply With Quote
Old 06-14-2017, 02:21 PM   #3
earlevel
Human being with feelings
 
Join Date: Dec 2015
Posts: 331
Default

The problem with requesting tempo from the sample processing (ProcessDoubleReplacing) thread is that it results in a callback to the host. It may result in a low overhead call, but that's really up to the host, making it a bad choice to be running at the audio processing priority.

So yeah, it will probably work, for any host that's not brain dead, but it's a bad design. In my case, tempo tracking doesn't need high precision—it's just for locking delay time to tempo.

But a possible secondary problem is that I should track tempo even if the host is not pushing audio. I'm not sure how likely that would be for any host. (Without going into details, in some cases it matters whether the tempo change happens right before processing audio, or several seconds before int he absence of audio.)
earlevel is offline   Reply With Quote
Old 06-15-2017, 12:04 AM   #4
1eqinfinity
Human being with feelings
 
Join Date: Apr 2014
Posts: 84
Default

I see. And I agree that that's not a good design. It would be interesting to know if there are hosts that run this operation noticeably slower than others.
__________________
soundcloud.com/crimsonbrain
1eqinfinity is offline   Reply With Quote
Old 06-17-2017, 01:46 PM   #5
earlevel
Human being with feelings
 
Join Date: Dec 2015
Posts: 331
Default

Just getting around to have a look—I think it will be easy enough to leverage the timer used for OnGUIIdle (need to verify it's running even when GUI is hidden, I think it is). It only runs at the "fps" rate, should be OK for this particular use, would be better to have it independent.
earlevel is offline   Reply With Quote
Old 06-17-2017, 01:59 PM   #6
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 654
Default

Quote:
Originally Posted by earlevel View Post
Just getting around to have a look—I think it will be easy enough to leverage the timer used for OnGUIIdle (need to verify it's running even when GUI is hidden, I think it is). It only runs at the "fps" rate, should be OK for this particular use, would be better to have it independent.
Be careful as OnGUIIdle is being called only is GUI is not dirty. It might be better to use IsDirty but I don't think that either of these are being called when GUI is closed.
Youlean is offline   Reply With Quote
Old 06-18-2017, 12:09 PM   #7
earlevel
Human being with feelings
 
Join Date: Dec 2015
Posts: 331
Default

Quote:
Originally Posted by Youlean View Post
Be careful as OnGUIIdle is being called only is GUI is not dirty. It might be better to use IsDirty but I don't think that either of these are being called when GUI is closed.
Sure, but I said "leverage the timer used for OnGUIIdle", not "use OnGUIIdle". However, the timer itself also only runs when the GUI is active (created/destroyed when window is opened/closed), so I'll basically be duplicated timer code and wiring it into a different place (to handle OnIdle).

Last edited by earlevel; 06-18-2017 at 12:52 PM.
earlevel is offline   Reply With Quote
Old 07-10-2017, 09:15 AM   #8
HoRNet
Human being with feelings
 
Join Date: Feb 2011
Posts: 171
Default

I think there's nothing wrong to ask for the tempo with GetTempo() in ProcessDoubleReplacing() just make sure to do your code only if the tempo has actually changed.

That's the only way to do it reliably (I remember RTAS crashing badly if i called GetTempo from anything but the audio thread)

Saverio
HoRNet is offline   Reply With Quote
Old 07-10-2017, 10:53 AM   #9
earlevel
Human being with feelings
 
Join Date: Dec 2015
Posts: 331
Default

Quote:
Originally Posted by HoRNet View Post
I think there's nothing wrong to ask for the tempo with GetTempo() in ProcessDoubleReplacing() just make sure to do your code only if the tempo has actually changed.

That's the only way to do it reliably (I remember RTAS crashing badly if i called GetTempo from anything but the audio thread)
Sure, the point was there should be a plugin idle implemented. Does OnIdle work for VST/VTS3 in IPlug? If so, it's not generally useful unless it's implemented in all plugin types that IPlug supports.

If you're crashing by calling GetTempo from other than the audio thread, then it's a bug. There is no reason you need to be in an audio thread to query the transport. I don't support RTAS, but it works fine for AAX. And it worked fine under TDM (non IPlug, of course).
earlevel 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 06:03 AM.


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