COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 04-16-2009, 03:18 PM   #1
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default GetSamplePos()

I'm trying to make a simple sample-accurate, beat synchronised ramp for a plugin i'm making. I commented out all the stuff in ProcessDoubleReplacing() in the iplug example, and used GetSamplePos(), to get the current sample position, however calling this alone in the sample loop seems to use up 20% of my cpu when i tested the VST version in MaxMSP (on Mac) ! It was about 8% in Live.

Am i doing something totally idiotic? Is there a simpler way to do this.

thanks,

oli
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 04-16-2009, 03:48 PM   #2
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,821
Default

GetSamplePos is a host callback (because only the host knows where in the project it is), it's up to the host how expensive the call is.

But, there's no point in calling it inside the loop -- it gives the sample position of the sample buffer passed to the plugin. You can call it once at the top of the function to get the starting position and then just increment in your loop.
schwa is offline   Reply With Quote
Old 04-16-2009, 05:30 PM   #3
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

thanks shwa, i realised i didn't have to call it every sample just after i posted...doh. One thing though... if i want a beat synchronised ramp, if the transport position gets changed mid block, i guess my ramp will be off. Or maybe the transport never position never jumps mid block?...thinking out loud.

oli
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin 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 01:10 AM.


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