Hello,
Is there a parameter in Halion that provides the current BPM of the DAW or Standalone environment? When I load Halion in my DAW or use the standalone version, I need a way to retrieve the BPM that Halion is operating with. Any suggestions or solutions would be greatly appreciated!
Hi @clAud9 !
This should do the trick:
https://steinbergmedia.github.io/halion-script-api/HALion-Script/pages/getTempo.html?highlight=BPM#gettempo
Thanks, Philippe! Do you know if it’s possible to retrieve the metadata of an audio file using a LUA function when dragging and dropping the loop into HALion?
I’m working on a loop engine, and my files are all Apple Loops and ACID files that contain metadata like tempo, beats, key, etc. I’m looking for a way to have HALion read this metadata and transfer it to the parameters of my instrument.
I’ve searched online but haven’t found any information on this. Any guidance would be greatly appreciated!
On import, HALion will read the tempo, loop, and key information from a wave/aiff header, if available. It is then exposed as parameter for the Sample Zone.
You can access this with get/setParameter()
your_zone:getParameter("SampleOsc.OriginalTempo")
your_zone:getParameter("SampleOsc.Rootkey")
etc.
I assume you are planning to sync your loops to the current host tempo. HALion also has this built in. It will use the SampleOsc.OriginalTempo from the file header to adjust the stretching accordingly.
Just do this:
your_zone:setParameter("SampleOsc.StretchMode", 1))
Keep in mind that this is a base value. If you increase SampleOsc.OriginalTempo, the sample will play slower, if you reduce it, the sample will play faster.
Just play around with the parameters to get a hang for it.
More information about sample import is here:
getParameter() is documented here:
https://steinbergmedia.github.io/halion-script-api/HALion-Script/pages/getParameter.html
Hi Philippe,
Thanks for your help. I’ve set up a drop area in my instrument UI where I can drag and drop loops. The samples load into the zone correctly, and I can play the loop, but the OriginalTempo parameter does not update as expected.
When I drag and drop the same sample directly into HALion , the OriginalTempo parameter updates correctly with the loop’s BPM.
Could you help me understand what I need to add or adjust in my Lua script to ensure that the OriginalTempo parameter is updated when I drag and drop the sample into the drop area in my UI?
Thanks in advance!
Hmm, you are right. I did not fully think this through, because I did not create a drop while thinking about this, only about the parameters.
In the callback of the drop, you need to extract the information from the audio file.
Here is a high level explanation how it should work
- Drag your file to the drop
- The drop will return a string with the path
- Use this path in the callback of the drop control to create an audio file object:
AudioFile.open(filename) - set all the parameters of the sample zone based on the attributes of the audio file object.
The native sample zone drop field, does all this automatically. For macropages, you need to build all this by hand.
Sorry for the confusion.
Let me know if you should get stuck.
Hi Philippe, this code is working for all parameters except for the tempo! I’m getting a “nil” value in the output message all other parameters are reported correctly. I’m dropping an ACID file so tempo is stored in the file. Also if I drop the same file inside Halion tempo is detected. What I’m doing wrong?
defineParameter("Filename", nil, "", function() onFilenameChanged() end)
function onFilenameChanged()
local zone = this.parent:getZone()
local sample = AudioFile.open(Filename)
if sample.valid then
print("Sample Rate: ", sample.rate)
print("Bit Depth: ", sample.bits)
print("Channels: ", sample.channels)
print("Sample Length: ", sample.length)
print("Sample Tempo: ", sample.tempo)
zone:setParameter("SampleOsc.Filename", sample.fileName)
end
end
I tried also with all other parameters, and is detecting all except the Tempo. This is the output message after dropping an Acid Loop:
Sample Rate: 44100
Bit Depth: 24
Channels: 2
Length: 705600
Tempo: nil
Signature: 4
Root Key: 60
Beats: 32
Hello Philippe do you have any idea why the tempo is not detected, I tried also with beats and they are detected correctly, the “tempo” is the only one that is not working! I tried all versions (Mac, latest halion version) AU VST and Standalone, is not working for all. Maybe a bug? Can anyone try?
this is the preset:
Tempo not working.vstpreset (8.8 KB)
This is the output message:
Sample Rate: 44100
Bit Depth: 24
Channels: 2
Length: 201600
Tempo: nil
Beats: 8
This is the code I’m using:
defineParameter("Filename", nil, "", function() onFilenameChanged() end)
function onFilenameChanged()
local zone = this.parent:getZone()
local sample = AudioFile.open(Filename)
if sample.valid then
print("Sample Rate: ", sample.rate)
print("Bit Depth: ", sample.bits)
print("Channels: ", sample.channels)
print("Length: ", sample.length)
print("Tempo: ", sample.tempo)
print("Beats: ", sample.beats)
zone:setParameter("SampleOsc.Filename", sample.fileName)
end
end
Looking into this as soon as I find a moment. Thanks for your patience.
Thanks, Philippe. I’ve conducted some tests that I’d like to share with you. Below is the Debug Output Message from HALion. The only scenario where everything works 100% is when I export the loop from Cubase.
Debug Results:
Exported File from Cubase
(with “Include Tempo Information” enabled)
- Tempo: 120
- Beats: 8
Exported File from Logic
(with “Include Tempo Information” enabled)
- Tempo: nil
- Beats: nil
ACID Loop
- Tempo: nil
- Beats: 8
Apple Loop
- Tempo: nil
- Beats: nil
Observations:
- I understand there might be some “incompatibility” with files exported from Logic Pro. However, it’s still surprising that HALion cannot detect the BPM, even when the “Include Tempo Information” option is enabled during export.
- What’s even stranger is that for ACID loops, HALion detects the “Beats” but not the “Tempo.”
Thanks for looking deeper into this. I was able to reproduce it and it might be a bug. Good find.
I will add it into the bug database and ask a dev to have a look.