Moduuli:Bassokirja/Säestyskuvio
Ulkoasu
Tämän moduulin ohjeistuksen voi tehdä sivulle Moduuli:Bassokirja/Säestyskuvio/ohje
local p = {}
local tekstipohja = require "Moduuli:Tekstipohja"
local templ = require "Moduuli:Bassokirja/Säestyskuvio/pohja"
local scoreText_template = templ.text
function p.saestyskuvio(frame)
if frame.args.frame == "malline" then
frame = frame:getParent()
end
local nowiki = frame.args.nowiki and (frame.args.nowiki ~= "")
local time_signature = frame.args.tahtilaji or "4/4"
local tempo = frame.args.tempo or "120"
local swing = frame.args.swing and (frame.args.swing ~= "")
local repeats = frame.args.toistoja or "4"
assert(tonumber(repeats) .. "" == repeats, "Toisojen määrän pitää olla numbero")
local notes = frame.args.nuotit:gsub("¦", "|")
local notes_midi = notes
if frame.args.midinuotit and frame.args.midinuotit ~= "" then
notes_midi = frame.args.midinuotit:gsub("¦", "|")
end
if not mw.ustring.match(time_signature, "^%d+/%d$") then
error("Virheellinen tahtilaji: " .. time_signature)
end
if not mw.ustring.match(tempo, "^%d+$") then
error("Virheellinen tempo: " .. tempo)
end
local score = tekstipohja.korvaaMuuttujat(scoreText_template, {
["TAHTILAJI"] = time_signature,
["TEMPO"] = tempo,
["NUOTIT_NUOTTIKUVA"] = notes,
["NUOTIT_MIDI"] = notes_midi,
["TOISTOJA"] = repeats })
local args = { raw = "1", sound = "1" }
local pref = ""
if swing then
pref = "[[Kuva:Swing-marking.svg]]\n"
end
if nowiki then
return "<pre>" .. pref .. score .. "</pre>"
else
return pref .. frame:extensionTag{ name = "score", content = score, args = args }
end
end
return p