Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Kontakt 6 Creator Tools LUA script for creating SFZ instruments. Outputs to console.
-- Check for valid instrument
if not instrument then
print("The following error message informs you that the Creator Tools are not "..
"focused on a Kontakt instrument. To solve this, load an instrument in "..
"Kontakt and select it from the instrument dropdown menu on top.")
return
end
print("// SFZ file for Kontakt 6 instrument " .. instrument.name)
print("")
--[[ Of course, all the above printed fields (name, volume and tune), as well as the rest of the
group fields are always displayed in the instrument's tree view.
In a similar way, you can also iterate over the zones of a group or a whole instrument.
--]]
local count = 0
for i,g in pairs(instrument.groups) do
local vol = g.volume
if vol < -144 then
vol = -144
end
print("<group>group_label=" .. g.name .. " volume=" .. vol .. " tune=" .. math.floor(g.tune*100))
for n,z in pairs(g.zones) do
local regionText = "<region>sample=" .. z.file ..
" volume=" .. z.volume ..
" tune=" .. math.floor(z.tune*100) ..
" pitch_keycenter=" .. z.rootKey ..
" offset=" .. z.sampleStart ..
" end=" .. z.sampleEnd ..
" lokey=" .. z.keyRange.low ..
" hikey=" .. z.keyRange.high ..
" lovel=" .. z.velocityRange.low ..
" hivel=" .. z.velocityRange.high
if z.loops[0].mode == 0 then
regionText = regionText .. " loop_mode=no_loop"
else
regionText = regionText .. " loop_mode=loop_continuous"
local loopEnd = z.loops[0].start + z.loops[0].length - 1
regionText = regionText .. " loop_start=" .. z.loops[0].start .. " loop_end=" .. loopEnd
end
print(regionText)
-- print("")
count = count + 1
end
end
@dhilowitz
Copy link
Author

dhilowitz commented Sep 29, 2021

I've just updated to translate SFZ tune= opcode correctly.

@anderseklov
Copy link

anderseklov commented Jan 28, 2022

Thanks for this, will be useful, with no quick tool (and free) around afik otherwise. Many around for EXS24 to SFZ or other formats, but not for Kontakt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment