abc2svg
Check-in [2c336cdff0]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:core: fix: bad start of music line when voice overlay starting with space or grace notes
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2c336cdff0a6673f052fcd2fb1e4243ba5555834
User & Date: jef 2022-05-07 14:12:39.677
References
2022-05-08
06:11
core: fix: crash when command/parameter at start of tune since commit [2c336cdff0] - reported by Stuart Soloway ... (check-in: 0b33b10279 user: jef tags: trunk)
Context
2022-05-07
17:07
core: fix: crash on tuplets of rests - reported by Frédéric Boulanger ... (check-in: e541a7f522 user: jef tags: trunk)
14:12
core: fix: bad start of music line when voice overlay starting with space or grace notes ... (check-in: 2c336cdff0 user: jef tags: trunk)
13:14
modules: equalbars: fix: crash when |] at EOL and |: with voice overlay in the next line - reported by William Obermeyer ... (check-in: 5b2d1cf37e user: jef tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to core/abc2svg.js.
1
2
3
4
5
6
7
8
9
10
// abc2svg - abc2svg.js
//
// Copyright (C) 2014-2021 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
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.


|







1
2
3
4
5
6
7
8
9
10
// abc2svg - abc2svg.js
//
// 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
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
25
26
27
28
29
30
31

32
33
34
35
36
37
38
abc2svg.C = {
	BLEN: 1536,

	// symbol types
	BAR: 0,
	CLEF: 1,
	CUSTOS: 2,

	GRACE: 4,
	KEY: 5,
	METER: 6,
	MREST: 7,
	NOTE: 8,
	PART: 9,
	REST: 10,







>







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
abc2svg.C = {
	BLEN: 1536,

	// symbol types
	BAR: 0,
	CLEF: 1,
	CUSTOS: 2,
	SM: 3,		// sequence marker (transient)
	GRACE: 4,
	KEY: 5,
	METER: 6,
	MREST: 7,
	NOTE: 8,
	PART: 9,
	REST: 10,
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
	SL_ALI_MSK: 0x70,	// align
		SL_ALIGN: 0x10,
		SL_CENTER: 0x20,
		SL_CLOSE: 0x40
    };

// !! tied to the symbol types in abc2svg.js !!
abc2svg.sym_name = ['bar', 'clef', 'custos', '', 'grace',
		'key', 'meter', 'Zrest', 'note', 'part',
		'rest', 'yspace', 'staves', 'Break', 'tempo',
		'', 'block', 'remark']

	// key table - index = number of accidentals + 7
abc2svg.keys = [
	new Int8Array([-1,-1,-1,-1,-1,-1,-1 ]),	// 7 flat signs







|







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
	SL_ALI_MSK: 0x70,	// align
		SL_ALIGN: 0x10,
		SL_CENTER: 0x20,
		SL_CLOSE: 0x40
    };

// !! tied to the symbol types in abc2svg.js !!
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
abc2svg.keys = [
	new Int8Array([-1,-1,-1,-1,-1,-1,-1 ]),	// 7 flat signs
Changes to core/parse.js.
1435
1436
1437
1438
1439
1440
1441




1442
1443
1444
1445
1446
1447
1448
		curvoice.lyric_restart = s
	if (!curvoice.sym_restart)
		curvoice.sym_restart = s

	sym_link(s);

	s.st = curvoice.st			/* original staff */





	/* if repeat bar and shift, add a repeat bar */
	if (s.rbstart
	 && bar_type != "["
	 && !curvoice.norepbra
	 && s.st > 0
	 && !(par_sy.staves[s.st - 1].flags & STOP_BAR)) {







>
>
>
>







1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
		curvoice.lyric_restart = s
	if (!curvoice.sym_restart)
		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
	 && s.st > 0
	 && !(par_sy.staves[s.st - 1].flags & STOP_BAR)) {
Changes to core/tune.js.
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
	}
	return s
}

/* -- sort all symbols by time and vertical sequence -- */
// weight of the symbols !! depends on the symbol type !!
var w_tb = new Uint8Array([
	5,	// bar
	1,	// clef
	8,	// custos
	0,	// (free)
	0,	// grace
	2,	// key
	3,	// meter
	9,	// mrest
	9,	// note
	0,	// part
	9,	// rest
	4,	// space
	0,	// staves
	7,	// stbrk
	0,	// tempo
	0,	// (free)
	0,	// block
	0	// remark
])







|


|







|







115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
	}
	return s
}

/* -- sort all symbols by time and vertical sequence -- */
// weight of the symbols !! depends on the symbol type !!
var w_tb = new Uint8Array([
	4,	// bar
	1,	// clef
	8,	// custos
	5,	// sm (sequence marker)
	0,	// grace
	2,	// key
	3,	// meter
	9,	// mrest
	9,	// note
	0,	// part
	9,	// rest
	6,	// space (after bar)
	0,	// staves
	7,	// stbrk
	0,	// tempo
	0,	// (free)
	0,	// block
	0	// remark
])
241
242
243
244
245
246
247
248
249









250
251
252
253
254
255
256
			v = vn[ir++]
			if (v == undefined)
				break
			s = vtb[v]
			if (!s || s.time != time
			 || w_tb[s.type] != wmin)
				continue
			if (s.type == C.STAVES)
				new_sy = s.sy









			if (fl) {
				fl = 0;
				s.seqst = true
			}
			s.ts_prev = prev
			prev.ts_next = s
			prev = s







|

>
>
>
>
>
>
>
>
>







241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
			v = vn[ir++]
			if (v == undefined)
				break
			s = vtb[v]
			if (!s || s.time != time
			 || w_tb[s.type] != wmin)
				continue
			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
			prev.ts_next = s
			prev = s
347
348
349
350
351
352
353






















354
355
356
357
358
359
360
			}
		} // not %%score
		for (s = p_voice.sym; s; s = s.next) {
			if (s.time >= staves_found)
				break
		}
		for ( ; s; s = s.next) {






















			switch (s.type) {
			case C.GRACE:
				if (!cfmt.graceword)
					continue
				for (s2 = s.next; s2; s2 = s2.next) {
					switch (s2.type) {
					case C.SPACE:







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
			}
		} // not %%score
		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) {
					switch (s2.type) {
					case C.SPACE:
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
			syntax(1, "Wrong duration in voice overlay")
			if (curvoice.time > vover.p_voice.time)
				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

	if (!curvoice.last_sym)







<
<
<
<
<
<
<
<
<
<
<
<







1835
1836
1837
1838
1839
1840
1841












1842
1843
1844
1845
1846
1847
1848
			syntax(1, "Wrong duration in voice overlay")
			if (curvoice.time > vover.p_voice.time)
				vover.p_voice.time = curvoice.time
		}
	}
	p_voice2.time = vover.time;
	curvoice = p_voice2












}

// check if a clef, key or time signature may go at start of the current voice
function is_voice_sig() {
	var s

	if (!curvoice.last_sym)