Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Kontakt 6 Creator Tools Export to Decent Sampler format
-- 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('<?xml version="1.0" encoding="UTF-8"?>')
print("<!-- DS file for Kontakt 6 instrument " .. instrument.name .. " -->")
print('<DecentSampler pluginVersion="1">')
print(' <groups>')
local count = 0
for i,g in pairs(instrument.groups) do
local vol = g.volume
if vol < -144 then
vol = -144
end
print(" <group name=\"" .. g.name .. "\" volume=\"" .. vol .. "dB\" tuning=\"" .. g.tune .. "\" ampVelTrack=\"1\">")
for n,z in pairs(g.zones) do
local regionText = " <sample path=\"Samples/" .. filesystem.filename(z.file) ..
"\" volume=\"" .. z.volume ..
"dB\" tuning=\"" .. string.format("%.2f",z.tune) ..
"\" rootNote=\"" .. z.rootKey ..
"\" start=\"" .. z.sampleStart ..
"\" end=\"" .. z.sampleEnd ..
"\" loNote=\"" .. z.keyRange.low ..
"\" hiNote=\"" .. z.keyRange.high ..
"\" loVel=\"" .. z.velocityRange.low ..
"\" hiVel=\"" .. z.velocityRange.high .. "\""
if z.loops[0].mode == 0 then
else
regionText = regionText .. " loopEnabled=\"true\""
local loopEnd = z.loops[0].start + z.loops[0].length - 1
regionText = regionText .. " loopStart=\"" .. z.loops[0].start .. "\" loopEnd=\"" .. loopEnd .. "\" loopCrossfade=\"" .. z.loops[0].xfade .. "\""
end
regionText = regionText .. " />"
print(regionText)
count = count + 1
end
print(" </group>")
end
print(" </groups>")
print("</DecentSampler>")
@paulwellnerbou
Copy link

paulwellnerbou commented Jan 31, 2022

That is great, thanks @dhilowitz.

Just a reminder for myself, as I keep forgetting it each time. How to use it:

  • open an instrument in Kontakt
  • open Creator Tools, and open the Lua Script tab in the lower window
  • drag & drop the file containing this script into the Lua Script tab
  • run the scripts pressing the play icon
  • copy the whole output: Ctrl+Alt+C
  • paste it into a *.dspreset file.

@KoltovichDV
Copy link

KoltovichDV commented Feb 24, 2022

That is great, thanks @dhilowitz 🙏

@praisetracks
Copy link

praisetracks commented Mar 9, 2022

This is such a powerful tool and I so appreciate the work that has brought it to us. I am really new at this but trying to learn.
One of the things I am doing is converting older Kontakt libraries that have their samples in a folder structure.
Is there a way to do the conversion and preserve the original sample folders?
This way you can load the Kontakt preset and the Decent Sampler presets while pulling from the same sample resource folders.
Thanks so much for the help,
Simeon

@paulwellnerbou
Copy link

paulwellnerbou commented Mar 10, 2022

@praisetracks Sure, this should work. But you might have to adjust the paths in the created file afterwards, you should be able to do this with Search&Replace in any editor.

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