Module:Keyboard: Difference between revisions

Plumtree (talk | contribs)
mNo edit summary
Plumtree (talk | contribs)
mNo edit summary
Line 54: Line 54:
end
end
return p.build_keyboard(freqs, colours, key_width, key_height, dur, gain, instrument, harmonic_spectrum)
return p.build_keyboard(freqs, colours, {}, key_width, key_height, dur, gain, instrument, harmonic_spectrum)
end
end


Line 63: Line 63:
local freqs = {}
local freqs = {}
local colours = ''
local colours = ''
local seps = {}
for i = from, to do
for i = from, to do
Line 70: Line 71:
local j = (i % et.size) + 1
local j = (i % et.size) + 1
colours = colours .. layout:sub(j, j)
colours = colours .. layout:sub(j, j)
if j == 1 and i > from then
seps[j] = true
end
end
end
return p.build_keyboard(freqs, colours, key_width, key_height, dur, gain, instrument, harmonic_spectrum)
return p.build_keyboard(freqs, colours, seps, key_width, key_height, dur, gain, instrument, harmonic_spectrum)
end
end


function p.build_keyboard(freqs, colours, key_width, key_height, dur, gain, instrument, harmonic_spectrum)
function p.build_keyboard(freqs, colours, seps, key_width, key_height, dur, gain, instrument, harmonic_spectrum)
if #freqs ~= #colours then
if #freqs ~= #colours then
return '<span style="color:red;">Number of keys (' .. (#freqs) .. ') and of colours (' .. (#colours) .. ') are different!</span>'
return '<span style="color:red;">Number of keys (' .. (#freqs) .. ') and of colours (' .. (#colours) .. ') are different!</span>'
Line 92: Line 96:
s = s .. ' data-timbre-' .. instrument .. '="' .. table.concat(harmonic_spectrum, ' ') .. '"'
s = s .. ' data-timbre-' .. instrument .. '="' .. table.concat(harmonic_spectrum, ' ') .. '"'
end
end
s = s .. ' style="width: ' .. key_width .. 'px; height: ' .. key_height .. 'px; border: 1px solid #7f7f7f;"></div>'
s = s .. ' style="width: ' .. key_width .. 'px; height: ' .. key_height .. 'px; border: 1px solid #7f7f7f;'
if seps[i] then
s = s .. ' border-left: 1px solid #ff0000;'
end
if seps[i + 1] then
s = s .. ' border-right: 1px solid #ff0000;'
end
s = s .. '"></div>'
end
end
s = s .. '</div>'
s = s .. '</div>'