App-Music-ChordPro
view release on metacpan or search on metacpan
lib/ChordPro/res/abc/abc2svg/grid-1.js view on Meta::CPAN
case C.NOTE:
case C.REST:
case C.SPACE:
if (!s.a_gch || chord[beat_i])
break
bt = cs_filter(s.a_gch)
if (!bt)
break
w = abc.strwh(bt.replace(
/<[^>]+>/gm,''))
if (w[0] > wmx)
wmx = w[0]
bt = new String(bt)
bt.wh = w
chord[beat_i] = bt
break
case C.BAR:
i = s.bar_num // check if normal measure bar
bt = s.bar_type
while (s.ts_next && s.ts_next.time == s.time) {
if (s.ts_next.dur
|| s.ts_next.type == C.SPACE)
break
s = s.ts_next
if (s.type == C.METER) {
beat = get_beat(s)
wm = s.wmeasure
continue
}
if (s.type != C.BAR)
continue
if (s.bar_type[0] == ':'
&& bt[0] != ':')
bt = ':' + bt
if (s.bar_type.slice(-1) == ':'
&& bt.slice(-1) != ':')
bt += ':'
if (s.bar_num)
i = s.bar_num
if (s.part)
parts[chords.length + 1] = s.part.text
}
if (grid.norep)
bt = '|'
if (s.time < wm) { // if anacrusis
if (chord.length) {
chords.push(chord)
bars.push(bt)
} else {
bars[0] = bt
}
} else {
if (!i) // if not normal measure bar
break
chords.push(chord)
bars.push(bt)
}
if (chord.length)
some_chord++
chord = []
cur_beat = s.time // synchronize in case of error
beat_i = 0
if (bt.indexOf(':') >= 0)
rep = true // some repeat
break
case C.METER:
beat = get_beat(s)
wm = s.wmeasure
break
}
}
if (chord.length) {
bars.push('')
chords.push(chord)
}
if (!some_chord)
return // no chord in this tune
wmx += abc.strwh(rep ? ' ' : ' ')[0]
sb.chords = chords
sb.bars = bars
if (grid.parts && parts.length)
sb.parts = parts
sb.wmx = wmx
} // build_chords
// -------- set_stems --------
// create a specific block
if (grid) {
var C = abc2svg.C,
tsfirst = this.get_tsfirst(),
fmt = tsfirst.fmt,
voice_tb = this.get_voice_tb(),
p_v = voice_tb[this.get_top_v()],
s = {
type: C.BLOCK,
subtype: 'grid',
dur: 0,
time: 0,
p_v: p_v,
v: p_v.v,
st: p_v.st
}
if (!cfmt.gridfont)
abc.param_set_font("gridfont", "serif 16")
abc.set_font('grid')
build_chords(s) // build the array of the chords
// and insert it in the tune
if (!s.chords) { // if no chord
;
} else if (grid.nomusic) { // if just the grid
this.set_tsfirst(s)
} else if (grid.n < 0) { // below
for (var s2 = tsfirst; s2.ts_next; s2 = s2.ts_next)
;
s.time = s2.time
( run in 0.819 second using v1.01-cache-2.11-cpan-98e64b0badf )