Minor updates from code review

"Off" option, improved note name handling, name change, code formatting
This commit is contained in:
Alby M 2019-02-18 10:44:49 -06:00 committed by Robin Gareus
parent ef43141301
commit 587960ac55
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -1,10 +1,10 @@
ardour { ardour {
["type"] = "dsp", ["type"] = "dsp",
name = "MIDI Remap Notes", name = "MIDI Note Mapper",
category = "Utility", category = "Utility",
license = "MIT", license = "MIT",
author = "Alby Musaelian", author = "Alby Musaelian",
description = [[Map arbitrary MIDI notes to others. Affects Note On/Off and polyphonic key pressure.]] description = [[Map arbitrary MIDI notes to others. Affects Note On/Off and polyphonic key pressure. Note that if a single note is mapped multiple times, the last mapping wins -- MIDI events are never duplicated.]]
} }
-- The number of remapping pairs to allow. Increasing this (at least in theory) -- The number of remapping pairs to allow. Increasing this (at least in theory)
@ -16,14 +16,14 @@ function dsp_ioconfig ()
return { { midi_in = 1, midi_out = 1, audio_in = 0, audio_out = 0}, } return { { midi_in = 1, midi_out = 1, audio_in = 0, audio_out = 0}, }
end end
function dsp_params () function dsp_params ()
local note_names = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}
local map_scalepoints = {} local map_scalepoints = {}
map_scalepoint["Off"] = -1
for note=0,127 do for note=0,127 do
local octave = -5 + math.floor(note / 12) local name = ARDOUR.ParameterDescriptor.midi_note_name(note)
local name = note_names[(note % 12) + 1] map_scalepoints[string.format("%03d (%s)", note, name)] = note
map_scalepoints[string.format("%03d (%s%d)", note, name, octave)] = note
end end
local map_params = {} local map_params = {}
@ -35,9 +35,9 @@ function dsp_params ()
map_params[i] = { map_params[i] = {
["type"] = "input", ["type"] = "input",
name = name, name = name,
min = 0, min = -1,
max = 127, max = 127,
default = 0, default = -1,
integer = true, integer = true,
enum = true, enum = true,
scalepoints = map_scalepoints scalepoints = map_scalepoints
@ -49,12 +49,14 @@ function dsp_params ()
return map_params return map_params
end end
function dsp_init(samplerate) function dsp_init(samplerate)
-- Init translation table, reserve memory -- Init translation table, reserve memory
translation_table = {} translation_table = {}
for i = 0,127 do for i = 0,127 do
translation_table[i] = i translation_table[i] = i
end end
translation_table[-1] = -1
end end