App-Music-ChordPro
view release on metacpan or search on metacpan
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
case C.NOTE:
delta = staff_delta[st]
if (delta
&& !s.p_v.ckey.k_drum) {
for (m = s.nhd; m >= 0; m--) {
note = s.notes[m]
note.opit = note.pit
note.pit += delta
}
}
if (s.dur < dur)
dur = s.dur
break
}
}
if (!last_s)
smallest_duration = dur
}
/* -- set the stem direction when multi-voices -- */
/* this function is called only once per tune */
// (possible hook)
Abc.prototype.set_stem_dir = function() {
var t, u, i, st, rvoice, v,
v_st, // voice -> staff 1 & 2
st_v, vobj, // staff -> (v, ymx, ymn)*
v_st_tb, // array of v_st
st_v_tb = [], // array of st_v
s = tsfirst,
sy = cur_sy,
nst = sy.nstaff
while (s) {
for (st = 0; st <= nst; st++)
st_v_tb[st] = []
v_st_tb = []
/* get the max/min offsets in the delta time */
/*fixme: the stem height is not calculated yet*/
for (u = s; u; u = u.ts_next) {
if (u.type == C.BAR)
break;
if (u.type == C.STAVES) {
if (u != s)
break
sy = s.sy
for (st = nst; st <= sy.nstaff; st++)
st_v_tb[st] = []
nst = sy.nstaff
continue
}
if ((u.type != C.NOTE && u.type != C.REST)
|| u.invis)
continue
st = u.st;
/*fixme:test*/
if (st > nst) {
var msg = "*** fatal set_stem_dir(): bad staff number " + st +
" max " + nst;
error(2, null, msg);
throw new Error(msg)
}
v = u.v;
v_st = v_st_tb[v]
if (!v_st) {
v_st = {
st1: -1,
st2: -1
}
v_st_tb[v] = v_st
}
if (v_st.st1 < 0) {
v_st.st1 = st
} else if (v_st.st1 != st) {
if (st > v_st.st1) {
if (st > v_st.st2)
v_st.st2 = st
} else {
if (v_st.st1 > v_st.st2)
v_st.st2 = v_st.st1;
v_st.st1 = st
}
}
st_v = st_v_tb[st];
rvoice = sy.voices[v].range;
for (i = st_v.length; --i >= 0; ) {
vobj = st_v[i]
if (vobj.v == rvoice)
break
}
if (i < 0) {
vobj = {
v: rvoice,
ymx: 0,
ymn: 24
}
for (i = 0; i < st_v.length; i++) {
if (rvoice < st_v[i].v) {
st_v.splice(i, 0, vobj)
break
}
}
if (i == st_v.length)
st_v.push(vobj)
}
if (u.type != C.NOTE)
continue
if (u.ymx > vobj.ymx)
vobj.ymx = u.ymx
if (u.ymn < vobj.ymn)
vobj.ymn = u.ymn
if (u.xstem) {
if (u.ts_prev.st != st - 1
|| u.ts_prev.type != C.NOTE) {
error(1, s, "Bad !xstem!");
u.xstem = false
/*fixme:nflags KO*/
} else {
u.ts_prev.multi = 1;
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
mf: {x:-8, y:0, c:"\ue52d"},
ff: {x:-7, y:0, c:"\ue52f"},
fff: {x:-10, y:0, c:"\ue530"},
ffff: {x:-14, y:0, c:"\ue531"},
sfz: {x:-10, y:0, c:"\ue539"},
trl: {x:-3, y:-3, c:"\ue566"}, // trill
turn: {x:-5, y:0, c:"\ue567"},
turnx: {x:-5, y:0, c:"\ue569"},
umrd: {x:-6, y:2, c:"\ue56c"},
lmrd: {x:-6, y:2, c:"\ue56d"},
dplus: {x:-3, y:0, c:"\ue582"}, // plus
sld: {x:-3, y:2, c:"\ue5d0"}, // slide
grm: {x:-3, y:-2, c:"\ue5e2"}, // grace mark
dnb: {x:-3, y:0, c:"\ue610"}, // down bow
upb: {x:-2, y:0, c:"\ue612"}, // up bow
opend: {x:-2, y:-2, c:"\ue614"}, // harmonic
roll: {x:0, y:0, c:"\ue618"},
thumb: {x:-2, y:-2, c:"\ue624"},
snap: {x:-2, y:-2, c:"\ue630"},
ped: {x:-10, y:0, c:"\ue650"},
pedoff: {x:-5, y:0, c:"\ue655"},
"mtro.": {x:0, y:0, c:"\ue910"}, // tempus perfectum prolatione perfecta
mtro: {x:0, y:0, c:"\ue911"}, // tempus perfectum
"mtro|": {x:0, y:0, c:"\ue912"}, // tempus perfectum (twice as fast)
"mtrc.": {x:0, y:0, c:"\ue914"}, // tempus imperfectum prolatione perfecta
mtrc: {x:0, y:0, c:"\ue915"}, // tempus imperfectum
"mtrc|": {x:0, y:0, c:"\ue918"}, // tempus imperfectum (twice as fast)
longa: {x:-4.7, y:0, c:"\ue95d"},
custos: {x:-4, y:3, c:"\uea02"},
ltr: {x:2, y:6, c:"\ueaa4"} // long trill element
}
// glyphs to put in <defs>
var glyphs = {
}
// convert a meter string to a SmuFL encoded string
function m_gl(s) {
return s.replace(/./g,
function(e) {
var m = tgls["mtr" + e]
//fixme: !! no m.x nor m.y yet !!
// if (!m.x && !m.y)
return m ? m.c : 0
// return '<tspan dx="'+ m.x.toFixed(1) +
// '" dy="' + m.y.toFixed(1) +
// '">' +
// m.c + '</tspan>'
})
}
// mark a glyph as used and add it in <defs>
function def_use(gl) {
var i, j, g
if (defined_glyph[gl])
return
defined_glyph[gl] = true;
g = glyphs[gl]
if (!g) {
//throw new Error("unknown glyph: " + gl)
error(1, null, "Unknown glyph: '$1'", gl)
return // fixme: the xlink is set
}
j = 0
while (1) {
i = g.indexOf('xlink:href="#', j)
if (i < 0)
break
i += 13;
j = g.indexOf('"', i);
def_use(g.slice(i, j))
}
defs += '\n' + g
}
// add user defs from %%beginsvg
function defs_add(text) {
var i, j, gl, tag, is,
ie = 0
// remove XML comments
text = text.replace(/<!--.*?-->/g, '')
while (1) {
is = text.indexOf('<', ie);
if (is < 0)
break
i = text.indexOf('id="', is)
if (i < 0)
break
i += 4;
j = text.indexOf('"', i);
if (j < 0)
break
gl = text.slice(i, j);
ie = text.indexOf('>', j);
if (ie < 0)
break
if (text[ie - 1] == '/') {
ie++
} else {
i = text.indexOf(' ', is);
if (i < 0)
break
tag = text.slice(is + 1, i);
ie = text.indexOf('</' + tag + '>', ie)
if (ie < 0)
break
ie += 3 + tag.length
}
if (text.substr(is, 7) == '<filter')
fulldefs += text.slice(is, ie) + '\n'
else
glyphs[gl] = text.slice(is, ie)
}
}
// output the stop/start of a graphic sequence
function set_g() {
( run in 1.522 second using v1.01-cache-2.11-cpan-97f6503c9c8 )