Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fixes #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions lib/nb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ local mydir = debug.getinfo(1).source:match("@?" .. _path.code .. "(.*/)")
local player_lib = include(mydir .. "player")
local nb = {}

if note_players == nil then
note_players = {}
end

-- note_players is a global that you can add note-players to from anywhere before
-- you call nb:add_param.
nb.players = note_players -- alias the global here. Helps with standalone use.

nb.none = player_lib:new()

-- Set this before init() to affect the number of voices added for some mods.
Expand Down Expand Up @@ -92,7 +84,7 @@ local function add_midi_players()
mod_d = "cc " .. params:get("midi_modulation_cc_" .. i .. '_' .. j)
end
return {
name = "v.name",
name = v.name,
supports_bend = true,
supports_slew = false,
note_mod_targets = { "pressure" },
Expand All @@ -109,6 +101,14 @@ end

-- Call from your init method.
function nb:init()
if note_players == nil then
note_players = {}
end

-- note_players is a global that you can add note-players to from anywhere before
-- you call nb:add_param.
nb.players = note_players -- alias the global here. Helps with standalone use.

nb_player_refcounts = {}
add_midi_players()
self:stop_all()
Expand All @@ -122,7 +122,9 @@ function nb:add_param(param_id, param_name)
for name, _ in pairs(note_players) do
table.insert(names, name)
end
table.sort(names)
table.sort(names, function(a, b)
return string.lower(a) < string.lower(b)
end)
table.insert(names, 1, "none")
local names_inverted = tab.invert(names)
params:add_option(param_id, param_name, names, 1)
Expand All @@ -132,7 +134,7 @@ function nb:add_param(param_id, param_name)
local p = params:lookup_param(param_id)
local initialized = false
function p:get_player()
local name = params:get(string_param_id)
local name = tostring(params:get(string_param_id))
if name == "none" then
if p.player ~= nil then
p.player:count_down()
Expand All @@ -159,7 +161,7 @@ function nb:add_param(param_id, param_name)
initialized = true
end, p)
params:set_action(string_param_id, function(name_param)
local i = names_inverted[params:get(string_param_id)]
local i = names_inverted[tostring(params:get(string_param_id))]
if i ~= nil then
-- silently set the interface param.
params:set(param_id, i, true)
Expand Down
2 changes: 1 addition & 1 deletion lib/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function player:describe()
supports_slew = false,
modulate_description = "unsupported",
note_mod_targets = {},
voice_mod_tarets = {},
voice_mod_targets = {},
params = {},
}
end
Expand Down
4 changes: 4 additions & 0 deletions nb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ function grid_redraw()
end
end
g:refresh()
end

function cleanup()
nb:stop_all()
end