view release on metacpan or search on metacpan
lib/ChordPro/res/abc/abc2svg/MIDI-1.js view on Meta::CPAN
break
case "chordprog": // %%MIDI chordprog <#MIDI program> [octave=<n>]
if (!cfmt.chord)
cfmt.chord = {}
cfmt.chord.prog = a[2]
if (a[3] && a[3].slice(0, 7) == "octave=")
cfmt.chord.trans = Number(a[3].slice(7))
break
case "chordvol": // %%MIDI chordvol <volume>
v = Number(a[2])
if (isNaN(v) || v < 0 || v > 127) {
abc.syntax(1, abc.errs.bad_val, "%%MIDI chordvol")
break
}
if (!cfmt.chord)
cfmt.chord = {}
cfmt.chord.vol = v / 127
break
// case "drone": // %%MIDI drone <#prog> <pit_1> <pit_2> <vol_1> <vol_2>
// // default: 70 45 33 80 80
// break
lib/ChordPro/res/abc/abc2svg/MIDI-1.js view on Meta::CPAN
&& curvoice) {
s = abc.new_block("midigch")
s.play = s.invis = 1 //true
s.on = a[1][7] == 'n'
} else {
cfmt.chord.gchon = a[1][7] == 'n'
}
break
case "channel":
v = parseInt(a[2])
if (isNaN(v) || v <= 0 || v > 16) {
abc.syntax(1, abc.errs.bad_val, "%%MIDI channel")
break
}
v-- // channel range 1..16 => 0..15
if (abc.parse.state == 3) {
s = abc.new_block("midiprog")
s.play = s.invis = 1 //true
s.chn = v
} else {
abc.set_v_param("channel", v)
}
break
case "drummap":
//fixme: should have a 'MIDIdrum' per voice?
v = Number(a[3])
if (isNaN(v)) {
abc.syntax(1, abc.errs.bad_val, "%%MIDI drummap")
break
}
n = ["C","^C","D","_E","E","F","^F","G","^G","A","_B","B"][v % 12]
while (v < 60) {
n += ','
v += 12
}
while (v > 72) {
n += "'"
lib/ChordPro/res/abc/abc2svg/MIDI-1.js view on Meta::CPAN
case "program":
a.shift()
v = []
if (a[2]) {
v[0] = +a[2] // program
v[1] = +a[1] // channel
} else {
v[0] = +a[1]
v[1] = 0
}
if (isNaN(v[0]) || v[0] < 0 || v[0] > 127
|| (v[1]
&& (isNaN(v[1]) || v[1] <= 0 || v[1] > 16))) {
abc.syntax(1, abc.errs.bad_val, "%%MIDI program")
break
}
if (abc.parse.state == 3) {
s = abc.new_block("midiprog");
s.play = s.invis = 1 //true
s.instr = v[0]
s.chn = v[1] > 0
? (v[1] - 1)
: curvoice.v < 9 ? curvoice.v : curvoice.v + 1
} else {
abc.set_v_param("instr", a.slice(1).join(' '))
}
break
case "control":
n = parseInt(a[2])
if (isNaN(n) || n < 0 || n > 127) {
abc.syntax(1, "Bad controller number in %%MIDI")
break
}
v = parseInt(a[3])
if (isNaN(v) || v < 0 || v > 127) {
abc.syntax(1, "Bad controller value in %%MIDI")
break
}
if (abc.parse.state == 3) {
s = abc.new_block("midictl");
s.play = s.invis = 1 //true
s.ctrl = n;
s.val = v
} else {
abc.set_v_param("midictl", a[2] + ' ' + a[3])
}
break
case "temperamentequal":
n = parseInt(a[2])
if (isNaN(n) || n < 5 || n > 255) {
abc.syntax(1, abc.errs.bad_val, "%%MIDI " + a[1])
return
}
// define the Turkish accidentals (53-TET)
if (n == 53) {
s = abc.get_glyphs()
// #1
s.acc12_53 = '<text id="acc12_53" x="-1"></text>'
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
if (!a) {
error(1, null, "Invalid decoration '$1'", nm)
return //undefined
}
var c_func = Number(a[1]),
// glyph = a[2],
h = a[3],
wl = parseFloat(a[4]),
wr = parseFloat(a[5])
if (isNaN(c_func)) {
error(1, null, "%%deco: bad C function value '$1'", a[1])
return //undefined
}
if (c_func > 10
&& (c_func < 32 || c_func > 45)) {
error(1, null, "%%deco: bad C function index '$1'", c_func)
return //undefined
}
// if (c_func == 5) // old !trill(!
// c_func = 3
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
// %%font <font> [<encoding>] [<scale>]
function get_font_scale(param) {
var i, font,
a = info_split(param) // a[0] = font name
if (a.length <= 1)
return
var scale = +a[a.length - 1]
if (isNaN(scale) || scale <= 0.5) {
syntax(1, "Bad scale value in %%font")
return
}
font_scale_tb[a[0]] = scale
}
// set the width factor of a font
function set_font_fac(font) {
var scale = font_scale_tb[font.fname || font.name]
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
if (font.weight >= 700)
font.fname += 'Bold'
cfmt[xxxfont] = font
}
// get a length with a unit - return the number of pixels
function get_unit(param) {
var v = param.toLowerCase().match(/(-?[\d.]+)(.*)/)
if (!v)
return NaN
v[1] = +v[1]
switch (v[2]) {
case "cm":
return v[1] * CM
case "in":
return v[1] * IN
case "pt": // paper point in 1/72 inch
return v[1] / .75
case "px": // screen pixel in 1/96 inch
case "":
return v[1]
}
return NaN
}
// set the infoname
function set_infoname(param) {
//fixme: check syntax: '<letter> ["string"]'
var tmp = cfmt.infoname.split("\n"),
letter = param[0]
for (var i = 0; i < tmp.length; i++) {
var infoname = tmp[i]
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
case "barsperstaff":
case "infoline":
case "measurenb":
case "rbmax":
case "rbmin":
case "measrepnb":
case "shiftunison":
case "systnames":
case "systvoices":
v = parseInt(param)
if (isNaN(v)) {
syntax(1, "Bad integer value");
break
}
if (cmd == "systnames") { // compatibility
switch (v) {
case -1: v = 3; break
case 1: v = 2; break
case 2: v = 1; break
}
cmd = "systvoices"
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
case "breaklimit": // float values
case "lineskipfac":
case "maxshrink":
case "pagescale":
case "parskipfac":
case "scale":
case "slurheight":
case "stemheight":
case "tieheight":
f = +param
if (isNaN(f) || !param || f < 0) {
syntax(1, errs.bad_val, '%%' + cmd)
break
}
switch (cmd) {
case "scale": // old scale
f /= .75
case "pagescale":
if (f < .1)
f = .1 // smallest scale
cmd = "scale";
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
case "partsspace":
case "staffsep":
case "subtitlespace":
case "sysstaffsep":
case "textspace":
case "titlespace":
case "topspace":
case "vocalspace":
case "wordsspace":
f = get_unit(param) // normally, unit in points - 72 DPI accepted
if (isNaN(f) || f < 0)
syntax(1, errs.bad_val, '%%' + cmd)
else
cfmt[cmd] = f
break
case "page-format":
user.page_format = get_bool(param)
break
case "print-leftmargin": // to remove
syntax(0, "$1 is deprecated - use %%printmargin instead", '%%' + cmd)
cmd = "printmargin"
// fall thru
case "printmargin":
// case "botmargin":
case "leftmargin":
// case "pageheight":
case "pagewidth":
case "rightmargin":
// case "topmargin":
f = get_unit(param) // normally unit in cm or in - 96 DPI
if (isNaN(f)) {
syntax(1, errs.bad_val, '%%' + cmd)
break
}
cfmt[cmd] = f;
img.chg = true
break
case "concert-score":
if (cfmt.sound != "play")
cfmt.sound = "concert"
break
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
if (parse.state != 0) {
syntax(1, errs.not_in_tune, "%%fullsvg")
break
}
//fixme: should check only alpha, num and '_' characters
cfmt[cmd] = param
break
case "gracespace":
v = param.split(/\s+/)
for (i = 0; i < 3; i++)
if (isNaN(+v[i])) {
syntax(1, errs.bad_val, "%%gracespace")
break
}
if (parse.ufmt)
cfmt[cmd] = new Float32Array(3)
for (i = 0; i < 3; i++)
cfmt[cmd][i] = +v[i]
break
case "tuplets":
v = param.split(/\s+/)
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
else
cfmt[cmd] = v
break
case "infoname":
set_infoname(param)
break
case "notespacingfactor":
v = param.match(/([.\d]+)[,\s]*(\d+)?/)
if (v) {
f = +v[1]
if (isNaN(f) || f < 1 || f > 2) {
f = 0
} else if (v[2]) {
f2 = +v[2]
if (isNaN(f))
f = 0
} else {
f2 = cfmt.spatab[5]
}
}
if (!f) {
syntax(1, errs.bad_val, "%%" + cmd)
break
}
cfmt[cmd] = param // (for dump)
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
if (cmd[1].slice(0, 3) == "vol")
cmd[1] = "dyn" // compatibility
set_pos(cmd[1], cmd[2])
break
case "sounding-score":
if (cfmt.sound != "play")
cfmt.sound = "sounding"
break
case "staffwidth":
v = get_unit(param)
if (isNaN(v)) {
syntax(1, errs.bad_val, '%%' + cmd)
break
}
if (v < 100) {
syntax(1, "%%staffwidth too small")
break
}
v = cfmt.pagewidth - v - cfmt.leftmargin
if (v < 2) {
syntax(1, "%%staffwidth too big")
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
break
case "textoption":
cfmt[cmd] = get_textopt(param)
break
case "dynalign":
case "quiet":
case "singleline":
case "stretchlast":
case "titletrim":
v = param == '' ? 1 : +param
if (isNaN(v))
v = +get_bool(param)
if (cmd[1] == 't') { // stretchlast
if (v < 0 || v > 1) {
syntax(1, errs.bad_val, '%%' + cmd)
break
}
}
cfmt[cmd] = v
break
case "combinevoices":
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
break
c2 = oct_acc[src[i + 2]]
if (c2) {
dst += c2;
j = i + 3
continue
}
break
case 'u':
j = Number("0x" + src.slice(i + 1, i + 5));
if (isNaN(j) || j < 0x20) {
dst += src[++i] + "\u0306" // breve accent
j = i + 1
continue
}
c = String.fromCharCode(j)
if (c == '\\') {
i += 4
break
}
dst += c
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
if (/^[\]\[|.':-]+$/.test(param)) // '
return param.replace(/\]/g, '[')
var n = +param
switch (n) {
case 0: return "..."
case 1: return "..|"
case 2: return ".||"
case 3: return ".|||"
}
if (isNaN(n) || n < 0 || n > 16)
return //undefined
return "||||||||||||||||".slice(0, n)
}
// create a block symbol in the tune body
function new_block(subtype) {
var s = {
type: C.BLOCK,
subtype: subtype,
dur: 0
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
break
}
clefpit = 4 - val // 4 = 'G'
break
}
}
syntax(1, errs.bad_val, item)
break
case "octave=":
val = +a.shift()
if (isNaN(val))
syntax(1, errs.bad_val, item)
else
curvoice.octave = val
break
case "cue=":
curvoice.scale = a.shift() == 'on' ? .7 : 1
break
case "instrument=":
// instrument=M/N => score=MN and sound=cN
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
case "align": val |= C.SL_ALIGN; break
case "center": val |= C.SL_CENTER; break
case "close": val |= C.SL_CLOSE; break
}
if (!pos)
pos = {}
pos[item[0]] = val
break
case "scale=": // %%voicescale
val = +a.shift()
if (isNaN(val) || val < .5 || val > 2)
syntax(1, errs.bad_val, "%%voicescale")
else
curvoice.scale = val
break
case "score=":
if (cfmt.nedo) {
syntax(1, errs.notransp)
break
}
// score=MN
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
if (val == undefined) {
syntax(1, "Bad %%stafflines value")
break
}
if (curvoice.st != undefined)
par_sy.staves[curvoice.st].stafflines = val
curvoice.stafflines = val
break
case "staffnonote=":
val = +a.shift()
if (isNaN(val))
syntax(1, "Bad %%staffnonote value")
else
curvoice.staffnonote = val
break
case "staffscale=":
val = +a.shift()
if (isNaN(val) || val < .3 || val > 2)
syntax(1, "Bad %%staffscale value")
else
curvoice.staffscale = val
break
case "tacet=":
val = a.shift()
curvoice.tacet = val || undefined
break
case "transpose=": // (abcMIDI compatibility)
if (cfmt.nedo) {
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
dur: 0
}
// get a note duration
function get_nd(p) {
var n, d,
nd = p.match(/(\d+)\/(\d+)/)
if (nd) {
d = +nd[2]
if (d && !isNaN(d) && !(d & (d - 1))) {
n = +nd[1]
if (!isNaN(n))
return C.BLEN * n / d
}
}
syntax(1, "Invalid note duration $1", c)
} // get_nd()
set_ref(s)
if (cfmt.writefields.indexOf('Q') < 0)
s.invis = true // don't display
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
text = text.slice(4)
}
i = text.indexOf('/')
if (i > 0) {
nd = get_nd(text)
if (!nd)
return
s.new_beat = nd
} else {
s.tempo = +text
if (!s.tempo || isNaN(s.tempo)) {
syntax(1, "Bad tempo value")
return
}
}
}
if (parse.state < 2 // if in tune header
|| (!curvoice.time && !glovar.tempo)) {
info.Q = txt
glovar.tempo = s
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
// get a abcm2ps/abcMIDI compatible transposition value as a base-40 interval
// The value may be
// - [+|-]<number of semitones>[s|f]
// - <note1>[<note2>] % <note2> default is 'c'
function get_transp(param) {
if (param[0] == '0')
return 0
if ("123456789-+".indexOf(param[0]) >= 0) { // by semi-tone
var val = parseInt(param)
if (isNaN(val) || val < -36 || val > 36) {
//fixme: no source reference...
syntax(1, errs.bad_transp)
return
}
val += 36
val = ((val / 12 | 0) - 3) * 40 + abc2svg.isb40[val % 12]
if (param.slice(-1) == 'b')
val += 4
return val
}
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
case "linebreak":
set_linebreak(param)
return
case "map":
get_map(param)
return
case "maxsysstaffsep":
case "sysstaffsep":
if (parse.state == 3) {
val = get_unit(param)
if (isNaN(val)) {
syntax(1, errs.bad_val, "%%" + cmd)
return
}
par_sy.voices[curvoice.v][cmd[0] == 'm' ? "maxsep" : "sep"] =
val
return
}
break
case "multicol":
switch (param) {
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
sym_link(s)
return
}
set_ref(s)
self.block_gen(s)
return
case "ottava":
if (parse.state != 3)
return
n = parseInt(param)
if (isNaN(n) || n < -2 || n > 2
|| (!n && !curvoice.ottava)) {
syntax(1, errs.bad_val, "%%ottava")
return
}
k = n
if (n) {
curvoice.ottava = n
} else {
n = curvoice.ottava
curvoice.ottava = 0
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
syntax(1, "%%repeat cannot start a tune")
return
}
if (!param.length) {
n = 1;
k = 1
} else {
b = param.split(/\s+/);
n = parseInt(b[0]);
k = parseInt(b[1])
if (isNaN(n) || n < 1
|| (curvoice.last_sym.type == C.BAR
&& n > 2)) {
syntax(1, "Incorrect 1st value in %%repeat")
return
}
if (isNaN(k)) {
k = 1
} else {
if (k < 1) {
syntax(1, "Incorrect 2nd value in %%repeat")
return
}
}
}
parse.repeat_n = curvoice.last_sym.type == C.BAR ? n : -n;
parse.repeat_k = k
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
lwidth = img.width - img.lm - img.rm;
h1 = h2 = len = 0
if (param) {
values = param.split(/\s+/);
h1 = get_unit(values[0])
if (values[1]) {
h2 = get_unit(values[1])
if (values[2])
len = get_unit(values[2])
}
if (isNaN(h1) || isNaN(h2) || isNaN(len)) {
syntax(1, errs.bad_val, "%%sep")
return
}
}
if (h1 < 1)
h1 = 14
if (h2 < 1)
h2 = h1
if (len < 1)
len = 90
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
}
vskip(h1);
output += '<path class="stroke"\n\td="M';
out_sxsy((lwidth - len) / 2 / cfmt.scale, ' ', 0);
output += 'h' + (len / cfmt.scale).toFixed(1) + '"/>\n';
vskip(h2);
blk_flush()
return
case "setbarnb":
val = parseInt(param)
if (isNaN(val) || val < 1) {
syntax(1, "Bad %%setbarnb value")
break
}
glovar.new_nbar = val
return
case "staff":
if (parse.state != 3)
return
val = parseInt(param)
if (isNaN(val)) {
syntax(1, "Bad %%staff value '$1'", param)
return
}
var st
if (param[0] == '+' || param[0] == '-')
st = curvoice.cst + val
else
st = val - 1
if (st < 0 || st > nstaff) {
syntax(1, "Bad %%staff number $1 (cur $2, max $3)",
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
s = {
type: C.STBRK,
dur:0
}
if (param.slice(-1) == 'f') {
s.stbrk_forced = true
param = param.replace(/\sf$/, '')
}
if (param) {
val = get_unit(param)
if (isNaN(val)) {
syntax(1, errs.bad_val, "%%staffbreak")
return
}
s.xmx = val
} else {
s.xmx = 14
}
sym_link(s)
return
case "tacet":
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
return
case "user":
set_user(param)
return
case "voicecolor":
if (curvoice)
curvoice.color = param
return
case "vskip":
val = get_unit(param)
if (isNaN(val)) {
syntax(1, errs.bad_val, "%%vskip")
return
}
if (val < 0) {
syntax(1, "%%vskip cannot be negative")
return
}
if (parse.state >= 2) {
s = new_block(cmd);
s.sk = val
lib/ChordPro/res/abc/abc2svg/capo-1.js view on Meta::CPAN
},
// get the parameters of the current voice
set_vp: function(of, a) {
var i, v,
p_v = this.get_curvoice()
for (i = 0; i < a.length; i++) {
if (a[i] == "capo_=") {
v = Number(a[++i])
if (isNaN(v) || v <= 0)
this.syntax(1, "Bad fret number in %%capo")
else
p_v.capo = v
break
}
}
of(a)
}, // set_vp()
set_hooks: function(abc) {
lib/ChordPro/res/abc/abc2svg/grid-1.js view on Meta::CPAN
}
of()
}, // set_stems()
set_fmt: function(of, cmd, parm) {
if (cmd == "grid") {
if (!parm)
parm = "1";
parm = parm.split(/\s+/)
var grid = {n: Number(parm.shift())}
if (isNaN(grid.n)) {
if (parm.length) {
this.syntax(1, this.errs.bad_val, "%%grid")
return
}
grid.n = 1
}
while (parm.length) {
var item = parm.shift()
if (item == "norepeat")
grid.norep = true
lib/ChordPro/res/abc/abc2svg/nns-1.js view on Meta::CPAN
}, // set_stems()
set_fmt: function(of, cmd, parm) {
if (cmd == "nns") {
if (!parm)
parm = "1"
parm = parm.split(/\s+/)
var nns = {
n: Number(parm.shift())
}
if (isNaN(nns.n)) {
if (parm.length) {
this.syntax(1, this.errs.bad_val, "%%nns")
return
}
nns.n = 1
}
while (parm.length) {
var item = parm.shift()
if (item == "nomusic")
nns.nomusic = true
lib/ChordPro/res/abc/abc2svg/page-1.js view on Meta::CPAN
}, // img_in()
// handle the page related parameters
set_fmt: function(of, cmd, parm) {
var v,
cfmt = this.cfmt(),
page = this.page
if (cmd == "pageheight") {
v = this.get_unit(parm)
if (isNaN(v)) {
this.syntax(1, this.errs.bad_val, '%%' + cmd)
return
}
if (!user.img_out || !abc2svg.abc_end)
v = 0
cfmt.pageheight = v
if (!v) {
if (abc2svg.page.user_out) {
user.img_out = abc2svg.page.user_out
abc2svg.page.user_out = null
lib/ChordPro/res/abc/abc2svg/page-1.js view on Meta::CPAN
cfmt.header2 = null
}
if (cfmt.footer2) {
page.footer2 = cfmt.footer2
cfmt.footer2 = null
}
// get the previously defined page parameters
if (cfmt.botmargin != undefined) {
v = this.get_unit(cfmt.botmargin)
if (!isNaN(v))
page.botmargin = v
}
if (cfmt.topmargin != undefined) {
v = this.get_unit(cfmt.topmargin)
if (!isNaN(v))
page.topmargin = v
}
if (cfmt.gutter != undefined) {
v = this.get_unit(cfmt.gutter)
if (!isNaN(v))
page.gutter = v
}
if (cfmt.oneperpage)
page.oneperpage = this.get_bool(cfmt.oneperpage)
if (!cfmt.dateformat)
cfmt.dateformat = "%b %e, %Y %H:%M"
// set the hooks
if (!abc2svg.page.user_out)
abc2svg.page.user_out = user.img_out
lib/ChordPro/res/abc/abc2svg/page-1.js view on Meta::CPAN
case "footer":
case "header1":
case "header2":
case "footer2":
page[cmd] = parm
return
case "newpage":
if (!parm)
break
v = Number(parm)
if (isNaN(v)) {
this.syntax(1, this.errs.bad_val, '%%' + cmd)
return
}
page.pn = v - 1
return
case "gutter":
case "botmargin":
case "topmargin":
v = this.get_unit(parm)
if (isNaN(v)) {
this.syntax(1, this.errs.bad_val, '%%' + cmd)
return
}
page[cmd] = v
return
case "oneperpage":
page[cmd] = this.get_bool(parm)
return
}
}
lib/ChordPro/res/abc/abc2svg/perc-1.js view on Meta::CPAN
// convert a drum instrument to a ABC note
function toabc(p) {
var i, j, s, pit
if (/^[_^]*[A-Ga-g][,']*$/.test(p)) // '
return p // ABC note
// if not a MIDI pitch, try a drum instrument name
pit = Number(p)
if (isNaN(pit)) {
p = p.toLowerCase(p);
s = p[0]; // get the 1st letters after '-'
i = 0
while (1) {
j = p.indexOf('-', i)
if (j < 0)
break
i = j + 1;
s += '-' + p[i]
}
lib/ChordPro/res/abc/abc2svg/roman-1.js view on Meta::CPAN
}, // o_mus()
set_fmt: function(of, cmd, parm) {
var ty,
cfmt = this.cfmt()
if (cmd == "roman") {
if (!parm)
parm = "1"
ty = Number(parm)
if (isNaN(ty))
this.syntax(1, this.errs.bad_val, "%%roman")
else
cfmt.roman = ty
return
}
of(cmd, parm)
}, // set_fmt()
set_hooks: function(abc) {
abc.gch_build = abc2svg.roman.gch_build.bind(abc, abc.gch_build)
lib/ChordPro/res/abc/abc2svg/soloffs-1.js view on Meta::CPAN
set_fmt: function(of, cmd, parm) {
if (cmd == "soloffs") {
var i, v,
C = abc2svg.C,
soloffs = this.cfmt().soloffs = {}
parm = parm.split(/\s+/)
while (parm.length) {
i = parm.shift().split('=')
v = Number(i[1])
if (isNaN(v))
continue // error
switch (i[0]) {
// case 'bar':
// soloffs[C.BAR] = v
// break
case 'part':
soloffs[C.PART] = v // see deco.js
break
case 'tempo':
soloffs[C.TEMPO] = v + 16 // see deco.js
lib/ChordPro/res/abc/abc2svg/sth-1.js view on Meta::CPAN
if (h == '*')
continue // no change
if (h == '|') { // skip to the next measure bar
for (s = s.next; s; s = s.next) {
if (s.bar_type)
break
}
continue
}
h = Number(h)
if (isNaN(h) || !h)
continue // fixme: error
if (s.stem >= 0) {
s.ys = s.y + h;
s.ymx = (s.ys + 2.5) | 0
} else {
s.ys = s.y - h;
s.ymn = (s.ys - 2.5) | 0
}
s.sth = s.ys
}
lib/ChordPro/res/abc/abc2svg/strtab-1.js view on Meta::CPAN
var str, p, o,
t = []
if (p_v.diafret) {
while (1) {
str = a.shift()
if (!str)
break
p = "CDEFGAB".indexOf(str[0])
o = Number(str[1])
if (p < 0 || isNaN(o))
return // null
t.push(o * 7 + p - 12) // C4 = 16 (12 = 4 * 7 - 16)
}
} else {
while (1) {
str = a.shift()
if (!str)
break
p = "CCDDEFFGGAAB".indexOf(str[0])
if (p < 0)
lib/ChordPro/res/abc/abc2svg/strtab-1.js view on Meta::CPAN
switch (o) {
case '#':
case 'b':
p += o == '#' ? 1 : -1
o = Number(str[2])
break
default:
o = Number(str[1])
break
}
if (isNaN(o))
return // undefined
t.push((o + 1) * 12 + p) // C4 = 60
}
}
return t
} // str2tab()
// convert the list of <string number> ':' <fret number>
function minfret(a) {
var sf,
lib/ChordPro/res/abc/abc2svg/temper-1.js view on Meta::CPAN
abc2svg.temper = {
// get the temperament
set_fmt: function(of, cmd, param) {
if (cmd == "temperament") {
var i, tb,
tb40 = new Float32Array(40),
ls = new Float32Array(param.split(/ +/))
for (i = 0; i < ls.length; i++) {
if (isNaN(ls[i]))
break
ls[i] = i + ls[i] / 100 // delta -> MIDI/octave
}
switch (i) {
case 12:
tb = [ 10,11,0,1,2,0, // C
0,1,2,3,4,0, // D
2,3,4,5,6, // E
3,4,5,6,7,0, // F
5,6,7,8,9,0, // G