Last active
September 7, 2019 21:52
-
-
Save antonhornquist/b2d76b753e51b27798ca5b348e30a42d to your computer and use it in GitHub Desktop.
Lua engine metadata examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ControlSpec = require 'controlspec' | |
local Formatters = require 'formatters' | |
local lib = {} | |
local specs = {} | |
specs.send = ControlSpec.DB:copy() | |
specs.send.default = -60 | |
specs.sample_start = ControlSpec.UNIPOLAR | |
specs.sample_end = ControlSpec.new(0, 1, 'lin', 0, 1, '') | |
specs.loop_point = ControlSpec.UNIPOLAR | |
specs.speed = ControlSpec.new(0.05, 5, 'lin', 0, 1, '') | |
specs.volume = ControlSpec.DB:copy() | |
specs.volume.default = -10 | |
specs.volume_env_attack = ControlSpec.new(0, 1, 'lin', 0, 0.001, 'secs') | |
specs.volume_env_release = ControlSpec.new(0, 3, 'lin', 0, 3, 'secs') | |
specs.filter_env_attack = ControlSpec.new(0, 1, 'lin', 0, 0.001, 'secs') | |
specs_filter_env_release = ControlSpec.new(0, 3, 'lin', 0, 0.25, 'secs') | |
specs.filter_cutoff = ControlSpec.FREQ:copy() | |
specs.filter_cutoff.default = 20000 | |
specs.filter_res = ControlSpec.UNIPOLAR | |
specs.filter_env_mod = ControlSpec.BIPOLAR | |
specs.dist = ControlSpec.UNIPOLAR | |
specs.delay_time = ControlSpec.new(0.0001, 5, 'exp', 0, 0.1, 'secs') | |
specs.delay_feedback = ControlSpec.new(0, 1.25, 'lin', 0, 0.5, '') | |
specs.delay_level = ControlSpec.DB:copy() | |
specs.delay_level.default = -10 | |
specs.reverb_room = ControlSpec.new(0, 1, 'lin', 0, 0.5, '') | |
specs.reverb_damp = ControlSpec.new(0, 1, 'lin', 0, 0.5, '') | |
specs.reverb_level = ControlSpec.DB:copy() | |
specs.reverb_level.default = -10 | |
lib.specs = specs | |
function lib.add_channel_sample_param(channel) | |
params:add_file(channel.."_sample", channel..": sample") | |
params:set_action(channel.."_sample", function(value) | |
if value ~= "-" then | |
engine.loadSample(channel-1, value) | |
end | |
end) | |
end | |
function lib.add_start_pos_param(channel) | |
params:add_control(channel.."_start_pos", channel..": start pos", specs.sample_start, Formatters.unipolar_as_percentage) | |
params:set_action(channel.."_start_pos", function(value) engine.sampleStart(channel-1, value) end) | |
end | |
function lib.add_end_pos_param(channel) | |
params:add_control(channel.."_end_pos", channel..": end pos", specs.sample_end, Formatters.unipolar_as_percentage) | |
params:set_action(channel.."_end_pos", function(value) engine.sampleEnd(channel-1, value) end) | |
end | |
function lib.add_loop_param(channel) | |
params:add_option(channel.."_loop", channel..": loop", {"off", "on"}) | |
params:set_action(channel.."_loop", function(value) | |
if value == 2 then | |
engine.enableLoop(channel-1) | |
else | |
engine.disableLoop(channel-1) | |
end | |
end) | |
end | |
function lib.add_loop_point_param(channel) | |
params:add_control(channel.."_loop_point", channel..": loop point", specs.loop_point, Formatters.unipolar_as_percentage) | |
params:set_action(channel.."_loop_point", function(value) engine.loopPoint(channel-1, value) end) | |
end | |
function lib.add_speed_param(channel) | |
params:add_control(channel.."_speed", channel..": speed", specs.speed, Formatters.unipolar_as_percentage) | |
params:set_action(channel.."_speed", function(value) engine.speed(channel-1, value) end) | |
end | |
function lib.add_vol_param(channel) | |
params:add_control(channel.."_vol", channel..": vol", specs.volume, Formatters.default) | |
params:set_action(channel.."_vol", function(value) engine.volume(channel-1, value) end) | |
end | |
function lib.add_vol_env_atk_param(channel) | |
params:add_control(channel.."_vol_env_atk", channel..": vol env atk", specs.volume_env_attack, Formatters.secs_as_ms) | |
params:set_action(channel.."_vol_env_atk", function(value) engine.volumeEnvAttack(channel-1, value) end) | |
end | |
function lib.add_vol_env_rel_param(channel) | |
params:add_control(channel.."_vol_env_rel", channel..": vol env rel", specs.volume_env_release, Formatters.secs_as_ms) | |
params:set_action(channel.."_vol_env_rel", function(value) engine.volumeEnvRelease(channel-1, value) end) | |
end | |
function lib.add_pan_param(channel) | |
params:add_control(channel.."_pan", channel..": pan", ControlSpec.PAN, Formatters.bipolar_as_pan_widget) | |
params:set_action(channel.."_pan", function(value) engine.pan(channel-1, value) end) | |
end | |
function lib.add_filter_cutoff_param(channel) | |
params:add_control(channel.."_filter_cutoff", channel..": filter cutoff", specs.filter_cutoff, Formatters.round(0.001)) | |
params:set_action(channel.."_filter_cutoff", function(value) engine.filterCutoff(channel-1, value) end) | |
end | |
function lib.add_filter_res_param(channel) | |
params:add_control(channel.."_filter_res", channel..": filter res", specs.filter_res, Formatters.unipolar_as_percentage) | |
params:set_action(channel.."_filter_res", function(value) engine.filterRes(channel-1, value) end) | |
end | |
function lib.add_filter_mode_param(channel) | |
params:add_option(channel.."_filter_mode", channel..": filter mode", {"lowpass", "bandpass", "highpass", "notch", "peak"}) | |
params:set_action(channel.."_filter_mode", function(value) engine.filterMode(channel-1, value-1) end) | |
end | |
function lib.add_filter_env_atk_param(channel) | |
params:add_control(channel.."_filter_env_atk", channel..": filter env atk", specs.filter_env_attack, Formatters.secs_as_ms) | |
params:set_action(channel.."_filter_env_atk", function(value) engine.filterEnvAttack(channel-1, value) end) | |
end | |
function lib.add_filter_env_rel_param(channel) | |
params:add_control(channel.."_filter_env_rel", channel..": filter env rel", lib.specs_filter_env_release, Formatters.secs_as_ms) | |
params:set_action(channel.."_filter_env_rel", function(value) engine.filterEnvRelease(channel-1, value) end) | |
end | |
function lib.add_filter_env_mod_param(channel) | |
params:add_control(channel.."_filter_env_mod", channel..": filter env mod", specs.filter_env_mod, Formatters.bipolar_as_percentage) | |
params:set_action(channel.."_filter_env_mod", function(value) engine.filterEnvMod(channel-1, value) end) | |
end | |
function lib.add_dist_param(channel) | |
params:add_control(channel.."_dist", channel..": dist", specs.dist, Formatters.unipolar_as_percentage) | |
params:set_action(channel.."_dist", function(value) engine.dist(channel-1, value) end) | |
end | |
function lib.add_mutegroup_param(channel) | |
params:add_option(channel.."_in_mutegroup", channel..": in mutegroup", {"no", "yes"}) | |
params:set_action(channel.."_in_mutegroup", function(value) | |
if value == 2 then | |
engine.includeInMuteGroup(channel-1, 1) | |
else | |
engine.includeInMuteGroup(channel-1, 0) | |
end | |
end) | |
end | |
function lib.add_delay_send_param(channel) | |
params:add_control(channel.."_delay_send", channel..": delay send", specs.send, Formatters.default) | |
params:set_action(channel.."_delay_send", function(value) engine.delaySend(channel-1, value) end) | |
end | |
function lib.add_reverb_send_param(channel) | |
params:add_control(channel.."_reverb_send", channel..": reverb send", specs.send, Formatters.default) | |
params:set_action(channel.."_reverb_send", function(value) engine.reverbSend(channel-1, value) end) | |
end | |
function lib.add_channel_params(channel) | |
lib.add_channel_sample_param(channel) | |
lib.add_start_pos_param(channel) | |
lib.add_end_pos_param(channel) | |
lib.add_loop_param(channel) | |
lib.add_loop_point_param(channel) | |
lib.add_speed_param(channel) | |
lib.add_vol_param(channel) | |
lib.add_vol_env_atk_param(channel) | |
lib.add_vol_env_rel_param(channel) | |
lib.add_pan_param(channel) | |
lib.add_filter_mode_param(channel) | |
lib.add_filter_cutoff_param(channel) | |
lib.add_filter_res_param(channel) | |
lib.add_filter_env_atk_param(channel) | |
lib.add_filter_env_rel_param(channel) | |
lib.add_filter_env_mod_param(channel) | |
lib.add_dist_param(channel) | |
lib.add_mutegroup_param(channel) | |
lib.add_delay_send_param(channel) | |
lib.add_reverb_send_param(channel) | |
end | |
function lib.add_effects_params() | |
params:add_control("delay_time", "delay time", specs.delay_time, Formatters.secs_as_ms) | |
params:set_action("delay_time", engine.delayTime) | |
params:add_control("delay_feedback", "delay feedback", specs.delay_feedback, Formatters.unipolar_as_percentage) | |
params:set_action("delay_feedback", engine.delayFeedback) | |
params:add_control("delay_level", "delay level", specs.delay_level, Formatters.default) | |
params:set_action("delay_level", engine.delayLevel) | |
params:add_control("reverb_room_size", "reverb room size", specs.reverb_room, Formatters.unipolar_as_percentage) | |
params:set_action("reverb_room_size", engine.reverbRoom) | |
params:add_control("reverb_damp", "reverb damp", specs.reverb_damp, Formatters.unipolar_as_percentage) | |
params:set_action("reverb_damp", engine.reverbDamp) | |
params:add_control("reverb_level", "reverb level", specs.reverb_level, Formatters.default) | |
params:set_action("reverb_level", engine.reverbLevel) | |
end | |
function lib.add_params() | |
for channel=1,8 do | |
lib.add_channel_params(channel) | |
params:add_separator() | |
end | |
lib.add_effects_params() | |
end | |
return { | |
name = "ack", | |
commands = { | |
{ name="delayFeedback", format="f" }, | |
{ name="delayLevel", format="f" }, | |
{ name="delaySend", format="if" }, | |
{ name="delayTime", format="f" }, | |
{ name="disableLoop", format="i" }, | |
{ name="enableLoop", format="i" }, | |
{ name="dist", format="i" }, | |
{ name="filterCutoff", format="if" }, | |
{ name="filterAttack", format="if" }, | |
{ name="filterEnvMod", format="if" }, | |
{ name="filterEnvRelease", format="if" }, | |
{ name="filterMode", format="ii" }, | |
{ name="filterRes", format="if" }, | |
{ name="includeInMuteGroup", format="ii" }, | |
{ name="kill", format="i" }, | |
{ name="loadSample", format="is" }, | |
{ name="loopPoint", format="if" }, | |
{ name="multiKill", format="iiiiiiii" }, | |
{ name="multiTrig", format="iiiiiiii" }, | |
{ name="pan", format="if" }, | |
{ name="reverbDamp", format="f" }, | |
{ name="reverbLevel", format="f" }, | |
{ name="reverbRoom", format="f" }, | |
{ name="reverbSend", format="if" }, | |
{ name="sampleEnd", format="if" }, | |
{ name="sampleStart", format="if" }, | |
{ name="speed", format="if" }, | |
{ name="trig", format="i" }, | |
{ name="volume", format="if" }, | |
{ name="volumeEnvAttack", format="if" }, | |
{ name="volumeEnvRelease", format="if" }, | |
}, | |
kind = "sc", | |
config = { | |
source="relative/path/to/Engine_Ack.scd" | |
}, | |
lib = lib | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return { | |
name = "co", | |
commands = { | |
{ name="treshold", format="f" }, | |
{ name="ratio", format="f" }, | |
{ name="attack", format="f" }, | |
{ name="release", format="f" }, | |
{ name="makeup", format="f" }, | |
{ name="automakeup", format="i" }, | |
}, | |
polls = { | |
{ name="gain_reduction" }, | |
}, | |
kind = "custom_jack_client", | |
config = { | |
executable="relative/path/to/co", | |
arguments="-r 8889 -t 8888", -- osc receive / transmit port | |
jack_client_name = "CO_JACK_CLIENT_NAME" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local NVOICES = 7 | |
local glut = { | |
name = "glut", | |
commands = { | |
{ name="gate", format="ii" }, | |
{ name="speed", format="if" }, | |
{ name="jitter", format="if" }, | |
{ name="size", format="if" }, | |
{ name="density", format="if" }, | |
{ name="pitch", format="if" }, | |
{ name="spread", format="if" }, | |
{ name="volume", format="if" }, | |
{ name="envscale", format="if" } | |
}, | |
kind="sc", | |
config = { | |
source="relative/path/to/Engine_Glut.scd" | |
} | |
} | |
glut.polls = {} | |
for voicenum=1,NVOICES do | |
table.insert(glut.polls, { name="phase_"..voicenum }) | |
table.insert(glut.polls, { name="level_"..voicenum }) | |
end | |
return glut |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return { | |
name = "passersby", | |
commands = { | |
{ name="amp", format="f" }, | |
{ name="attack", format="f" }, | |
{ name="decay", format="f" }, | |
{ name="drift", format="f" }, | |
{ name="envType", format="i" }, | |
{ name="fm1Amount", format="f" }, | |
{ name="fm1Ratio", format="f" }, | |
{ name="fm2Amount", format="f" }, | |
{ name="fm2Ratio", format="f" }, | |
{ name="glide", format="f" }, | |
{ name="lfoFreq", format="f" }, | |
{ name="lfoShape", format="f" }, | |
{ name="lfoToAttackAmount", format="f" }, | |
{ name="lfoToDecayAmount", format="f" }, | |
{ name="lfoToFm1Amount", format="f" }, | |
{ name="lfoToFm2Amount", format="f" }, | |
{ name="lfoToFreqAmount", format="f" }, | |
{ name="lfoToPeakAmount", format="f" }, | |
{ name="lfoToReverbMixAmount", format="f" }, | |
{ name="lfoToWaveFoldsAmount", format="f" }, | |
{ name="lfoToWaveShapeAmount", format="f" }, | |
{ name="noteKill", format="i" }, | |
{ name="noteKillAll" }, | |
{ name="noteOff", format="i" }, | |
{ name="noteOffAll" }, | |
{ name="noteOn", format="iff" }, | |
{ name="peak", format="f" }, | |
{ name="pitchBend", format="if" }, | |
{ name="pitchBendAll", format="f" }, | |
{ name="pressure", format="if" }, | |
{ name="pressureAll", format="f" }, | |
{ name="reverbMix", format="f" }, | |
{ name="timbre", format="if" }, | |
{ name="timbreAll", format="f" }, | |
{ name="waveFolds", format="f" }, | |
{ name="waveShape", format="f" }, | |
}, | |
polls = { | |
{ name="amp_in_l" }, | |
{ name="amp_in_r" }, | |
{ name="amp_out_l" }, | |
{ name="amp_out_r" }, | |
{ name="attackMod" }, | |
{ name="cpu_avg" }, | |
{ name="cpu_peak" }, | |
{ name="decayMod" }, | |
{ name="fm1AmountMod" }, | |
{ name="fm2AmountMod" }, | |
{ name="peakMulMod" }, | |
{ name="pitch_in_l" }, | |
{ name="pitch_in_r" }, | |
{ name="reverbMixMod" }, | |
{ name="waveFoldsMod" }, | |
{ name="waveShapeMod" }, | |
}, | |
kind = "sc", | |
config = { | |
source="relative/path/to/Engine_Passersby.scd" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return { | |
name = "r", | |
commands = { | |
{ name="new", format="ss" }, | |
{ name="delete", format="s" }, | |
{ name="connect", format="ss" }, | |
{ name="disconnect", format="ss" }, | |
{ name="set", format="sf" }, | |
{ name="bulkset", format="s" }, | |
{ name="newmacro", format="ss" }, | |
{ name="deletemacro", format="ss" }, | |
{ name="macroset", format="sf" }, | |
{ name="trace", format="i" } | |
}, | |
kind = "sc", | |
config = { | |
source="relative/path/to/Engine_R.scd" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return { | |
name = "testsine", | |
commands = { | |
{ name="amp", format="f" }, | |
{ name="hz", format="f" }, | |
}, | |
kind = "sc", | |
config = { | |
patch="relative/path/to/Engine_TestSine.scd" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return { | |
name = "testsine_pd", | |
commands = { | |
{ name="amp", format="f" }, | |
{ name="hz", format="f" }, | |
}, | |
kind = "pd", | |
config = { | |
patch="relative/path/to/testsine.pd" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment