| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
if (typeof abc2svg == "undefined") |
| 26 |
var abc2svg = {} |
| 27 |
|
| 28 |
abc2svg.ambitus = { |
| 29 |
do_ambitus: function() { |
| 30 |
var C = abc2svg.C, |
| 31 |
s, v, p_v, min, max, |
| 32 |
voice_tb = this.get_voice_tb() |
| 33 |
|
| 34 |
for (v = 0; v < voice_tb.length; v++) { |
| 35 |
p_v = voice_tb[v]; |
| 36 |
if (p_v.second) |
| 37 |
continue |
| 38 |
min = 100; |
| 39 |
max = -100 |
| 40 |
|
| 41 |
|
| 42 |
for (s = p_v.sym; s; s = s.next) { |
| 43 |
if (s.type != C.NOTE) |
| 44 |
continue |
| 45 |
if (s.notes[s.nhd].pit > max) |
| 46 |
max = s.notes[s.nhd].pit |
| 47 |
if (s.notes[0].pit < min) |
| 48 |
min = s.notes[0].pit |
| 49 |
} |
| 50 |
if (min == 100) |
| 51 |
continue |
| 52 |
|
| 53 |
s = p_v.clef; |
| 54 |
s.stem = 1; |
| 55 |
s.head = C.FULL; |
| 56 |
s.stemless = true; |
| 57 |
s.nhd = 1; |
| 58 |
s.notes = [{ |
| 59 |
dur: C.BLEN / 4, |
| 60 |
pit: min, |
| 61 |
shhd: 0 |
| 62 |
},{ |
| 63 |
dur: C.BLEN / 4, |
| 64 |
pit: max, |
| 65 |
shhd: 0 |
| 66 |
}] |
| 67 |
} |
| 68 |
}, |
| 69 |
|
| 70 |
draw_symbols: function(of, p_voice) { |
| 71 |
var staff_tb = this.get_staff_tb(), |
| 72 |
s = p_voice.sym |
| 73 |
|
| 74 |
if (s.clef_type != undefined && s.nhd > 0) { |
| 75 |
s.x -= 26; |
| 76 |
this.set_scale(s); |
| 77 |
this.draw_note(s) |
| 78 |
if (s.notes[1].pit - s.notes[0].pit > 4) { |
| 79 |
this.xypath(s.x, 3 * (s.notes[1].pit - 18) + staff_tb[s.st].y); |
| 80 |
this.out_svg('v' + |
| 81 |
((s.notes[1].pit - s.notes[0].pit) * 3).toFixed(1) + |
| 82 |
'" stroke-width=".6"/>\n'); |
| 83 |
} |
| 84 |
s.x += 26; |
| 85 |
s.nhd = 0 |
| 86 |
p_voice.clef.nhd = 0 |
| 87 |
} |
| 88 |
of(p_voice) |
| 89 |
}, |
| 90 |
|
| 91 |
set_pitch: function(of, last_s) { |
| 92 |
of(last_s) |
| 93 |
if (!last_s && this.cfmt().ambitus) |
| 94 |
abc2svg.ambitus.do_ambitus.call(this) |
| 95 |
}, |
| 96 |
|
| 97 |
set_fmt: function(of, cmd, param) { |
| 98 |
if (cmd == "ambitus") { |
| 99 |
this.cfmt().ambitus = param |
| 100 |
return |
| 101 |
} |
| 102 |
of(cmd, param) |
| 103 |
}, |
| 104 |
|
| 105 |
set_glue: function(of, w) { |
| 106 |
var v, s, |
| 107 |
voice_tb = this.get_voice_tb() |
| 108 |
|
| 109 |
of(w) |
| 110 |
if (this.cfmt().ambitus) { |
| 111 |
for (v = 0; v < voice_tb.length; v++) { |
| 112 |
s = voice_tb[v].sym |
| 113 |
while (!s.time && !s.clef_type) |
| 114 |
s = s.next |
| 115 |
if (s && s.nhd) { |
| 116 |
s.x -= 26 |
| 117 |
this.draw_hl(s) |
| 118 |
s.ymn = 3 * (s.notes[0].pit - 18) - 2 |
| 119 |
s.ymx = 3 * (s.notes[1].pit - 18) + 2 |
| 120 |
s.x += 26 |
| 121 |
} |
| 122 |
} |
| 123 |
} |
| 124 |
}, |
| 125 |
|
| 126 |
set_width: function(of, s) { |
| 127 |
if (s.clef_type != undefined && s.nhd > 0) { |
| 128 |
s.wl = 40; |
| 129 |
s.wr = 12 |
| 130 |
} else { |
| 131 |
of(s) |
| 132 |
} |
| 133 |
}, |
| 134 |
|
| 135 |
set_hooks: function(abc) { |
| 136 |
abc.draw_symbols = abc2svg.ambitus.draw_symbols.bind(abc, abc.draw_symbols); |
| 137 |
abc.set_pitch = abc2svg.ambitus.set_pitch.bind(abc, abc.set_pitch); |
| 138 |
abc.set_format = abc2svg.ambitus.set_fmt.bind(abc, abc.set_format); |
| 139 |
abc.set_sym_glue = abc2svg.ambitus.set_glue.bind(abc, abc.set_sym_glue) |
| 140 |
abc.set_width = abc2svg.ambitus.set_width.bind(abc, abc.set_width) |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
if (!abc2svg.mhooks) |
| 145 |
abc2svg.mhooks = {} |
| 146 |
abc2svg.mhooks.ambitus = abc2svg.ambitus.set_hooks |