Index: core/abc2svg.js ================================================================== --- core/abc2svg.js +++ core/abc2svg.js @@ -1,8 +1,8 @@ // abc2svg - abc2svg.js // -// Copyright (C) 2014-2021 Jean-Francois Moine +// Copyright (C) 2014-2022 Jean-Francois Moine // // This file is part of abc2svg-core. // // abc2svg-core is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by @@ -27,10 +27,11 @@ // symbol types BAR: 0, CLEF: 1, CUSTOS: 2, + SM: 3, // sequence marker (transient) GRACE: 4, KEY: 5, METER: 6, MREST: 7, NOTE: 8, @@ -61,11 +62,11 @@ SL_CENTER: 0x20, SL_CLOSE: 0x40 }; // !! tied to the symbol types in abc2svg.js !! -abc2svg.sym_name = ['bar', 'clef', 'custos', '', 'grace', +abc2svg.sym_name = ['bar', 'clef', 'custos', 'smark', 'grace', 'key', 'meter', 'Zrest', 'note', 'part', 'rest', 'yspace', 'staves', 'Break', 'tempo', '', 'block', 'remark'] // key table - index = number of accidentals + 7 Index: core/parse.js ================================================================== --- core/parse.js +++ core/parse.js @@ -1437,10 +1437,14 @@ curvoice.sym_restart = s sym_link(s); s.st = curvoice.st /* original staff */ + + // if space before the bar, update its time (see w_tb[]) + if (s.prev && s.prev.type == C.SPACE) + s.prev.time-- /* if repeat bar and shift, add a repeat bar */ if (s.rbstart && bar_type != "[" && !curvoice.norepbra Index: core/tune.js ================================================================== --- core/tune.js +++ core/tune.js @@ -117,22 +117,22 @@ } /* -- sort all symbols by time and vertical sequence -- */ // weight of the symbols !! depends on the symbol type !! var w_tb = new Uint8Array([ - 5, // bar + 4, // bar 1, // clef 8, // custos - 0, // (free) + 5, // sm (sequence marker) 0, // grace 2, // key 3, // meter 9, // mrest 9, // note 0, // part 9, // rest - 4, // space + 6, // space (after bar) 0, // staves 7, // stbrk 0, // tempo 0, // (free) 0, // block @@ -243,12 +243,21 @@ break s = vtb[v] if (!s || s.time != time || w_tb[s.type] != wmin) continue - if (s.type == C.STAVES) + if (s.type == C.STAVES) { new_sy = s.sy + } else if (s.type == C.SM) { // if a sequence marker + s.next.prev = s.prev // remove it + if (s.prev) + s.prev.next = s.next + else + s.p_v.sym = s.next + vtb[v] = s.next + continue + } if (fl) { fl = 0; s.seqst = true } s.ts_prev = prev @@ -349,10 +358,32 @@ for (s = p_voice.sym; s; s = s.next) { if (s.time >= staves_found) break } for ( ; s; s = s.next) { + + // if the symbol has no sequence weight + // and if there a time skip, + // add a sequence marker before it + if (!w_tb[s.type] + && (!s.prev || s.time > s.prev.time + s.prev.dur)) { + s2 = { + type: C.SM, + v: s.v, + p_v: s.p_v, + time: s.time, + dur:0, + next: s, + prev: s.prev + } + if (s.prev) + s.prev.next = s2 + else + voice_tb[s.v].sym = s2 + s.prev = s2 + } + switch (s.type) { case C.GRACE: if (!cfmt.graceword) continue for (s2 = s.next; s2; s2 = s2.next) { @@ -1806,22 +1837,10 @@ vover.p_voice.time = curvoice.time } } p_voice2.time = vover.time; curvoice = p_voice2 - - // add a bar at start of the measure overlay - // (needed for sort_all() in case of spaces - 'y') - if (vover.bar && vover.time) { - sym_link({ - type: C.BAR, - bar_type: vover.bar, - invis: 1, - dur: 0, - multi: 0 - }) - } } // check if a clef, key or time signature may go at start of the current voice function is_voice_sig() { var s