0.0.25 • Published 6 years ago
kontakt_script v0.0.25
Kontakt Script frontend
A small library providing a frontend to kontakt_script
Installation
Install it using npm:
$ npm install kontakt_script
Usage
Kontakt script can be used in real-time, or in batch processing mode
Batch processing
Batch processing mode will open a Kontakt file, perform a series of commands and then close it. This can be more efficient than real-time editing but does not give interactive feedback. Batch processing can be done either asynchronously or synchronously.
//Open test.nki and run a script (par 2)
kontakt_script.run.script("test.nki", "group_select @test\ngroup_name renamed\n\nsave", function (err, result)
{
console.log("Result of group select and rename was:");
console.log(result);
});
//Open test.nki and perform a single command synchronously
var result = kontakt_script.run.commandSync("test.nki", "program_libraryid 1234");
//Open test.nki and retrieve JSON formatted objects
var groups = kontakt_script.json.groupSync("test.nki");
console.log("Group 3 is called " + groups[2].name);
//Open test.nki and retrieve variables
var result = kontakt_script.variable.getSync("test.nki", ["$test","%arr"]);
console.log("Variables $test and %arr are:");
console.log(result);
Real-time processing
Real-time processing can only be done asynchronously. In this mode, Kontakt files are opened and modified in real-time, as if using the kontakt_script command line intepreter tool.
kontakt_script.open("test.nki", function(err, nki)
{
//nki object can be worked on
nki.do("program_name", function(err, res)
{
console.log("Program name is " + res + ". Changing to poop and clearing zones...");
nki.do(["program_name poop", "clear zones"], function(err, res)
{
console.log("All done. Saving...");
nki.do("save", function(err, res)
{
nki.close();
});
});
});
});