Get tempo over time

Post topics about HALion scripting.
Post Reply
User avatar
abject39
Member
Posts: 327
Joined: Sat Jan 17, 2015 8:20 pm
Location: Ventura, Ca
Contact:

Get tempo over time

Post by abject39 »

Happy Holidays! I have been struggling to get the hosts tempo over time. My goal is to get the tempo and use it as a variable anywhere in my script. The issue is once the function is ran it gets the tempo only at that exact moment. If an end-user changes the tempo later the script isn't aware of the tempo change. I want to be able to continually tell the script to get the tempo. So far I've tried several things but none have worked. Anyone knows how I can enhance the following scipt?

Code: Select all

T1 = getTempo()
I've tried scripts such as the one below but nothing has worked.

Code: Select all

defineParameter("TempoDetect", nil, 0, 0, 10, 1) --Fast loop for sun gradient

function calcModulation()
  local freq = 100
  local rate = getSamplingRate() / 32
  local TempoDetect = TempoDetect + freq / rate
  
  if TempoDetect >= 10 then
      TempoDetect = TempoDetect - 10
      return getTempo(T1)
  end
end
Anyone know what I am doing incorrectly? No matter what I have tried I either end up with nil value for T1 or I end up only being able to get the tempo once.
My vision is uncompromising: to transcend my clients dreams by mesmerizing their audience with the world's finest audio arrangements and products.

misohoza
Member
Posts: 952
Joined: Sun Oct 05, 2014 12:18 am
Contact:

Re: Get tempo over time

Post by misohoza »

Hi Chris,

Is it for an animation?

Something like this could probably work:

Code: Select all

defineParameter("TempoDetect", nil, 0, 0, 10, 1) --Fast loop for sun gradient
assert(getTempo() ~= -1) --Check if host provides tempo information

local rate = getSamplingRate() / 32
local phase = 0

function calcModulation()
  if isPlaying() then
    _, phase = math.modf(getBeatTime())
  else
    local freq = getTempo() / 60
    phase = phase + freq / rate
  end

  if phase >= 1 then
    phase = phase - 1
  end

  TempoDetect = 10 * phase

end
Win 10 Home, 64 bit, 8 gb ram,
Cubase Pro 10.5, Wavelab Pro 9.5, Halion 6, Dorico 3,
NI Komplete 10 Ultimate, Ozone 7,
UR 44

User avatar
abject39
Member
Posts: 327
Joined: Sat Jan 17, 2015 8:20 pm
Location: Ventura, Ca
Contact:

Re: Get tempo over time

Post by abject39 »

Ooops! That comment was just an old comment I forgot to delete lol.

No it isn't for an animation. I am getting the tempo and then putting it into a table of note times as a synchronized option. So basically the user can choose to adjust the time in increments of milliseconds or synchronize to note values. When they choose to synchronize to note values I want to get the tempo and convert and calculate the note time value from the tempo. The issue I had is that if the tempo changes then the values in the table are not longer accurate. This is why I want the tempo to occasionally check the tempo to ensure accuracy. Your example doesn't seem to work for me either. I'll send you a PM.
My vision is uncompromising: to transcend my clients dreams by mesmerizing their audience with the world's finest audio arrangements and products.

Post Reply

Return to “Halion Scripting”

Who is online

Users browsing this forum: No registered users and 3 guests