「VexFlow タブ譜 フレット番号と旗表示」の版間の差分

提供:yonewiki
 
(同じ利用者による、間の139版が非表示)
7行目: 7行目:
== '''概要''' ==
== '''概要''' ==
 五線譜で音が指定されていれば、フレット番号と弦の位置は数パターンに絞られます。が、一意には決まらないのがギターのややこしいところ、それでは弾けないので親切に押さえ方を教えてくれるのがタブ譜の役割です。一番上が一番細い弦で第一弦。一番下は一番太い弦で第六弦です。押さえなければ、上からE, B, G, D, A, Eという音がなります。一番上の弦と一番下の弦は音の高さこそ違えど同じ音がなります。
 五線譜で音が指定されていれば、フレット番号と弦の位置は数パターンに絞られます。が、一意には決まらないのがギターのややこしいところ、それでは弾けないので親切に押さえ方を教えてくれるのがタブ譜の役割です。一番上が一番細い弦で第一弦。一番下は一番太い弦で第六弦です。押さえなければ、上からE, B, G, D, A, Eという音がなります。一番上の弦と一番下の弦は音の高さこそ違えど同じ音がなります。
 あー。できないことがまた一つ見つかった。トリルができない。8分音符なのに譜旗の旗の部分がいらない。そしてトレモロのような記号を音符と音符の間に置かないといけない。できない。ちょっと考えよか。まただ。次々とできないことが判明するね。あとタイとかスラーのデフォルト値短すぎ。わかりやすく長めに書いてほしいのに16分音符のタイとスラー役にたってない。VexFlow。やるな!管理人を困らせるの得意すぎる。
 頑張ってタブ譜をなっとくいくレベルの描画をしてみました。これくらいの描画がVexFlowで出来たら、まじでバリバリ使ってたと思う。けど、ほとんど自作の描画です。慣れないうちは疲れるね。スライド、ハンマリング、プリングオフといった指示を省略しています。次の記事でつけよかな。
 追加した関数は
*insertTiePathToSVG({x:(始点x座標), y:(始点y座標)}, {x:終点x座標, y:終点y座標}, 方向数値(1 or -1), 深さ数値);
*insertTrilPathToSVG([{x:(始点x座標), y:(始点y座標)}, {x:終点x座標, y:終点y座標}], 方向数値(1 or -1));
*getUniqueStaveNotesIds(StaveNote notes, arr = [])
*updateAllFlagUniqueIds(getUniqueStaveNotesIds()の戻り値)
 で、タイやスラーを独自で描く関数と音符と音符の間に描くトリル記号を描く関数を追加しました。いずれの関数も始点と終点のキー.xと.yを含むオブジェクトを引数に受け取ります。方向数値はstem_directionに準じて1が規定値で、1なら下向きに膨らんだタイ、スラーになり、トリルは旗が上向きのときのトリル記号になり-1なら逆向きです。insertTiePathToSVGが引数にとる深さ数値は10ピクセル±2がベジェ曲線のハンドル値になるカーブの深さになります。もっと深くしたい場合は大きい値を指定するとよいですが、カーブの内側と外側の±2は固定なので、薄い線になるでしょう。
 トリルの時は4分音符の長さで行うときは旗の無い8分音符が2つの間をすばやく何回か繰り返すという意味なので8分音符で描いてから、旗を消すという処理が必要になります。2分音符のときは2分音符の符頭に置き換えないとだめでしょう。全音符のときは2分音符二つの旗と符棒を消さないと駄目ですね。符棒も旗も消す関数も必要かもしれませんね。あとでつくっておこうかな。
 最後の部分でupdateAllUniqueIdsに取得した符頭を消す全てのノートidの集合を処理する部分の精度をあげる改造をしました。前の項目までの処理だとノートに付随する付点を消したり、結局ほとんどのアクセントは使えないのですが、アクセント記号が消えたりする可能性がありました。
 タブ譜の音の高さはならす弦の高さで旗の付け根の位置をきめるだけの音の高さです。一番低い位置の弦か、高い位置の弦を音として指定するだけです。6弦は一番下の線で、E/4の位置ですから、G/4で旗の長さは十分でしょう。1弦の位置は五線譜の一個上の位置なので、A/5の位置で、そのままだと追加線が表示されますが、下向きの符棒なら、stem_directionを-1にして、F/5までの線でよいでしょう。そういう感じで音の高さを弦の位置におきかえて考えます。1弦でも装飾音符なら上向きの旗になることもあるので、その場合はB/5とかを指定してstem_directionを1というのもあるでしょう。でも大丈夫です。符頭消去処理では五線譜の追加線も消えるようになっていますので、きにせず、高い位置の弦も高い音符を使えばいいのです。1弦を描くために使った、五線譜で音符を書き始めるとバランスが難しくなってきますので、使わない方がよいでしょう。
 弦をひとつしかつかわない音なんかで、VexFlowの機能をアクセント記号を書きたいときには書けばいいでしょう。2弦以上同時に鳴らすアーティキュレーションは、符旗がながくなってしまうので、描けません。基本的には、手動でアーティキュレーション記号もBravuraフォントを使って描くのがよいでしょう。タブ譜を描くという目的のためにはアクセントは消さず、臨時記号は消した方がよさそうです。あと、追加の五線譜もタブ譜にはいらないので消す対象としました。四分音符と二分音符、全音符の符頭は消します。
 タブ譜の数字は自作フォントでは全角の数字に割り当てていますので、9までなら全角文字でいけます。10以降も全角文字2つの数字を使えばよいのでしょうけれど、つめつめにした専用の数字が違うコードポイントに格納されています。


 
 
41行目: 77行目:
const Perc_note1_1_0 = new Position();
const Perc_note1_1_0 = new Position();


var shiftGuitar1_1;
var shiftGuitar1_tab4_tr;
var shiftGuitar1_tab1;
var shiftGuitar1_tab2;
var shiftGuitar1_tab3;
var shiftGuitar1_tab4;
var shiftDrum1;
var shiftDrum1;
var shiftPerc1;
var shiftPerc1;
58行目: 101行目:
}
}


function insertTextToSVG(options) {
function insertTiePathToSVG(StartPos, EndPos, Direction = 1, Depth = 10) {
     var textContent = options.textContent;
  var newGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g');
     var strID = options.strID;
  newGroup.setAttribute('transform', 'translate(0, 0)');
     var Stave_x = options.Stave_x || 0;
  var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
  var pathStr = 'M' + (StartPos.x) + ' ' + (StartPos.y) + 'Q' + (StartPos.x + (EndPos.x - StartPos.x)/2) + ' ' + ((StartPos.y + EndPos.y)/2 + Direction * (Depth - 2)) +
    ',' + (EndPos.x) + ' ' + (EndPos.y) + 'Q' + ((StartPos.x + EndPos.x)/2) + ' ' + (StartPos.y + (EndPos.y - StartPos.y)/2 + Direction * (Depth + 2)) +
    ','  + (StartPos.x) + ' ' + (StartPos.y) + 'Z';
  path.setAttribute('d', pathStr);
  path.setAttribute('stroke', 'none');
  path.setAttribute('stroke-width', '1');
  path.setAttribute('fill', 'black');
  newGroup.appendChild(path);
  svgElement.appendChild(newGroup);
}
 
function insertTrilPathToSVG(Shift, Direction = 1) {
  var newGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g');
  newGroup.setAttribute('transform', 'translate(0, 0)');
  var DirectionOffset = 0;
  if (Direction == -1) DirectionOffset = 60;
  var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
  var pathStr = 'M ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 40 + DirectionOffset) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 36 + DirectionOffset) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 36 + DirectionOffset) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset);
  path.setAttribute('d', pathStr);
  path.setAttribute('stroke', 'none');
  path.setAttribute('stroke-width', '1');
  path.setAttribute('fill', 'black');
  var path2 = document.createElementNS('http://www.w3.org/2000/svg', 'path');
  var pathStr2 = 'M ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset + Direction * 7) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 40 + DirectionOffset + Direction * 7) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 36 + DirectionOffset + Direction * 7) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 36 + DirectionOffset + Direction * 7) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset + Direction * 7);
  path2.setAttribute('d', pathStr2);
  path2.setAttribute('stroke', 'none');
  path2.setAttribute('stroke-width', '1');
  path2.setAttribute('fill', 'black');
  var path3 = document.createElementNS('http://www.w3.org/2000/svg', 'path');
  var pathStr3 = 'M ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset + Direction * 14) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 40 + DirectionOffset + Direction * 14) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 36 + DirectionOffset + Direction * 14) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 36 + DirectionOffset + Direction * 14) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset + Direction * 14);
  path3.setAttribute('d', pathStr3);
  path3.setAttribute('stroke', 'none');
  path3.setAttribute('stroke-width', '1');
  path3.setAttribute('fill', 'black');
  newGroup.appendChild(path);
  newGroup.appendChild(path2);
  newGroup.appendChild(path3);
  svgElement.appendChild(newGroup);
}
 
 
function insertTextToSVG(options) {
     var textContent = options.textContent;
     var strID = options.strID;
     var Stave_x = options.Stave_x || 0;
     var Stave_y = options.Stave_y || 0;
     var Stave_y = options.Stave_y || 0;
     var isOffset_x_abs = options.IsOffset_x_Abs || false;
     var isOffset_x_abs = options.IsOffset_x_Abs || false;
183行目: 283行目:


var allUniqueIds = [];
var allUniqueIds = [];
var allFlagUniqueIds = [];
(function(){
(function(){
function addShift(notes, arrx = [], arry = []) {
function addShift(notes, arrx = [], arry = []) {
249行目: 350行目:
}
}


function dotted(staveNote, noteIndex = -1) {
var SteveNoteUniqueIds;
   if (noteIndex < 0) {
function getUniqueStaveNotesIds(notes, arr = []) {
     Dot.buildAndAttach([staveNote], {
    //すべてのidを格納するためのセットを作成
       all: true
    let tempnote;
     });
    uniqueIds = new Set();
   }  
    for(let i = 0; i < arr.length || i == 0; i++){
    //notesのchildrenの各要素について処理
      if(arr.length === 0){
        tempnote = notes;
      }
      else{
        tempnote = notes[arr[i]];
      }
      if (tempnote.attrs){
        if(tempnote.attrs.type === "StaveNote") {
          uniqueIds.add(tempnote.attrs.id);
        }
      }
    }
    // セットを配列に変換して戻り値として返す
    return Array.from(uniqueIds);
}
 
function updateAllFlagUniqueIds(FlagUniqueIds) {
    // allUniqueIdsにUniqueIdsを追加または結合
    if (allFlagUniqueIds.length === 0) {
      // allUniqueIdsが空の場合、UniqueIdsをそのままコピー
      allFlagUniqueIds = [...FlagUniqueIds];//スプレッド演算子で要素の中身を書き出す。
    } else {
      FlagUniqueIds.forEach(id => {
        if (!allFlagUniqueIds.includes(id)) {
            allFlagUniqueIds.push(id);
        }
      });
    }
    // 更新されたallUniqueIdsを戻り値として返す
    return allFlagUniqueIds;
}
 
function dotted(staveNote, noteIndex = -1) {
   if (noteIndex < 0) {
     Dot.buildAndAttach([staveNote], {
       all: true
     });
   }  
   else {
   else {
     for(noteIndexValue of noteIndex){
     for(noteIndexValue of noteIndex){
339行目: 479行目:
VocalSt1.setClef("treble").setContext(ctx);
VocalSt1.setClef("treble").setContext(ctx);
VocalSt1.setTimeSignature('4/4').setContext(ctx);
VocalSt1.setTimeSignature('4/4').setContext(ctx);
VocalSt1.addKeySignature('D').setContext(ctx);
VocalSt1.setMeasure(1);
VocalSt1.setMeasure(1);
VocalSt1.draw();
VocalSt1.draw();
360行目: 501行目:
Guitar1St1.addClef("treble").setContext(ctx);
Guitar1St1.addClef("treble").setContext(ctx);
Guitar1St1.addTimeSignature('4/4').setContext(ctx);
Guitar1St1.addTimeSignature('4/4').setContext(ctx);
Guitar1St1.addKeySignature('D').setContext(ctx);
Guitar1St1.draw();
Guitar1St1.draw();


const Guitar1_notes1_1 = [
const Guitar1_notes1_1 = [
   new VF.StaveNote({ keys: ["a/3", "e/4", "a/4", "c/5"], duration: "2" }),
   new VF.StaveNote({ keys: ["a/3", "e/4", "a/4", "c/5"], duration: "2" }),
   new VF.StaveNote({ keys: ["e/5"], duration: "8" }),
   new VF.StaveNote({ keys: ["e/5"], duration: "8", stem_direction: -1 }),
   dotted(new VF.StaveNote({ keys: ["c/6"], duration: "4d" })),
   dotted(new VF.StaveNote({ keys: ["c/6"], duration: "4d", stem_direction: -1 })),
];
];
const Guitar1_notes1_2 = [
const Guitar1_notes1_2 = [
398行目: 540行目:


var formatterGuitar1_St1_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_St1_2Voice, Guitar1_St1_1Voice]);
var formatterGuitar1_St1_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_St1_2Voice, Guitar1_St1_1Voice]);
formatterGuitar1_St1_1.format([Guitar1_St1_2Voice, Guitar1_St1_1Voice], nStaveWidth - 10);
formatterGuitar1_St1_1.format([Guitar1_St1_2Voice, Guitar1_St1_1Voice], nStaveWidth - 20 - 10);
Guitar1_St1_1Voice.draw(ctx, Guitar1St1);
Guitar1_St1_1Voice.draw(ctx, Guitar1St1);
Guitar1_St1_2Voice.draw(ctx, Guitar1St1);
Guitar1_St1_2Voice.draw(ctx, Guitar1St1);
405行目: 547行目:
Guitar1St2.draw();
Guitar1St2.draw();


const Guitar1St3 = new Stave(Guitar1St2.width + Guitar1St2.x, Guitar1St1.y, nStaveWidth).setContext(ctx);
const Guitar1_gracenotes2 = [
Guitar1St3.draw();
  new VF.GraceNote({ keys: ['e/5', 'g/5'], duration: '8', slash: true })
  .addModifier(new VF.Accidental('#'), 1)
];


const Guitar1St4 = new Stave(Guitar1St3.width + Guitar1St3.x, Guitar1St1.y, nStaveWidth).setContext(ctx);
const Guitar1_notes2_1 = [
Guitar1St4.draw();
  new VF.StaveNote({ keys: ["f/5", "a/5"], duration: "8", stem_direction: -1 })
  .addModifier(new VF.Accidental('n'), 0),
  new VF.StaveNote({ keys: ["e/5", "g/5"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["f/5"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["e/5"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4", "d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["f/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["e/4"], duration: "8" }),
];
const Guitar1_notes2_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


const Guitar1_tab1 = new Stave(Guitar1St1.x, Guitar1St1.y + 110, nHeadMargin + nStaveWidth).setContext(ctx);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
for (var i = 0; i < 5; i++) {
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  if (i == 0) continue;
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   Guitar1_tab1.setConfigForLine(i, {visible: false} );
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
}
Guitar1_tab1.draw();


const Guitar1_tab2 = new Stave(Guitar1_tab1.width + Guitar1_tab1.x, Guitar1_tab1.y, nStaveWidth).setContext(ctx);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
for (var i = 0; i < 5; i++) {
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  if (i == 0) continue;
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   Guitar1_tab2.setConfigForLine(i, {visible: false} );
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
}
Guitar1_tab2.draw();


const Guitar1_tab3 = new Stave(Guitar1_tab2.width + Guitar1_tab2.x, Guitar1_tab1.y, nStaveWidth).setContext(ctx);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
for (var i = 0; i < 5; i++) {
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  if (i == 0) continue;
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   Guitar1_tab3.setConfigForLine(i, {visible: false} );
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
}
Guitar1_tab3.draw();


const Guitar1_tab4 = new Stave(Guitar1_tab3.width + Guitar1_tab3.x, Guitar1_tab1.y, nStaveWidth).setContext(ctx);
];
for (var i = 0; i < 5; i++) {
Guitar1_notes2_1[0].addModifier(new VF.Articulation('a.').setPosition(3));
  if (i == 0) continue;
Guitar1_notes2_1[1].addModifier(new VF.Articulation('a.').setPosition(3));
  Guitar1_tab4.setConfigForLine(i, {visible: false} );
Guitar1_notes2_1[2].addModifier(new VF.Articulation('a.').setPosition(3));
}
Guitar1_notes2_1[3].addModifier(new VF.Articulation('a.').setPosition(3));
Guitar1_tab4.draw();
Guitar1_notes2_1[4].addModifier(new VF.Articulation('a.').setPosition(4));
Guitar1_notes2_1[5].addModifier(new VF.Articulation('a.').setPosition(4));
Guitar1_notes2_1[6].addModifier(new VF.Articulation('a.').setPosition(4));
Guitar1_notes2_1[7].addModifier(new VF.Articulation('a.').setPosition(4));
Guitar1_notes2_1[0].addModifier(new VF.GraceNoteGroup(Guitar1_gracenotes2, true), 0);


const Guitar1_Tab1 = new Stave(Guitar1St1.x, Guitar1St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
const Guitar1_beam1_1 = new VF.Beam([Guitar1_notes2_1[0], Guitar1_notes2_1[1], Guitar1_notes2_1[2], Guitar1_notes2_1[3]]);
Guitar1_Tab1.draw();
const Guitar1_beam1_2 = new VF.Beam([Guitar1_notes2_1[4], Guitar1_notes2_1[5], Guitar1_notes2_1[6], Guitar1_notes2_1[7]]);


Stave9Pos.x = Guitar1_Tab1.x;
var Guitar1_St2_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Stave9Pos.y = Guitar1_Tab1.y;
Guitar1_St2_1Voice.setStrict(true);
Guitar1_St2_1Voice.addTickables(Guitar1_notes2_1);


var connector9_2 = new VF.StaveConnector(Guitar1St1, Guitar1_Tab1);
var Guitar1_St2_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
connector9_2.setType(VF.StaveConnector.type.BRACKET);
Guitar1_St2_2Voice.setStrict(true);
connector9_2.setContext(ctx);
Guitar1_St2_2Voice.addTickables(Guitar1_notes2_2);
connector9_2.draw();


Guitar1Inst.x = VocalSt1.x - 30;
var formatterGuitar1_St2_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_St2_2Voice, Guitar1_St2_1Voice]);
Guitar1Inst.y = Guitar1St1.y + ((Guitar1_Tab1.y - Guitar1St1.y) / 2) + 90;  
formatterGuitar1_St2_1.format([Guitar1_St2_2Voice, Guitar1_St2_1Voice], nStaveWidth - 30);
Guitar1_St2_1Voice.draw(ctx, Guitar1St2);
Guitar1_St2_2Voice.draw(ctx, Guitar1St2);


const Guitar1_Tab2 = new Stave(Guitar1_Tab1.width + Guitar1_Tab1.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
Guitar1_beam1_1.setContext(ctx).draw();
Guitar1_Tab2.draw();
Guitar1_beam1_2.setContext(ctx).draw();


const Guitar1_Tab3 = new Stave(Guitar1_Tab2.width + Guitar1_Tab2.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
const Guitar1St3 = new Stave(Guitar1St2.width + Guitar1St2.x, Guitar1St1.y, nStaveWidth).setContext(ctx);
Guitar1_Tab3.draw();
Guitar1St3.draw();


const Guitar1_Tab4 = new Stave(Guitar1_Tab3.width + Guitar1_Tab3.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
const Guitar1_notes3_1 = [
Guitar1_Tab4.draw();
  new VF.StaveNote({ keys: ["g/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["e/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["e/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["e/4"], duration: "2" }),
];
const Guitar1_notes3_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


const Guitar2_St1 = new Stave(Guitar1_Tab1.x, Guitar1_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Guitar2_St1.addClef("treble").setContext(ctx);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Guitar2_St1.addTimeSignature('4/4').setContext(ctx);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Guitar2_St1.draw();
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


const Guitar2_St2 = new Stave(Guitar2_St1.width + Guitar2_St1.x, Guitar2_St1.y, nStaveWidth).setContext(ctx);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Guitar2_St2.draw();
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


const Guitar2_St3 = new Stave(Guitar2_St2.width + Guitar2_St2.x, Guitar2_St2.y, nStaveWidth).setContext(ctx);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Guitar2_St3.draw();
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


const Guitar2_St4 = new Stave(Guitar2_St3.width + Guitar2_St3.x, Guitar2_St3.y, nStaveWidth).setContext(ctx);
];
Guitar2_St4.draw();
const Guitar1_beam3_1 = new VF.Beam([Guitar1_notes3_1[0], Guitar1_notes3_1[1], Guitar1_notes3_1[2], Guitar1_notes3_1[3]]);
const Guitar1_beam3_2 = new VF.Beam([Guitar1_notes3_1[4], Guitar1_notes3_1[5], Guitar1_notes3_1[6]]);


const Guitar2_Tab1 = new Stave(Guitar2_St1.x, Guitar2_St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
var Guitar1_St3_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar2_Tab1.draw();
Guitar1_St3_1Voice.setStrict(true);
Guitar1_St3_1Voice.addTickables(Guitar1_notes3_1);


Guitar2Tab1.x = Guitar2_Tab1.x;
var Guitar1_St3_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar2Tab1.y = Guitar2_Tab1.y;
Guitar1_St3_2Voice.setStrict(true);
Guitar1_St3_2Voice.addTickables(Guitar1_notes3_2);


const Guitar2_Tab2 = new Stave(Guitar2_Tab1.width + Guitar2_Tab1.x, Guitar2_Tab1.y, nStaveWidth).setContext(ctx);
var formatterGuitar1_St3_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_St3_2Voice, Guitar1_St3_1Voice]);
Guitar2_Tab2.draw();
formatterGuitar1_St3_1.format([Guitar1_St3_2Voice, Guitar1_St3_1Voice], nStaveWidth - 30);
Guitar1_St3_1Voice.draw(ctx, Guitar1St3);
Guitar1_St3_2Voice.draw(ctx, Guitar1St3);


const Guitar2_Tab3 = new Stave(Guitar2_Tab2.width + Guitar2_Tab2.x, Guitar2_Tab2.y, nStaveWidth).setContext(ctx);
Guitar1_beam3_1.setContext(ctx).draw();
Guitar2_Tab3.draw();
Guitar1_beam3_2.setContext(ctx).draw();


const Guitar2_Tab4 = new Stave(Guitar2_Tab3.width + Guitar2_Tab3.x, Guitar2_Tab3.y, nStaveWidth).setContext(ctx);
const Guitar1_ties3 = [
Guitar2_Tab4.draw();
    new StaveTie({
        first_note: Guitar1_notes3_1[0],
        last_note: Guitar1_notes3_1[1],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes3_1[1],
        last_note: Guitar1_notes3_1[2],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes3_1[2],
        last_note: Guitar1_notes3_1[3],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes3_1[3],
        last_note: Guitar1_notes3_1[4],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes3_1[6],
        last_note: Guitar1_notes3_1[7],
        first_indices: [0],
        last_indices: [0],
    }),
];


var Guitar2_connect = new VF.StaveConnector(Guitar2_St1, Guitar2_Tab1);
Guitar1_ties3.forEach((t) => {
Guitar2_connect.setType(VF.StaveConnector.type.BRACKET);
    t.setContext(ctx).draw();
Guitar2_connect.setContext(ctx);
});
Guitar2_connect.draw();


const Guitar2_Tab1_tab = new Stave(Guitar2_Tab1.x, Guitar2_Tab1.y - 10, nHeadMargin + nStaveWidth).setContext(ctx);
var Guitar1_vibrato3 = new VF.VibratoBracket({
for (var i = 0; i < 5; i++) {
  start: Guitar1_notes3_1[7],
  if (i == 0) continue;
  stop: null,
  Guitar2_Tab1_tab.setConfigForLine(i, {visible: false} );
});
}
Guitar1_vibrato3.setLine(0);
Guitar2_Tab1_tab.draw();
Guitar1_vibrato3.setHarsh(true);
Guitar1_vibrato3.setContext(ctx).draw();


const Guitar2_Tab2_tab = new Stave(Guitar2_Tab1_tab.width + Guitar2_Tab1_tab.x, Guitar2_Tab1_tab.y, nStaveWidth).setContext(ctx);
const Guitar1St4 = new Stave(Guitar1St3.width + Guitar1St3.x, Guitar1St1.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
Guitar1St4.draw();
  if (i == 0) continue;
  Guitar2_Tab2_tab.setConfigForLine(i, {visible: false} );
}
Guitar2_Tab2_tab.draw();


const Guitar2_Tab3_tab = new Stave(Guitar2_Tab2_tab.width + Guitar2_Tab2_tab.x, Guitar2_Tab2_tab.y, nStaveWidth).setContext(ctx);
const Guitar1_gracenotes4 = [
for (var i = 0; i < 5; i++) {
  new VF.GraceNote({ keys: ['a/4'], duration: '8', slash: true })
  if (i == 0) continue;
];
  Guitar2_Tab3_tab.setConfigForLine(i, {visible: false} );
}
Guitar2_Tab3_tab.draw();


const Guitar2_Tab4_tab = new Stave(Guitar2_Tab3_tab.width + Guitar2_Tab3_tab.x, Guitar2_Tab3_tab.y, nStaveWidth).setContext(ctx);
const Guitar1_notes4_1 = [
for (var i = 0; i < 5; i++) {
  new VF.StaveNote({ keys: ["g/4"], duration: "8" }),
   if (i == 0) continue;
  new VF.StaveNote({ keys: ["a/4"], duration: "8" }),
   Guitar2_Tab4_tab.setConfigForLine(i, {visible: false} );
  new VF.StaveNote({ keys: ["g/4"], duration: "8" }),
}
  new VF.StaveNote({ keys: ["b/4"], duration: "8" }),
Guitar2_Tab4_tab.draw();
  new VF.StaveNote({ keys: ["b/4"], duration: "4" }),
  new VF.StaveNote({ keys: ["b/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "16", stem_direction: -1 }),
   new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 }),
];
const Guitar1_notes4_2 = [
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


Guitar2Inst.x = Guitar2_St1.x - 30;
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Guitar2Inst.y = Guitar2_St1.y + ((Guitar2_Tab1.y - Guitar2_St1.y) / 2) + 90;
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


const Base_St1 = new Stave(Guitar2_Tab1.x, Guitar2_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Base_St1.addClef("treble").setContext(ctx);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Base_St1.addTimeSignature('4/4').setContext(ctx);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Base_St1.draw();
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


const Base_St2 = new Stave(Base_St1.width + Base_St1.x, Base_St1.y, nStaveWidth).setContext(ctx);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Base_St2.draw();
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


const Base_St3 = new Stave(Base_St2.width + Base_St2.x, Base_St2.y, nStaveWidth).setContext(ctx);
];
Base_St3.draw();
Guitar1_notes4_1[7].addModifier(new VF.Articulation('a.').setPosition(3));
Guitar1_notes4_1[3].addModifier(new VF.GraceNoteGroup(Guitar1_gracenotes4, true), 0);


const Base_St4 = new Stave(Base_St3.width + Base_St3.x, Base_St3.y, nStaveWidth).setContext(ctx);
SteveNoteUniqueIds = getUniqueStaveNotesIds(Guitar1_notes4_1, [0, 1]);
Base_St4.draw();
allFlagUniqueIds = updateAllFlagUniqueIds(SteveNoteUniqueIds);


const Base_Tab1 = new Stave(Base_St1.x, Base_St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
const Guitar1_beam4_1 = new VF.Beam([Guitar1_notes4_1[2], Guitar1_notes4_1[3]]);
Base_Tab1.setEndBarType(VF.Barline.type.NONE);
const Guitar1_beam4_2 = new VF.Beam([Guitar1_notes4_1[5], Guitar1_notes4_1[6], Guitar1_notes4_1[7]]);
for (var i = 0; i < 5; i++) {
 
  if (i != 0) continue;
var Guitar1_St4_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
  Base_Tab1.setConfigForLine(i, {visible: false} );
Guitar1_St4_1Voice.setStrict(true);
}
Guitar1_St4_1Voice.addTickables(Guitar1_notes4_1);
Base_Tab1.draw();
 
var Guitar1_St4_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St4_2Voice.setStrict(true);
Guitar1_St4_2Voice.addTickables(Guitar1_notes4_2);
 
var formatterGuitar1_St4_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_St4_2Voice, Guitar1_St4_1Voice]);
formatterGuitar1_St4_1.format([Guitar1_St4_2Voice, Guitar1_St4_1Voice], nStaveWidth - 30);
Guitar1_St4_1Voice.draw(ctx, Guitar1St4);
Guitar1_St4_2Voice.draw(ctx, Guitar1St4);


BaseTab1.x = Base_Tab1.x;
Guitar1_beam4_1.setContext(ctx).draw();
BaseTab1.y = Base_Tab1.y;
Guitar1_beam4_2.setContext(ctx).draw();


BaseInst.x = Base_St1.x - 30;
shiftGuitar1_1 = addShift(
BaseInst.y = Base_St1.y + ((Base_Tab1.y - Base_St1.y) / 2) + 90;  
  Guitar1_notes4_1,
  [0, 1],
  [4, 3.5]
);


StaveBase1 = Base_Tab1;
const Guitar1_ties4 = [
    new StaveTie({
        first_note: Guitar1_notes4_1[0],
        last_note: Guitar1_notes4_1[1],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes4_1[1],
        last_note: Guitar1_notes4_1[2],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes4_1[3],
        last_note: Guitar1_notes4_1[4],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes4_1[5],
        last_note: Guitar1_notes4_1[6],
        first_indices: [0],
        last_indices: [0],
    }),
];


const Base_Tab2 = new Stave(Base_Tab1.width + Base_Tab1.x, Base_Tab1.y, nStaveWidth).setContext(ctx);
Guitar1_ties4.forEach((t) => {
Base_Tab2.setBegBarType(VF.Barline.type.NONE);
    t.setContext(ctx).draw();
Base_Tab2.setEndBarType(VF.Barline.type.NONE);
});
for (var i = 0; i < 5; i++) {
  if (i != 0) continue;
  Base_Tab2.setConfigForLine(i, {visible: false} );
}
Base_Tab2.draw();


StaveBase2 = Base_Tab2;


const Base_Tab3 = new Stave(Base_Tab2.width + Base_Tab2.x, Base_Tab2.y, nStaveWidth).setContext(ctx);
const Guitar1_tab1 = new Stave(Guitar1St1.x, Guitar1St1.y + 110, nHeadMargin + nStaveWidth).setContext(ctx);
Base_Tab3.setBegBarType(VF.Barline.type.NONE);
Base_Tab3.setEndBarType(VF.Barline.type.NONE);
for (var i = 0; i < 5; i++) {
for (var i = 0; i < 5; i++) {
   if (i != 0) continue;
   if (i == 0) continue;
   Base_Tab3.setConfigForLine(i, {visible: false} );
  Guitar1_tab1.setConfigForLine(i, {visible: false} );
}
Guitar1_tab1.draw();
 
const Guitar1_tab2 = new Stave(Guitar1_tab1.width + Guitar1_tab1.x, Guitar1_tab1.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
   Guitar1_tab2.setConfigForLine(i, {visible: false} );
}
}
Base_Tab3.draw();
Guitar1_tab2.draw();


StaveBase3 = Base_Tab3;
const Guitar1_tab3 = new Stave(Guitar1_tab2.width + Guitar1_tab2.x, Guitar1_tab1.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar1_tab3.setConfigForLine(i, {visible: false} );
}
Guitar1_tab3.draw();


const Base_Tab4 = new Stave(Base_Tab3.width + Base_Tab3.x, Base_Tab3.y, nStaveWidth).setContext(ctx);
const Guitar1_tab4 = new Stave(Guitar1_tab3.width + Guitar1_tab3.x, Guitar1_tab1.y, nStaveWidth).setContext(ctx);
Base_Tab4.setBegBarType(VF.Barline.type.NONE);
Base_Tab4.setEndBarType(VF.Barline.type.NONE);
for (var i = 0; i < 5; i++) {
for (var i = 0; i < 5; i++) {
   if (i != 0) continue;
   if (i == 0) continue;
   Base_Tab4.setConfigForLine(i, {visible: false} );
   Guitar1_tab4.setConfigForLine(i, {visible: false} );
}
}
Base_Tab4.draw();
Guitar1_tab4.draw();
 


StaveBase4 = Base_Tab4;


var Base_connect = new VF.StaveConnector(Base_St1, Base_Tab1);
const Guitar1_Tab1 = new Stave(Guitar1St1.x, Guitar1St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Base_connect.setType(VF.StaveConnector.type.BRACKET);
Guitar1_Tab1.draw();
Base_connect.setContext(ctx);
 
Base_connect.draw();
Stave9Pos.x = Guitar1_Tab1.x;
Stave9Pos.y = Guitar1_Tab1.y;
 
var connector9_2 = new VF.StaveConnector(Guitar1St1, Guitar1_Tab1);
connector9_2.setType(VF.StaveConnector.type.BRACKET);
connector9_2.setContext(ctx);
connector9_2.draw();


const Drum_St1 = new Stave(Base_Tab1.x, Base_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Guitar1Inst.x = VocalSt1.x - 30;
Drum_St1.addClef("bass").setContext(ctx);
Guitar1Inst.y = Guitar1St1.y + ((Guitar1_Tab1.y - Guitar1St1.y) / 2) + 90;  
Drum_St1.addTimeSignature('4/4').setContext(ctx);
Drum_St1.draw();


DrumInst.x = Drum_St1.x - 30;
DrumInst.y = Drum_St1.y + 90;


const Drum_St1_1 = new Stave(nHeadMargin + Base_Tab1.x, Base_Tab1.y + 120, 0).setContext(ctx);
const Guitar1_Tab1_1 = new Stave(Guitar1_Tab1.x + nHeadMargin + 20, Guitar1_Tab1.y, 0).setContext(ctx);
Drum_St1_1.setBegBarType(VF.Barline.type.NONE);
Guitar1_Tab1_1.setBegBarType(VF.Barline.type.NONE);
Drum_St1_1.setEndBarType(VF.Barline.type.NONE);
Guitar1_Tab1_1.setEndBarType(VF.Barline.type.NONE);
Drum_St1_1.draw();
Guitar1_Tab1_1.draw();


const Drum_notes1_1 = [
const Guitar1_tab_notes1_1 = [
   new StaveNote({ keys: ["f/4"], duration: "4", stem_direction: -1 }),
   new VF.GhostNote({ keys: ["a/3", "e/4", "a/4", "c/5"], duration: "2" }),
  new StaveNote({ keys: ["c/4"], duration: "4r" }),
   new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 }),
  new StaveNote({ keys: ["c/4"], duration: "8r" }),
   dotted(new VF.StaveNote({ keys: ["f/5"], duration: "4d", stem_direction: -1 })),
   new StaveNote({ keys: ["f/4"], duration: "8", stem_direction: -1 }),
   new StaveNote({ keys: ["c/4"], duration: "8r" }),
  new StaveNote({ keys: ["f/4"], duration: "8", stem_direction: -1 })
];
];
const Drum_beam1_1 = new VF.Beam([Drum_notes1_1[3],Drum_notes1_1[5]]);
const Guitar1_tab_notes1_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


var Drum_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Drum_St1_1Voice.setStrict(true);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Drum_St1_1Voice.addTickables(Drum_notes1_1);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


const Drum_St1_2 = new Stave(nHeadMargin + Base_Tab1.x, Base_Tab1.y + 120, 0).setContext(ctx);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Drum_St1_2.setBegBarType(VF.Barline.type.NONE);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Drum_St1_2.setEndBarType(VF.Barline.type.NONE);
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Drum_St1_2.draw();
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


const Drum_notes1_2 = [
];
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
UniqueIds = getUniqueNoteheadIds(Guitar1_tab_notes1_1, [1, 2]);
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
allUniqueIds = updateAllUniqueIds(UniqueIds);
  new VF.StaveNote({ keys: ["c/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "16", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "16", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 })
];


const Drum_notes1_3 = [
var Guitar1_tab_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
Guitar1_tab_St1_1Voice.setStrict(true);
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
Guitar1_tab_St1_1Voice.addTickables(Guitar1_tab_notes1_1);
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),


  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
var Guitar1_tab_St1_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
Guitar1_tab_St1_2Voice.setStrict(true);
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
Guitar1_tab_St1_2Voice.addTickables(Guitar1_tab_notes1_2);
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),


  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
var formatterGuitar1_tab_St1_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_tab_St1_2Voice, Guitar1_tab_St1_1Voice]);
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
formatterGuitar1_tab_St1_1.format([Guitar1_tab_St1_2Voice, Guitar1_tab_St1_1Voice], nStaveWidth - 20 - 10);
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
Guitar1_tab_St1_1Voice.draw(ctx, Guitar1_Tab1_1);
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
Guitar1_tab_St1_2Voice.draw(ctx, Guitar1_Tab1_1);


   new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
shiftGuitar1_tab1 = addShift(
   new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
   Guitar1_tab_notes1_1,  
   new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
   [0, 0, 0, 0, 1,  2],
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 })
   [3, 2, 1, 0, 1, -1]
];
);


UniqueIds = getUniqueNoteheadIds(Drum_notes1_2, [0, 1, 3, 5, 6, 8]);
allUniqueIds = updateAllUniqueIds(UniqueIds);


const Drum_beam1_2_1 = new VF.Beam([Drum_notes1_2[0], Drum_notes1_2[1]]);
const Drum_beam1_2_2 = new VF.Beam([Drum_notes1_2[2], Drum_notes1_2[3], Drum_notes1_2[4]]);
const Drum_beam1_2_3 = new VF.Beam([Drum_notes1_2[5], Drum_notes1_2[6], Drum_notes1_2[7], Drum_notes1_2[8]]);


var Drum_St1_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
const Guitar1_Tab2 = new Stave(Guitar1_Tab1.width + Guitar1_Tab1.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
Drum_St1_2Voice.setStrict(true);
Guitar1_Tab2.draw();
Drum_St1_2Voice.addTickables(Drum_notes1_2);


var Drum_St1_3Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
const Guitar1_tab_gracenotes2 = [
Drum_St1_3Voice.setStrict(true);
  new VF.GraceNote({ keys: ['a/5'], duration: '8', slash: true })
Drum_St1_3Voice.addTickables(Drum_notes1_3);
  .addModifier(new VF.Accidental('#'), 0)
];


var formatterDrum_St1_2 = new Vex.Flow.Formatter().joinVoices([Drum_St1_3Voice, Drum_St1_1Voice, Drum_St1_2Voice]);
const Guitar1_tab_notes2_1 = [
//formatter13_2.formatToStave([stave13_3Voice, stave13_1Voice, stave13_2Voice], stave13_2);
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 })
formatterDrum_St1_2.format([Drum_St1_3Voice, Drum_St1_1Voice, Drum_St1_2Voice], nStaveWidth - 30);
  .addModifier(new VF.Accidental('n'), 0),
Drum_St1_1Voice.draw(ctx, Drum_St1_2);
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 }),
Drum_St1_2Voice.draw(ctx, Drum_St1_2);
  new VF.StaveNote({ keys: ["d/5"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["f/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["b/4"], duration: "8" }),
];
const Guitar1_tab_notes2_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


Drum_beam1_1.setContext(ctx).draw();
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


Drum_beam1_2_1.setContext(ctx).draw();
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Drum_beam1_2_2.setContext(ctx).draw();
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
Drum_beam1_2_3.setContext(ctx).draw();
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


shiftDrum1 = addShift(
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   Drum_notes1_2,  
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   [0, 1, 2, 3, 5, 5, 6, 6, 7, 7, 8, 8],
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
);


];
Guitar1_tab_notes2_1[0].addModifier(new VF.GraceNoteGroup(Guitar1_tab_gracenotes2, false), 0);


const Drum_St2 = new Stave(Drum_St1.width + Drum_St1.x, Drum_St1.y, nStaveWidth).setContext(ctx);
UniqueIds = getUniqueNoteheadIds(Guitar1_tab_notes2_1, [0, 1, 2, 3, 4, 5, 6, 7]);
Drum_St2.draw();
allUniqueIds = updateAllUniqueIds(UniqueIds);


const Guitar1_tab_beam2_1 = new VF.Beam([Guitar1_tab_notes2_1[0], Guitar1_tab_notes2_1[1], Guitar1_tab_notes2_1[2], Guitar1_tab_notes2_1[3]]);
const Guitar1_tab_beam2_2 = new VF.Beam([Guitar1_tab_notes2_1[4], Guitar1_tab_notes2_1[5], Guitar1_tab_notes2_1[6], Guitar1_tab_notes2_1[7]]);


const Drum_St3 = new Stave(Drum_St2.width + Drum_St2.x, Drum_St1.y, nStaveWidth).setContext(ctx);
var Guitar1_tab_St2_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Drum_St3.draw();
Guitar1_tab_St2_1Voice.setStrict(true);
Guitar1_tab_St2_1Voice.addTickables(Guitar1_tab_notes2_1);


var Guitar1_tab_St2_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St2_2Voice.setStrict(true);
Guitar1_tab_St2_2Voice.addTickables(Guitar1_tab_notes2_2);


const Drum_St4 = new Stave(Drum_St3.width + Drum_St3.x, Drum_St1.y, nStaveWidth).setContext(ctx);
var formatterGuitar1_tab_St2_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_tab_St2_2Voice, Guitar1_tab_St2_1Voice]);
Drum_St4.draw();
formatterGuitar1_tab_St2_1.format([Guitar1_tab_St2_2Voice, Guitar1_tab_St2_1Voice], nStaveWidth - 20);
Guitar1_tab_St2_1Voice.draw(ctx, Guitar1_Tab2);
Guitar1_tab_St2_2Voice.draw(ctx, Guitar1_Tab2);


shiftGuitar1_tab2 = addShift(
  Guitar1_tab_notes2_1,
  [0, 0, 0, 0, 1, 1, 2, 3, 4, 4, 5, 6, 7],
  [1, 0, 1, 0, 1, 0, 0, 1, 2, 1, 2, 2, 3]
);


const Perc_St1 = new Stave(Drum_St1.x, Drum_St1.y + 100, nHeadMargin + nStaveWidth).setContext(ctx);
Guitar1_tab_beam2_1.setContext(ctx).draw();
Perc_St1.addTimeSignature('4/4').setContext(ctx);
Guitar1_tab_beam2_2.setContext(ctx).draw();


const Perc_St1_1 = new Stave(nHeadMargin + Drum_St1.x, Drum_St1.y + 100, 0).setContext(ctx);
//const Curve1_1to2_2 = new Curve(
Perc_St1_1.setBegBarType(VF.Barline.type.NONE);
//  Guitar1_tab_gracenotes2[0],
Perc_St1_1.setEndBarType(VF.Barline.type.NONE);
//  Guitar1_tab_notes2_1[0],
Perc_St1_1.draw();
//  {
//    cps: [
//      { x: 0, y:10 },
//      { x: 0, y:10 },
//    ],
//  },
//);


for (var i = 0; i < 5; i++) {
  if (i == 2) continue;
  Perc_St1.setConfigForLine(i, {visible: false} );
}


Perc_St1.draw();


PercInst.x = Perc_St1.x - 30;
const Guitar1_Tab3 = new Stave(Guitar1_Tab2.width + Guitar1_Tab2.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
PercInst.y = Perc_St1.y + 90;  
Guitar1_Tab3.draw();


var AllConnector = new VF.StaveConnector(VocalSt1, Perc_St1);
const Guitar1_tab_notes3_1 = [
AllConnector.setType(VF.StaveConnector.type.SINGLE);
  new VF.StaveNote({ keys: ["d/5"], duration: "16" }),
AllConnector.setContext(ctx);
  new VF.StaveNote({ keys: ["d/5"], duration: "16" }),
AllConnector.draw();
  new VF.StaveNote({ keys: ["d/5"], duration: "16" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "16" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "16" }),
  new VF.GhostNote({ keys: ["b/4"], duration: "2" }),
];
const Guitar1_tab_notes3_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


const Perc_notes1_1 = [
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),


   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
   new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 })
];
];
UniqueIds = getUniqueNoteheadIds(Perc_notes1_1, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
UniqueIds = getUniqueNoteheadIds(Guitar1_tab_notes3_1, [0, 1, 2, 3, 4, 5, 6, 7]);
allUniqueIds = updateAllUniqueIds(UniqueIds);
allUniqueIds = updateAllUniqueIds(UniqueIds);


const Perc_beam1_1_1 = new VF.Beam([Perc_notes1_1[0], Perc_notes1_1[1], Perc_notes1_1[2], Perc_notes1_1[3]]);
const Guitar1_tab_beam3_1 = new VF.Beam([Guitar1_tab_notes3_1[0], Guitar1_tab_notes3_1[1], Guitar1_tab_notes3_1[2], Guitar1_tab_notes3_1[3]]);
const Perc_beam1_1_2 = new VF.Beam([Perc_notes1_1[4], Perc_notes1_1[5], Perc_notes1_1[6], Perc_notes1_1[7]]);
const Guitar1_tab_beam3_2 = new VF.Beam([Guitar1_tab_notes3_1[4], Guitar1_tab_notes3_1[5], Guitar1_tab_notes3_1[6]]);
const Perc_beam1_1_3 = new VF.Beam([Perc_notes1_1[8], Perc_notes1_1[9], Perc_notes1_1[10], Perc_notes1_1[11]]);
 
const Perc_beam1_1_4 = new VF.Beam([Perc_notes1_1[12], Perc_notes1_1[13], Perc_notes1_1[14], Perc_notes1_1[15]]);
var Guitar1_tab_St3_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St3_1Voice.setStrict(true);
Guitar1_tab_St3_1Voice.addTickables(Guitar1_tab_notes3_1);


var Perc_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
var Guitar1_tab_St3_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Perc_St1_1Voice.setStrict(true);
Guitar1_tab_St3_2Voice.setStrict(true);
Perc_St1_1Voice.addTickables(Perc_notes1_1);
Guitar1_tab_St3_2Voice.addTickables(Guitar1_tab_notes3_2);


var formatterPerc_St1_1 = new Vex.Flow.Formatter().joinVoices([Perc_St1_1Voice]);
var formatterGuitar1_tab_St3_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_tab_St3_2Voice, Guitar1_tab_St3_1Voice]);
//formatterPerc_St1_1.formatToStave([stave17_1Voice], Perc_St1_1);
formatterGuitar1_tab_St3_1.format([Guitar1_tab_St3_2Voice, Guitar1_tab_St3_1Voice], nStaveWidth - 20);
formatterPerc_St1_1.format([Perc_St1_1Voice], nStaveWidth - 30);
Guitar1_tab_St3_1Voice.draw(ctx, Guitar1_Tab3);
Perc_St1_1Voice.draw(ctx, Perc_St1_1);
Guitar1_tab_St3_2Voice.draw(ctx, Guitar1_Tab3);


Perc_beam1_1_1.setContext(ctx).draw();
shiftGuitar1_tab3 = addShift(
Perc_beam1_1_2.setContext(ctx).draw();
  Guitar1_tab_notes3_1,
Perc_beam1_1_3.setContext(ctx).draw();
  [0, 1, 2, 3, 4, 5, 6, 7],
Perc_beam1_1_4.setContext(ctx).draw();
  [2, 2, 2, 2, 2, 4, 4, 4]
);


Perc_note1_1_0.x = Perc_notes1_1[0].getAbsoluteX();
Guitar1_tab_beam3_1.setContext(ctx).draw();
Perc_note1_1_0.y = Perc_notes1_1[0].getStave().getYForLine(1);
Guitar1_tab_beam3_2.setContext(ctx).draw();


shiftPerc1 = addShift(
var Guitar1_tab_vibrato3 = new VF.VibratoBracket({
   Perc_notes1_1,
   start: Guitar1_tab_notes3_1[7],
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
   stop: null,
   [4, 4, 4, 4, 4, 4, 4, 4, 4, 4,  4,  4,  4,  4,  4,  4]
});
);
Guitar1_tab_vibrato3.setLine(1);
Guitar1_tab_vibrato3.setHarsh(true);
Guitar1_tab_vibrato3.setContext(ctx).draw();


const Perc_St2 = new Stave(Perc_St1.width + Perc_St1.x, Perc_St1.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 2) continue;
  Perc_St2.setConfigForLine(i, {visible: false} );
}
Perc_St2.draw();


const Perc_St3 = new Stave(Perc_St2.width + Perc_St2.x, Perc_St2.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 2) continue;
  Perc_St3.setConfigForLine(i, {visible: false} );
}
Perc_St3.draw();


const Perc_St4 = new Stave(Perc_St3.width + Perc_St3.x, Perc_St3.y, nStaveWidth).setContext(ctx);
const Guitar1_Tab4 = new Stave(Guitar1_Tab3.width + Guitar1_Tab3.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
Guitar1_Tab4.draw();
  if (i == 2) continue;
  Perc_St4.setConfigForLine(i, {visible: false} );
}
Perc_St4.draw();


})();
const Guitar1_tab_gracenotes4 = [
  new VF.GraceNote({ keys: ['d/5'], duration: '8', slash: true })
];


const svgElement2 = document.querySelector('#yonet202403Mid_Output01 svg');
const Guitar1_tab_notes4_1 = [
svgElement2.style.backgroundColor = '#F5F5F5';
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
var svgContainer = document.getElementById('yonet202403Mid_Output01');
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
var svgElement = svgContainer.querySelector('svg');
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "4" }),
  new VF.StaveNote({ keys: ["b/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["b/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 }),
];
const Guitar1_tab_notes4_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),


var VocalText_options = {
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
    textContent: ["Vocal"], // 必須文字列
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
    strID: "VocalText", // 必須
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
    Stave_x: Vocal.x,
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
    Stave_y: Vocal.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(VocalText_options);


var EGuitarText_options = {
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
    textContent: ["E.Guitar1"], // 必須文字列
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
    strID: "EGuitarText", // 必須
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
    Stave_x: Guitar1Inst.x,
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
    Stave_y: Guitar1Inst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(EGuitarText_options);


var EGuitarTab_options = {
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
    textContent: [""], // 必須文字列
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
    strID: "EGuitarTab", // 必須
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
    Stave_x: Stave9Pos.x,
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
    Stave_y: Stave9Pos.y,
 
    Stave_x_Offset: 10,
];
    Stave_y_Offset: 80,
Guitar1_tab_notes4_1[3].addModifier(new VF.GraceNoteGroup(Guitar1_tab_gracenotes4, false), 0);
    fontFamily: "YonetMuFL, Arial",
};
insertTextToSVG(EGuitarTab_options);


var EGuitar2Text_options = {
SteveNoteUniqueIds = getUniqueStaveNotesIds(Guitar1_tab_notes4_1, [0, 1]);
    textContent: ["E.Guitar2"], // 必須文字列
allFlagUniqueIds = updateAllFlagUniqueIds(SteveNoteUniqueIds);
    strID: "EGuitar2Text", // 必須
    Stave_x: Guitar2Inst.x,
    Stave_y: Guitar2Inst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(EGuitar2Text_options);


var EGuitar2Tab_options = {
UniqueIds = getUniqueNoteheadIds(Guitar1_tab_notes4_1, [0, 1, 2, 3, 4, 5, 6, 7]);
    textContent: ["@"], // 必須文字列
allUniqueIds = updateAllUniqueIds(UniqueIds);
    strID: "EGuitar2Tab", // 必須
    Stave_x: Guitar2Tab1.x,
    Stave_y: Guitar2Tab1.y,
    Stave_x_Offset: 10,
    Stave_y_Offset: 80,
    fontFamily: "YonetMuFL, Arial",
};
insertTextToSVG(EGuitar2Tab_options);


var BaseText_options = {
const Guitar1_tab_beam4_1 = new VF.Beam([Guitar1_tab_notes4_1[2], Guitar1_tab_notes4_1[3]]);
    textContent: ["Base"], // 必須文字列
const Guitar1_tab_beam4_2 = new VF.Beam([Guitar1_tab_notes4_1[5], Guitar1_tab_notes4_1[6], Guitar1_tab_notes4_1[7]]);
    strID: "BaseText", // 必須
    Stave_x: BaseInst.x,
    Stave_y: BaseInst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(BaseText_options);


var BaseTab_options = {
var Guitar1_tab_St4_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
    textContent: ["@"], // 必須文字列
Guitar1_tab_St4_1Voice.setStrict(true);
    strID: "BaseTab", // 必須
Guitar1_tab_St4_1Voice.addTickables(Guitar1_tab_notes4_1);
    Stave_x: BaseTab1.x,
    Stave_y: BaseTab1.y,
    Stave_x_Offset: 10,
    Stave_y_Offset: 90,
    fontFamily: "YonetMuFL, Arial",
};
insertTextToSVG(BaseTab_options);


insertBaseEndBarPathToSVG(StaveBase1);
var Guitar1_tab_St4_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
insertBaseEndBarPathToSVG(StaveBase2);
Guitar1_tab_St4_2Voice.setStrict(true);
insertBaseEndBarPathToSVG(StaveBase3);
Guitar1_tab_St4_2Voice.addTickables(Guitar1_tab_notes4_2);
insertBaseEndBarPathToSVG(StaveBase4);


var DrumText_options = {
var formatterGuitar1_tab_St4_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_tab_St4_2Voice, Guitar1_tab_St4_1Voice]);
    textContent: ["Drum"], // 必須文字列
formatterGuitar1_tab_St4_1.format([Guitar1_tab_St4_2Voice, Guitar1_tab_St4_1Voice], nStaveWidth - 20);
    strID: "DrumText", // 必須
Guitar1_tab_St4_1Voice.draw(ctx, Guitar1_Tab4);
    Stave_x: DrumInst.x,
Guitar1_tab_St4_2Voice.draw(ctx, Guitar1_Tab4);
    Stave_y: DrumInst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(DrumText_options);


var PercText_options = {
shiftGuitar1_tab4 = addShift(
    textContent: ["Perc."], // 必須文字列
  Guitar1_tab_notes4_1,
    strID: "PercText", // 必須
  [0, 1, 2, 3, 3, 4, 5, 6, 7, 7],
    Stave_x: PercInst.x,
  [2, 2, 2, 2, 2, 2, 1, 1, 1, 1]
    Stave_y: PercInst.y,
);
    fontFamily: "Arial, sans-serif",
 
    fontSize: "20pt",
shiftGuitar1_tab4_tr = addShift(
    Rotate: -90
  Guitar1_tab_notes4_1,  
};
  [0, 1],
insertTextToSVG(PercText_options);
  [3, 2.5]
);
 
Guitar1_tab_beam4_1.setContext(ctx).draw();
Guitar1_tab_beam4_2.setContext(ctx).draw();


var note13_2_0_option = {
    textContent: ["\uFF65", "\uFF65", "\uFF65", "\uFF65",
                  "\uFF65", "\uFF68", "\uFF66", "\uFF67", "\uFF65", "\uFF0B", "\uFF65", "\uFF0F"], // 必須文字列
                //x      ,  half_o,        ,        >,        ,      + ,        ,        o
    strID: "note13_2_0", // 必須
    Stave_y_Offset: [  -5,      -5,      -5,      -5,
                        -5,      -60,      -5,      -60,      -5,      -60,      -5,      -60],
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: shiftDrum1, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(note13_2_0_option);


var Perc_notes1_1_0_Shaker_option = {
const Guitar2_St1 = new Stave(Guitar1_Tab1.x, Guitar1_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
    textContent: ["< Shaker >"], // 必須文字列
Guitar2_St1.addClef("treble").setContext(ctx);
    strID: "Perc_notes1_1_0_shaker", // 必須
Guitar2_St1.addTimeSignature('4/4').setContext(ctx);
    Stave_x: Perc_note1_1_0.x,
Guitar2_St1.addKeySignature('D').setContext(ctx);
    Stave_y: Perc_note1_1_0.y,
Guitar2_St1.draw();
    Stave_x_Offset: -20,
 
    Stave_y_Offset: 0,
const Guitar2_St2 = new Stave(Guitar2_St1.width + Guitar2_St1.x, Guitar2_St1.y, nStaveWidth).setContext(ctx);
    fontSize: 60,
Guitar2_St2.draw();
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: [0] // xのオフセット値配列
};
insertTextToSVG(Perc_notes1_1_0_Shaker_option);


var Perc_notes1_1_0_option = {
const Guitar2_St3 = new Stave(Guitar2_St2.width + Guitar2_St2.x, Guitar2_St2.y, nStaveWidth).setContext(ctx);
    textContent: ["\uFF69"], // 必須文字列
Guitar2_St3.draw();
    strID: "Perc_notes1_1_0", // 必須
    Stave_y_Offset: -5,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: shiftPerc1, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Perc_notes1_1_0_option);


// 透明にするIDの配列
const Guitar2_St4 = new Stave(Guitar2_St3.width + Guitar2_St3.x, Guitar2_St3.y, nStaveWidth).setContext(ctx);
// 例としてここでIDを指定
Guitar2_St4.draw();
let autoUniqueIds = allUniqueIds.map(id => "vf-" + id);


// 各IDに対して処理
const Guitar2_Tab1 = new Stave(Guitar2_St1.x, Guitar2_St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
autoUniqueIds.forEach(id => {
Guitar2_Tab1.draw();
    // 該当するIDの要素を取得
 
    let element = svgElement.getElementById(id);
Guitar2Tab1.x = Guitar2_Tab1.x;
    if (element) {
Guitar2Tab1.y = Guitar2_Tab1.y;
        // 該当する要素があれば、描画内容を透明にする
        let paths = element.querySelectorAll("path");
        paths.forEach(path => {
            path.setAttribute("fill", "none");
            path.setAttribute("stroke", "none");
        });
    }
});


})();
const Guitar2_Tab2 = new Stave(Guitar2_Tab1.width + Guitar2_Tab1.x, Guitar2_Tab1.y, nStaveWidth).setContext(ctx);
</yjavascript>
Guitar2_Tab2.draw();


const Guitar2_Tab3 = new Stave(Guitar2_Tab2.width + Guitar2_Tab2.x, Guitar2_Tab2.y, nStaveWidth).setContext(ctx);
Guitar2_Tab3.draw();


 コードは以下のとおりです。
const Guitar2_Tab4 = new Stave(Guitar2_Tab3.width + Guitar2_Tab3.x, Guitar2_Tab3.y, nStaveWidth).setContext(ctx);
Guitar2_Tab4.draw();


var Guitar2_connect = new VF.StaveConnector(Guitar2_St1, Guitar2_Tab1);
Guitar2_connect.setType(VF.StaveConnector.type.BRACKET);
Guitar2_connect.setContext(ctx);
Guitar2_connect.draw();


<syntaxhighlight lang="javascript" line start="1" highlight="">
const Guitar2_Tab1_tab = new Stave(Guitar2_Tab1.x, Guitar2_Tab1.y - 10, nHeadMargin + nStaveWidth).setContext(ctx);
<div id="yonet202403Mid_Output01"></div>
for (var i = 0; i < 5; i++) {
<script>
   if (i == 0) continue;
///////////////////////
  Guitar2_Tab1_tab.setConfigForLine(i, {visible: false} );
(function(){
class Position {
   constructor(x = 0, y = 0) {
    this.x = x;
    this.y = y;
  }
}
}
var VF = Vex.Flow;
Guitar2_Tab1_tab.draw();
const Vocal = new Position();
const Guitar1Inst = new Position();
const Guitar2Inst = new Position();
const Guitar2Tab1 = new Position();
const BaseInst = new Position();
const BaseTab1 = new Position();
const DrumInst = new Position();
const PercInst = new Position();
const Stave9Pos = new Position();


var StaveBase1;
const Guitar2_Tab2_tab = new Stave(Guitar2_Tab1_tab.width + Guitar2_Tab1_tab.x, Guitar2_Tab1_tab.y, nStaveWidth).setContext(ctx);
var StaveBase2;
for (var i = 0; i < 5; i++) {
var StaveBase3;
  if (i == 0) continue;
var StaveBase4;
  Guitar2_Tab2_tab.setConfigForLine(i, {visible: false} );
}
Guitar2_Tab2_tab.draw();


const Perc_note1_1_0 = new Position();
const Guitar2_Tab3_tab = new Stave(Guitar2_Tab2_tab.width + Guitar2_Tab2_tab.x, Guitar2_Tab2_tab.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar2_Tab3_tab.setConfigForLine(i, {visible: false} );
}
Guitar2_Tab3_tab.draw();


var shiftDrum1;
const Guitar2_Tab4_tab = new Stave(Guitar2_Tab3_tab.width + Guitar2_Tab3_tab.x, Guitar2_Tab3_tab.y, nStaveWidth).setContext(ctx);
var shiftPerc1;
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar2_Tab4_tab.setConfigForLine(i, {visible: false} );
}
Guitar2_Tab4_tab.draw();
 
Guitar2Inst.x = Guitar2_St1.x - 30;
Guitar2Inst.y = Guitar2_St1.y + ((Guitar2_Tab1.y - Guitar2_St1.y) / 2) + 90;  


function insertBaseEndBarPathToSVG(Stave) {
const Base_St1 = new Stave(Guitar2_Tab1.x, Guitar2_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
  var newGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g');
Base_St1.addClef("bass").setContext(ctx);
  newGroup.setAttribute('transform', 'translate(0, 0)');
Base_St1.addTimeSignature('4/4').setContext(ctx);
  var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
Base_St1.addKeySignature('D').setContext(ctx);
  var pathStr = 'M ' + (Stave.x + Stave.width) + ' ' + (Stave.y + 50) +
Base_St1.draw();
    ' L ' + (Stave.x + Stave.width) + ' ' + (Stave.y + 80);
  path.setAttribute('d', pathStr);
  path.setAttribute('stroke', 'black');
  path.setAttribute('stroke-width', '1');
  path.setAttribute('fill', 'none');
  newGroup.appendChild(path);
  svgElement.appendChild(newGroup);
}


function insertTextToSVG(options) {
const Base_St2 = new Stave(Base_St1.width + Base_St1.x, Base_St1.y, nStaveWidth).setContext(ctx);
    var textContent = options.textContent;
Base_St2.draw();
    var strID = options.strID;
 
    var Stave_x = options.Stave_x || 0;
const Base_St3 = new Stave(Base_St2.width + Base_St2.x, Base_St2.y, nStaveWidth).setContext(ctx);
    var Stave_y = options.Stave_y || 0;
Base_St3.draw();
    var isOffset_x_abs = options.IsOffset_x_Abs || false;
    var Stave_x_Offset = options.Stave_x_Offset || 0;
    var Stave_y_Offset = options.Stave_y_Offset || 0;
    var StaveWidth = options.StaveWidth || 0;
    var StaveHeight = options.StaveHeight || 0;
    var StaveVerticalScale = options.StaveVerticalScale || 0;
    var fontSize = options.fontSize || 40;
    var fontFamily = options.fontFamily || "Bravura, Arial";
    var shift_x = options.shift_x || [0];
    var Rotate = options.Rotate || 0;
    var offset_sum = 0;
    var Stave_x_Offset_Value = 0;
    var Stave_y_Offset_Value = 0;
    var last_Stave_x_Offset = 0;
    var last_Stave_y_Offset = 0;
    var last_textContent = "";
    shift_x.forEach(function(offset, index) {
        offset_sum = offset_sum + offset;
        var newText = document.createElementNS('http://www.w3.org/2000/svg', 'text');
        newText.setAttribute('id', strID + '_' + index); // テキスト要素にIDを付ける
        newText.setAttribute('x', 0);
        newText.setAttribute('y', 0);
        newText.setAttribute('font-family', fontFamily);
        newText.setAttribute('font-size', fontSize);
        newText.setAttribute('fill', 'black');


        if(typeof textContent === "string"){
const Base_St4 = new Stave(Base_St3.width + Base_St3.x, Base_St3.y, nStaveWidth).setContext(ctx);
          newText.textContent = textContent;
Base_St4.draw();
        }
        else{
          if(textContent.length - 1 < index){
            newText.textContent = last_textContent;
          }
          else{
            newText.textContent = textContent[index];
            last_textContent = textContent[index];
          }
        }


        if(Stave_x_Offset.length - 1 < index){
const Base_Tab1 = new Stave(Base_St1.x, Base_St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
          Stave_x_Offset_Value = last_Stave_x_Offset;
Base_Tab1.setEndBarType(VF.Barline.type.NONE);
        }
for (var i = 0; i < 5; i++) {
        else{
  if (i != 0) continue;
          if(Stave_x_Offset.length >= 2){
  Base_Tab1.setConfigForLine(i, {visible: false} );
            Stave_x_Offset_Value = Stave_x_Offset[index];
}
            last_Stave_x_Offset = Stave_x_Offset[index];
Base_Tab1.draw();
          }
          else{
            Stave_x_Offset_Value = Stave_x_Offset;
          }
        }


        if(Stave_y_Offset.length - 1 < index){
BaseTab1.x = Base_Tab1.x;
          Stave_y_Offset_Value = last_Stave_y_Offset;
BaseTab1.y = Base_Tab1.y;
        }
 
        else{
BaseInst.x = Base_St1.x - 30;
          if(Stave_y_Offset.length >= 2){
BaseInst.y = Base_St1.y + ((Base_Tab1.y - Base_St1.y) / 2) + 90;  
            Stave_y_Offset_Value = Stave_y_Offset[index];
 
            last_Stave_y_Offset = Stave_y_Offset[index];
StaveBase1 = Base_Tab1;
          }
 
          else{
const Base_Tab2 = new Stave(Base_Tab1.width + Base_Tab1.x, Base_Tab1.y, nStaveWidth).setContext(ctx);
            Stave_y_Offset_Value = Stave_y_Offset;
Base_Tab2.setBegBarType(VF.Barline.type.NONE);
          }
Base_Tab2.setEndBarType(VF.Barline.type.NONE);
        }
for (var i = 0; i < 5; i++) {
        var textGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g');
  if (i != 0) continue;
        if(Rotate != 0){
  Base_Tab2.setConfigForLine(i, {visible: false} );
          textGroup.setAttribute('transform', 'rotate(' + Rotate + ' ' + 0 + ' ' + 0 + ')');
}
          textGroup.appendChild(newText);
Base_Tab2.draw();
          svgElement.appendChild(textGroup);
 
        }
StaveBase2 = Base_Tab2;
        else{
          svgElement.appendChild(newText);
        }
        (function() {
            var textWidth = newText.getBBox().width;
            var textHeight = newText.getBBox().height;
            var horizontalScale;
            if (typeof StaveWidth === 'undefined' || StaveWidth == 0) {
                horizontalScale = 1;
            }
            else {
                horizontalScale = StaveWidth / textWidth;
            }
            var verticalScale;
            if (typeof StaveHeight === 'undefined' || StaveHeight == 0) {
                verticalScale = 1;
            }
            else if (StaveVerticalScale != 0) {
                verticalScale = StaveVerticalScale;
            }  
            else {
                verticalScale = StaveHeight / textHeight;
            }
            if(isOffset_x_abs){
              var StavePos_x = offset.x + Stave_x_Offset_Value;
              var StavePos_y = offset.y + Stave_y_Offset_Value;
            }
            else{
              var StavePos_x = Stave_x + Stave_x_Offset + offset_sum;
              var StavePos_y = Stave_y + Stave_y_Offset;
            }


            newText.setAttribute('transform', 'translate(' + StavePos_x + ',' + StavePos_y + ') scale(' + horizontalScale + ',' + verticalScale + ')');
const Base_Tab3 = new Stave(Base_Tab2.width + Base_Tab2.x, Base_Tab2.y, nStaveWidth).setContext(ctx);
Base_Tab3.setBegBarType(VF.Barline.type.NONE);
Base_Tab3.setEndBarType(VF.Barline.type.NONE);
for (var i = 0; i < 5; i++) {
  if (i != 0) continue;
  Base_Tab3.setConfigForLine(i, {visible: false} );
}
Base_Tab3.draw();


            if(Rotate != 0){
StaveBase3 = Base_Tab3;
              textGroup.setAttribute('transform', 'rotate(' + Rotate + ' ' + StavePos_x + ' ' + StavePos_y + ')');
            }
        })();


        if(Rotate != 0){
const Base_Tab4 = new Stave(Base_Tab3.width + Base_Tab3.x, Base_Tab3.y, nStaveWidth).setContext(ctx);
          textGroup.appendChild(newText);
Base_Tab4.setBegBarType(VF.Barline.type.NONE);
          svgElement.appendChild(textGroup);
Base_Tab4.setEndBarType(VF.Barline.type.NONE);
        }
for (var i = 0; i < 5; i++) {
        else{
  if (i != 0) continue;
          svgElement.appendChild(newText);
  Base_Tab4.setConfigForLine(i, {visible: false} );
        }
    });
}
}
Base_Tab4.draw();
StaveBase4 = Base_Tab4;


var allUniqueIds = [];
var Base_connect = new VF.StaveConnector(Base_St1, Base_Tab1);
(function(){
Base_connect.setType(VF.StaveConnector.type.BRACKET);
function addShift(notes, arrx = [], arry = []) {
Base_connect.setContext(ctx);
Base_connect.draw();
  let tempnote;
  let retShift = [];
 
  for(let i = 0; i < arrx.length || i == 0; i++){
    const pos = new Position();
    //notesのchildrenの各要素について処理
    if(arrx.length === 0){
      tempnote = notes;
    }
    else{
      tempnote = notes[arrx[i]];
      temp_y = arry[i];
    }
    pos.x = tempnote.getAbsoluteX();
    pos.y = tempnote.getStave().getYForLine(temp_y);


    retShift.push(pos);
const Drum_St1 = new Stave(Base_Tab1.x, Base_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
  }
Drum_St1.addClef("bass").setContext(ctx);
  return retShift;
Drum_St1.addTimeSignature('4/4').setContext(ctx);
}
Drum_St1.draw();


var UniqueIds;
DrumInst.x = Drum_St1.x - 30;
function getUniqueNoteheadIds(notes, arr = []) {
DrumInst.y = Drum_St1.y + 90;  
    //すべてのidを格納するためのセットを作成
    let tempnote;
    uniqueIds = new Set();
    for(let i = 0; i < arr.length || i == 0; i++){
    //notesのchildrenの各要素について処理
      if(arr.length === 0){
        tempnote = notes;
      }
      else{
        tempnote = notes[arr[i]];
      }
      tempnote.children.forEach(child => {
        //typeが"notehead"であるかチェックし、idを取得
        if (child.attrs){
          if(child.attrs.type === "NoteHead") {
            uniqueIds.add(child.attrs.id);
          }
        }
      });
    }
    // セットを配列に変換して戻り値として返す
    return Array.from(uniqueIds);
}


function updateAllUniqueIds(UniqueIds) {
const Drum_St1_1 = new Stave(nHeadMargin + Base_Tab1.x, Base_Tab1.y + 120, 0).setContext(ctx);
    // allUniqueIdsにUniqueIdsを追加または結合
Drum_St1_1.setBegBarType(VF.Barline.type.NONE);
    if (allUniqueIds.length === 0) {//allUniqueIdsはグローバルな変数
Drum_St1_1.setEndBarType(VF.Barline.type.NONE);
      // allUniqueIdsが空の場合、UniqueIdsをそのままコピー
Drum_St1_1.draw();
      allUniqueIds = [...UniqueIds];//スプレッド演算子で要素の中身を書き出す。
 
    } else {
const Drum_notes1_1 = [
      UniqueIds.forEach(id => {
  new StaveNote({ keys: ["f/4"], duration: "4", stem_direction: -1 }),
        if (!allUniqueIds.includes(id)) {
  new StaveNote({ keys: ["c/4"], duration: "4r" }),
            allUniqueIds.push(id);
  new StaveNote({ keys: ["c/4"], duration: "8r" }),
        }
  new StaveNote({ keys: ["f/4"], duration: "8", stem_direction: -1 }),
      });
  new StaveNote({ keys: ["c/4"], duration: "8r" }),
    }
  new StaveNote({ keys: ["f/4"], duration: "8", stem_direction: -1 })
    // 更新されたallUniqueIdsを戻り値として返す
];
    return allUniqueIds;
const Drum_beam1_1 = new VF.Beam([Drum_notes1_1[3],Drum_notes1_1[5]]);
}


function dotted(staveNote, noteIndex = -1) {
var Drum_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
  if (noteIndex < 0) {
Drum_St1_1Voice.setStrict(true);
    Dot.buildAndAttach([staveNote], {
Drum_St1_1Voice.addTickables(Drum_notes1_1);
      all: true
    });
  }
  else {
    for(noteIndexValue of noteIndex){
      Dot.buildAndAttach([staveNote], {
        index: noteIndexValue
      });
    }
  }
  return staveNote;
}


const {
const Drum_St1_2 = new Stave(nHeadMargin + Base_Tab1.x, Base_Tab1.y + 120, 0).setContext(ctx);
  Factory,
Drum_St1_2.setBegBarType(VF.Barline.type.NONE);
  Stave,
Drum_St1_2.setEndBarType(VF.Barline.type.NONE);
  StaveNote,
Drum_St1_2.draw();
  Formatter,
  Voice,
  StaveTie,
  BarLine,
  Beam,
  Dot,
  StaveConnector,
  Modifier,
  RenderContext,
  TextDynamics,
  Articulation,
  TextNote,
  Crescendo,
  Renderer
} = Vex.Flow;


let nscale = 0.64;
const Drum_notes1_2 = [
let nwidth = 1040;
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
let nheight = 1120;
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "16", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "16", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 })
];


let nHeadMargin = 70;
const Drum_notes1_3 = [
let nStaveWidth = 350;
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),


const f = new Factory({  
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
   renderer: { elementId: 'yonet202403Mid_Output01', width: nwidth, height: nheight * nscale }
   new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
   });
   new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
const ctx = f.getContext();
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
ctx.scale(nscale, nscale);


const defaultStyle = {
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
   lineWidth: ctx.lineWidth,
   new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
   strokeStyle: ctx.strokeStyle,
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
};
   new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
 
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 })
];


for (let i = 0; i <= nwidth * (1 / nscale); i += 10) {
UniqueIds = getUniqueNoteheadIds(Drum_notes1_2, [0, 1, 3, 5, 6, 8]);
  ctx.beginPath();
allUniqueIds = updateAllUniqueIds(UniqueIds);
  ctx.moveTo(0 + i, 0);
  ctx.lineTo(0 + i, nheight);
  if (i % 100 === 0){
    ctx.setLineWidth(1);
    ctx.setStrokeStyle('rgba(200, 200, 200, 0.8)');
  }
  else{
    ctx.setLineWidth(0.5);
    ctx.setStrokeStyle('rgba(230, 230, 230, 0.8)');
  }
  ctx.stroke();
}


for (let i = 0; i <= nheight; i += 10) {
const Drum_beam1_2_1 = new VF.Beam([Drum_notes1_2[0], Drum_notes1_2[1]]);
  ctx.beginPath();
const Drum_beam1_2_2 = new VF.Beam([Drum_notes1_2[2], Drum_notes1_2[3], Drum_notes1_2[4]]);
  ctx.moveTo(0, i);
const Drum_beam1_2_3 = new VF.Beam([Drum_notes1_2[5], Drum_notes1_2[6], Drum_notes1_2[7], Drum_notes1_2[8]]);
  ctx.lineTo(nwidth * (1 / nscale), i);
  if (i % 100 === 0){
    ctx.setLineWidth(1);
    ctx.setStrokeStyle('rgba(200, 200, 200, 0.8)');
  }
  else{
    ctx.setLineWidth(0.5);
    ctx.setStrokeStyle('rgba(230, 230, 230, 0.8)');
  }
  ctx.stroke();
}


ctx.lineWidth = defaultStyle.lineWidth;
var Drum_St1_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
ctx.strokeStyle = defaultStyle.strokeStyle;
Drum_St1_2Voice.setStrict(true);
Drum_St1_2Voice.addTickables(Drum_notes1_2);


const VocalSt1 = new Stave(80, 30, nHeadMargin + nStaveWidth).setContext(ctx);
var Drum_St1_3Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
VocalSt1.setClef("treble").setContext(ctx);
Drum_St1_3Voice.setStrict(true);
VocalSt1.setTimeSignature('4/4').setContext(ctx);
Drum_St1_3Voice.addTickables(Drum_notes1_3);
VocalSt1.setMeasure(1);
VocalSt1.draw();


Vocal.x = VocalSt1.x - 30;
var formatterDrum_St1_2 = new Vex.Flow.Formatter().joinVoices([Drum_St1_3Voice, Drum_St1_1Voice, Drum_St1_2Voice]);
Vocal.y = VocalSt1.y + 90;  
//formatter13_2.formatToStave([stave13_3Voice, stave13_1Voice, stave13_2Voice], stave13_2);
formatterDrum_St1_2.format([Drum_St1_3Voice, Drum_St1_1Voice, Drum_St1_2Voice], nStaveWidth - 30);
Drum_St1_1Voice.draw(ctx, Drum_St1_2);
Drum_St1_2Voice.draw(ctx, Drum_St1_2);


const VocalSt2 = f.Stave({ x: VocalSt1.width + VocalSt1.x, y: VocalSt1.y, width: nStaveWidth });
Drum_beam1_1.setContext(ctx).draw();
VocalSt2.setMeasure(2);
VocalSt2.setContext(ctx).draw();


const VocalSt3 = new Stave(VocalSt2.width + VocalSt2.x, VocalSt1.y, nStaveWidth).setContext(ctx);
Drum_beam1_2_1.setContext(ctx).draw();
VocalSt3.setMeasure(3);
Drum_beam1_2_2.setContext(ctx).draw();
VocalSt3.draw();
Drum_beam1_2_3.setContext(ctx).draw();


const VocalSt4 = new Stave(VocalSt3.width + VocalSt3.x, VocalSt1.y, nStaveWidth).setContext(ctx);
shiftDrum1 = addShift(
VocalSt4.setMeasure(4);
  Drum_notes1_2,
VocalSt4.draw();
  [0, 1, 2, 3, 5, 5, 6, 6, 7, 7, 8, 8],
  [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
);


const Guitar1St1 = new Stave(VocalSt1.x, VocalSt1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Guitar1St1.addClef("treble").setContext(ctx);
Guitar1St1.addTimeSignature('4/4').setContext(ctx);
Guitar1St1.draw();


const Guitar1St2 = new Stave(Guitar1St1.width + Guitar1St1.x, Guitar1St1.y, nStaveWidth).setContext(ctx);
const Drum_St2 = new Stave(Drum_St1.width + Drum_St1.x, Drum_St1.y, nStaveWidth).setContext(ctx);
Guitar1St2.draw();
Drum_St2.draw();


const Guitar1St3 = new Stave(Guitar1St2.width + Guitar1St2.x, Guitar1St1.y, nStaveWidth).setContext(ctx);
Guitar1St3.draw();


const Guitar1St4 = new Stave(Guitar1St3.width + Guitar1St3.x, Guitar1St1.y, nStaveWidth).setContext(ctx);
const Drum_St3 = new Stave(Drum_St2.width + Drum_St2.x, Drum_St1.y, nStaveWidth).setContext(ctx);
Guitar1St4.draw();
Drum_St3.draw();


const Guitar1_tab1 = new Stave(Guitar1St1.x, Guitar1St1.y + 110, nHeadMargin + nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar1_tab1.setConfigForLine(i, {visible: false} );
}
Guitar1_tab1.draw();


const Guitar1_tab2 = new Stave(Guitar1_tab1.width + Guitar1_tab1.x, Guitar1_tab1.y, nStaveWidth).setContext(ctx);
const Drum_St4 = new Stave(Drum_St3.width + Drum_St3.x, Drum_St1.y, nStaveWidth).setContext(ctx);
Drum_St4.draw();
 
 
const Perc_St1 = new Stave(Drum_St1.x, Drum_St1.y + 100, nHeadMargin + nStaveWidth).setContext(ctx);
Perc_St1.addTimeSignature('4/4').setContext(ctx);
 
const Perc_St1_1 = new Stave(nHeadMargin + Drum_St1.x, Drum_St1.y + 100, 0).setContext(ctx);
Perc_St1_1.setBegBarType(VF.Barline.type.NONE);
Perc_St1_1.setEndBarType(VF.Barline.type.NONE);
Perc_St1_1.draw();
 
for (var i = 0; i < 5; i++) {
for (var i = 0; i < 5; i++) {
   if (i == 0) continue;
   if (i == 2) continue;
   Guitar1_tab2.setConfigForLine(i, {visible: false} );
   Perc_St1.setConfigForLine(i, {visible: false} );
}
}
Guitar1_tab2.draw();


const Guitar1_tab3 = new Stave(Guitar1_tab2.width + Guitar1_tab2.x, Guitar1_tab1.y, nStaveWidth).setContext(ctx);
Perc_St1.draw();
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar1_tab3.setConfigForLine(i, {visible: false} );
}
Guitar1_tab3.draw();


const Guitar1_tab4 = new Stave(Guitar1_tab3.width + Guitar1_tab3.x, Guitar1_tab1.y, nStaveWidth).setContext(ctx);
PercInst.x = Perc_St1.x - 30;
for (var i = 0; i < 5; i++) {
PercInst.y = Perc_St1.y + 90;  
  if (i == 0) continue;
  Guitar1_tab4.setConfigForLine(i, {visible: false} );
}
Guitar1_tab4.draw();


const Guitar1_Tab1 = new Stave(Guitar1St1.x, Guitar1St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
var AllConnector = new VF.StaveConnector(VocalSt1, Perc_St1);
Guitar1_Tab1.draw();
AllConnector.setType(VF.StaveConnector.type.SINGLE);
AllConnector.setContext(ctx);
AllConnector.draw();


Stave9Pos.x = Guitar1_Tab1.x;
const Perc_notes1_1 = [
Stave9Pos.y = Guitar1_Tab1.y;
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),


var connector9_2 = new VF.StaveConnector(Guitar1St1, Guitar1_Tab1);
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
connector9_2.setType(VF.StaveConnector.type.BRACKET);
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
connector9_2.setContext(ctx);
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
connector9_2.draw();
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),


Guitar1Inst.x = VocalSt1.x - 30;
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
Guitar1Inst.y = Guitar1St1.y + ((Guitar1_Tab1.y - Guitar1St1.y) / 2) + 90;
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),


const Guitar1_Tab2 = new Stave(Guitar1_Tab1.width + Guitar1_Tab1.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
Guitar1_Tab2.draw();
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 })
];
UniqueIds = getUniqueNoteheadIds(Perc_notes1_1, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
allUniqueIds = updateAllUniqueIds(UniqueIds);


const Guitar1_Tab3 = new Stave(Guitar1_Tab2.width + Guitar1_Tab2.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
const Perc_beam1_1_1 = new VF.Beam([Perc_notes1_1[0], Perc_notes1_1[1], Perc_notes1_1[2], Perc_notes1_1[3]]);
Guitar1_Tab3.draw();
const Perc_beam1_1_2 = new VF.Beam([Perc_notes1_1[4], Perc_notes1_1[5], Perc_notes1_1[6], Perc_notes1_1[7]]);
const Perc_beam1_1_3 = new VF.Beam([Perc_notes1_1[8], Perc_notes1_1[9], Perc_notes1_1[10], Perc_notes1_1[11]]);
const Perc_beam1_1_4 = new VF.Beam([Perc_notes1_1[12], Perc_notes1_1[13], Perc_notes1_1[14], Perc_notes1_1[15]]);


const Guitar1_Tab4 = new Stave(Guitar1_Tab3.width + Guitar1_Tab3.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
var Perc_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_Tab4.draw();
Perc_St1_1Voice.setStrict(true);
Perc_St1_1Voice.addTickables(Perc_notes1_1);


const Guitar2_St1 = new Stave(Guitar1_Tab1.x, Guitar1_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
var formatterPerc_St1_1 = new Vex.Flow.Formatter().joinVoices([Perc_St1_1Voice]);
Guitar2_St1.addClef("treble").setContext(ctx);
//formatterPerc_St1_1.formatToStave([stave17_1Voice], Perc_St1_1);
Guitar2_St1.addTimeSignature('4/4').setContext(ctx);
formatterPerc_St1_1.format([Perc_St1_1Voice], nStaveWidth - 30);
Guitar2_St1.draw();
Perc_St1_1Voice.draw(ctx, Perc_St1_1);


const Guitar2_St2 = new Stave(Guitar2_St1.width + Guitar2_St1.x, Guitar2_St1.y, nStaveWidth).setContext(ctx);
Perc_beam1_1_1.setContext(ctx).draw();
Guitar2_St2.draw();
Perc_beam1_1_2.setContext(ctx).draw();
Perc_beam1_1_3.setContext(ctx).draw();
Perc_beam1_1_4.setContext(ctx).draw();


const Guitar2_St3 = new Stave(Guitar2_St2.width + Guitar2_St2.x, Guitar2_St2.y, nStaveWidth).setContext(ctx);
Perc_note1_1_0.x = Perc_notes1_1[0].getAbsoluteX();
Guitar2_St3.draw();
Perc_note1_1_0.y = Perc_notes1_1[0].getStave().getYForLine(1);


const Guitar2_St4 = new Stave(Guitar2_St3.width + Guitar2_St3.x, Guitar2_St3.y, nStaveWidth).setContext(ctx);
shiftPerc1 = addShift(
Guitar2_St4.draw();
  Perc_notes1_1,
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
  [4, 4, 4, 4, 4, 4, 4, 4, 4, 4,  4,  4,  4,  4,  4,  4]
);


const Guitar2_Tab1 = new Stave(Guitar2_St1.x, Guitar2_St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
const Perc_St2 = new Stave(Perc_St1.width + Perc_St1.x, Perc_St1.y, nStaveWidth).setContext(ctx);
Guitar2_Tab1.draw();
for (var i = 0; i < 5; i++) {
  if (i == 2) continue;
  Perc_St2.setConfigForLine(i, {visible: false} );
}
Perc_St2.draw();


Guitar2Tab1.x = Guitar2_Tab1.x;
const Perc_St3 = new Stave(Perc_St2.width + Perc_St2.x, Perc_St2.y, nStaveWidth).setContext(ctx);
Guitar2Tab1.y = Guitar2_Tab1.y;
for (var i = 0; i < 5; i++) {
  if (i == 2) continue;
  Perc_St3.setConfigForLine(i, {visible: false} );
}
Perc_St3.draw();


const Guitar2_Tab2 = new Stave(Guitar2_Tab1.width + Guitar2_Tab1.x, Guitar2_Tab1.y, nStaveWidth).setContext(ctx);
const Perc_St4 = new Stave(Perc_St3.width + Perc_St3.x, Perc_St3.y, nStaveWidth).setContext(ctx);
Guitar2_Tab2.draw();
 
const Guitar2_Tab3 = new Stave(Guitar2_Tab2.width + Guitar2_Tab2.x, Guitar2_Tab2.y, nStaveWidth).setContext(ctx);
Guitar2_Tab3.draw();
 
const Guitar2_Tab4 = new Stave(Guitar2_Tab3.width + Guitar2_Tab3.x, Guitar2_Tab3.y, nStaveWidth).setContext(ctx);
Guitar2_Tab4.draw();
 
var Guitar2_connect = new VF.StaveConnector(Guitar2_St1, Guitar2_Tab1);
Guitar2_connect.setType(VF.StaveConnector.type.BRACKET);
Guitar2_connect.setContext(ctx);
Guitar2_connect.draw();
 
const Guitar2_Tab1_tab = new Stave(Guitar2_Tab1.x, Guitar2_Tab1.y - 10, nHeadMargin + nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
for (var i = 0; i < 5; i++) {
   if (i == 0) continue;
   if (i == 2) continue;
   Guitar2_Tab1_tab.setConfigForLine(i, {visible: false} );
   Perc_St4.setConfigForLine(i, {visible: false} );
}
}
Guitar2_Tab1_tab.draw();
Perc_St4.draw();


const Guitar2_Tab2_tab = new Stave(Guitar2_Tab1_tab.width + Guitar2_Tab1_tab.x, Guitar2_Tab1_tab.y, nStaveWidth).setContext(ctx);
})();
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar2_Tab2_tab.setConfigForLine(i, {visible: false} );
}
Guitar2_Tab2_tab.draw();


const Guitar2_Tab3_tab = new Stave(Guitar2_Tab2_tab.width + Guitar2_Tab2_tab.x, Guitar2_Tab2_tab.y, nStaveWidth).setContext(ctx);
const svgElement2 = document.querySelector('#yonet202403Mid_Output01 svg');
for (var i = 0; i < 5; i++) {
svgElement2.style.backgroundColor = '#F5F5F5';
  if (i == 0) continue;
var svgContainer = document.getElementById('yonet202403Mid_Output01');
  Guitar2_Tab3_tab.setConfigForLine(i, {visible: false} );
var svgElement = svgContainer.querySelector('svg');
}
Guitar2_Tab3_tab.draw();


const Guitar2_Tab4_tab = new Stave(Guitar2_Tab3_tab.width + Guitar2_Tab3_tab.x, Guitar2_Tab3_tab.y, nStaveWidth).setContext(ctx);
var VocalText_options = {
for (var i = 0; i < 5; i++) {
    textContent: ["Vocal"], // 必須文字列
  if (i == 0) continue;
    strID: "VocalText", // 必須
  Guitar2_Tab4_tab.setConfigForLine(i, {visible: false} );
    Stave_x: Vocal.x,
}
    Stave_y: Vocal.y,
Guitar2_Tab4_tab.draw();
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(VocalText_options);


Guitar2Inst.x = Guitar2_St1.x - 30;
var EGuitarText_options = {
Guitar2Inst.y = Guitar2_St1.y + ((Guitar2_Tab1.y - Guitar2_St1.y) / 2) + 90;
    textContent: ["E.Guitar1"], // 必須文字列
 
    strID: "EGuitarText", // 必須
const Base_St1 = new Stave(Guitar2_Tab1.x, Guitar2_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
    Stave_x: Guitar1Inst.x,
Base_St1.addClef("treble").setContext(ctx);
    Stave_y: Guitar1Inst.y,
Base_St1.addTimeSignature('4/4').setContext(ctx);
    fontFamily: "Arial, sans-serif",
Base_St1.draw();
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(EGuitarText_options);


const Base_St2 = new Stave(Base_St1.width + Base_St1.x, Base_St1.y, nStaveWidth).setContext(ctx);
var EGuitarTab_options = {
Base_St2.draw();
    textContent: ["@"], // 必須文字列
    strID: "EGuitarTab", // 必須
    Stave_x: Stave9Pos.x,
    Stave_y: Stave9Pos.y,
    Stave_x_Offset: 10,
    Stave_y_Offset: 80,
    fontFamily: "YonetMuFL, Arial",
};
insertTextToSVG(EGuitarTab_options);


const Base_St3 = new Stave(Base_St2.width + Base_St2.x, Base_St2.y, nStaveWidth).setContext(ctx);
insertTrilPathToSVG(shiftGuitar1_1);
Base_St3.draw();


const Base_St4 = new Stave(Base_St3.width + Base_St3.x, Base_St3.y, nStaveWidth).setContext(ctx);
var Guitar1_notes4_tr_option = {
Base_St4.draw();
    textContent: ["tr."], // 必須文字列
    strID: "Guitar1_notes4_tr", // 必須
    Stave_x: shiftGuitar1_1[0].x,
    Stave_y: shiftGuitar1_1[0].y,
    Stave_x_Offset: 25,
    Stave_y_Offset: -50,
    fontSize: 40,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: [0] // xのオフセット値配列
};
insertTextToSVG(Guitar1_notes4_tr_option);


const Base_Tab1 = new Stave(Base_St1.x, Base_St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
var Guitar1_notes1_option = {
Base_Tab1.setEndBarType(VF.Barline.type.NONE);
    textContent: ["0", "2", "2", "2", "9", "9"], // 必須文字列
for (var i = 0; i < 5; i++) {
    strID: "Guitar1_notes1", // 必須
  if (i != 0) continue;
    Stave_x_Offset: [10, 0, 10, 0, 0, 0],
  Base_Tab1.setConfigForLine(i, {visible: false} );
    Stave_y_Offset: 0,
}
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
Base_Tab1.draw();
    fontSize: 50,
    shift_x: shiftGuitar1_tab1, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Guitar1_notes1_option);


BaseTab1.x = Base_Tab1.x;
var Guitar1_notes1_0_option = {
BaseTab1.y = Base_Tab1.y;
    textContent: ["\uFF7C"], // 必須文字列
    strID: "Guitar1_notes1_ele0", // 必須
    Stave_x: shiftGuitar1_tab1[0].x,
    Stave_y: shiftGuitar1_tab1[0].y,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
};
insertTextToSVG(Guitar1_notes1_0_option);


BaseInst.x = Base_St1.x - 30;
var Guitar1_notes2_option = {
BaseInst.y = Base_St1.y + ((Base_Tab1.y - Base_St1.y) / 2) + 90;  
    textContent: ["9", "9", "9", "9", "9", "9", "7", "9", "7", "7", "5", "4", "7"], // 必須文字列
    strID: "Guitar1_notes1", // 必須
    Stave_x_Offset: [-30, -40, 0, -10, 0, -10, 0, 0, 10, 0, 0, 0, 0],
    Stave_y_Offset: 0,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    fontSize: 50,
    shift_x: shiftGuitar1_tab2, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Guitar1_notes2_option);


StaveBase1 = Base_Tab1;
var Guitar1_notes2_a_option = {
    textContent: [".", ".", ".", ".", ".", ".", ".", "."], // 必須文字列
    strID: "Guitar1_notes2", // 必須
    Stave_x_Offset: [0, 0, 0, 0, 0, 0, 0, 0],
    Stave_y_Offset: [-15, -15, -15, -15, 15, 15, 15, 15],
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    fontSize: 50,
    shift_x: [{x:shiftGuitar1_tab2[3].x, y:shiftGuitar1_tab2[3].y},
              {x:shiftGuitar1_tab2[5].x, y:shiftGuitar1_tab2[5].y},
              {x:shiftGuitar1_tab2[6].x, y:shiftGuitar1_tab2[6].y},
              {x:shiftGuitar1_tab2[7].x, y:shiftGuitar1_tab2[7].y},
              {x:shiftGuitar1_tab2[8].x, y:shiftGuitar1_tab2[8].y},
              {x:shiftGuitar1_tab2[10].x, y:shiftGuitar1_tab2[10].y},
              {x:shiftGuitar1_tab2[11].x, y:shiftGuitar1_tab2[11].y},
              {x:shiftGuitar1_tab2[12].x, y:shiftGuitar1_tab2[12].y}], // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Guitar1_notes2_a_option);


const Base_Tab2 = new Stave(Base_Tab1.width + Base_Tab1.x, Base_Tab1.y, nStaveWidth).setContext(ctx);
insertTiePathToSVG({x:shiftGuitar1_tab2[0].x - 20 - 10, y:shiftGuitar1_tab2[0].y + 10}, {x:shiftGuitar1_tab2[0].x, y:shiftGuitar1_tab2[0].y + 10});
Base_Tab2.setBegBarType(VF.Barline.type.NONE);
Base_Tab2.setEndBarType(VF.Barline.type.NONE);
for (var i = 0; i < 5; i++) {
  if (i != 0) continue;
  Base_Tab2.setConfigForLine(i, {visible: false} );
}
Base_Tab2.draw();


StaveBase2 = Base_Tab2;
insertTiePathToSVG({x:shiftGuitar1_tab2[0].x - 20 - 10, y:shiftGuitar1_tab2[0].y - 40}, {x:shiftGuitar1_tab2[0].x, y:shiftGuitar1_tab2[0].y - 40}, -1);


const Base_Tab3 = new Stave(Base_Tab2.width + Base_Tab2.x, Base_Tab2.y, nStaveWidth).setContext(ctx);
var Guitar1_notes3_option = {
Base_Tab3.setBegBarType(VF.Barline.type.NONE);
    textContent: ["5", "7", "5", "7", "5", "7", "7", "7"], // 必須文字列
Base_Tab3.setEndBarType(VF.Barline.type.NONE);
    strID: "Guitar1_notes3", // 必須
for (var i = 0; i < 5; i++) {
    Stave_x_Offset: [0, 0, 0, 0, 0, 0, 0, 5],
  if (i != 0) continue;
    Stave_y_Offset: 0,
  Base_Tab3.setConfigForLine(i, {visible: false} );
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
}
    fontSize: 50,
Base_Tab3.draw();
    shift_x: shiftGuitar1_tab3, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Guitar1_notes3_option);
 
insertTiePathToSVG({x:shiftGuitar1_tab3[0].x , y:shiftGuitar1_tab3[0].y + 10}, {x:shiftGuitar1_tab3[1].x + 5, y:shiftGuitar1_tab3[0].y + 10});


StaveBase3 = Base_Tab3;
insertTiePathToSVG({x:shiftGuitar1_tab3[1].x , y:shiftGuitar1_tab3[1].y + 10}, {x:shiftGuitar1_tab3[2].x + 5, y:shiftGuitar1_tab3[1].y + 10});


const Base_Tab4 = new Stave(Base_Tab3.width + Base_Tab3.x, Base_Tab3.y, nStaveWidth).setContext(ctx);
insertTiePathToSVG({x:shiftGuitar1_tab3[2].x , y:shiftGuitar1_tab3[2].y + 10}, {x:shiftGuitar1_tab3[3].x + 5, y:shiftGuitar1_tab3[2].y + 10});
Base_Tab4.setBegBarType(VF.Barline.type.NONE);
Base_Tab4.setEndBarType(VF.Barline.type.NONE);
for (var i = 0; i < 5; i++) {
  if (i != 0) continue;
  Base_Tab4.setConfigForLine(i, {visible: false} );
}
Base_Tab4.draw();


StaveBase4 = Base_Tab4;
insertTiePathToSVG({x:shiftGuitar1_tab3[3].x , y:shiftGuitar1_tab3[3].y + 10}, {x:shiftGuitar1_tab3[4].x + 5, y:shiftGuitar1_tab3[3].y + 10});


var Base_connect = new VF.StaveConnector(Base_St1, Base_Tab1);
insertTiePathToSVG({x:shiftGuitar1_tab3[6].x , y:shiftGuitar1_tab3[6].y + 15}, {x:shiftGuitar1_tab3[6].x + 35, y:shiftGuitar1_tab3[6].y + 15});
Base_connect.setType(VF.StaveConnector.type.BRACKET);
Base_connect.setContext(ctx);
Base_connect.draw();


const Drum_St1 = new Stave(Base_Tab1.x, Base_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Drum_St1.addClef("bass").setContext(ctx);
Drum_St1.addTimeSignature('4/4').setContext(ctx);
Drum_St1.draw();


DrumInst.x = Drum_St1.x - 30;
var Guitar1_notes3_7_option = {
DrumInst.y = Drum_St1.y + 90;  
    textContent: ["\uFF7A"], // 必須文字列
    strID: "Guitar1_notes3_ele7", // 必須
    Stave_x: shiftGuitar1_tab3[7].x,
    Stave_y: shiftGuitar1_tab3[7].y + 5,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
};
insertTextToSVG(Guitar1_notes3_7_option);


const Drum_St1_1 = new Stave(nHeadMargin + Base_Tab1.x, Base_Tab1.y + 120, 0).setContext(ctx);
var Guitar1_notes4_option = {
Drum_St1_1.setBegBarType(VF.Barline.type.NONE);
    textContent: ["5", "7", "5", "7", "7", "7", "4", "6", "4", "."], // 必須文字列
Drum_St1_1.setEndBarType(VF.Barline.type.NONE);
    strID: "Guitar1_notes3", // 必須
Drum_St1_1.draw();
    Stave_x_Offset: [0, 0, 0, -20, 0, 0, 0, 0, 0,  0],
    Stave_y_Offset: [0, 0, 0,  0, 0, 0, 0, 0, 0, -15],
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    fontSize: 50,
    shift_x: shiftGuitar1_tab4, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Guitar1_notes4_option);


const Drum_notes1_1 = [
insertTiePathToSVG({x:shiftGuitar1_tab4[0].x, y:shiftGuitar1_tab4[0].y + 10}, {x:shiftGuitar1_tab4[1].x + 2, y:shiftGuitar1_tab4[0].y + 10});
  new StaveNote({ keys: ["f/4"], duration: "4", stem_direction: -1 }),
  new StaveNote({ keys: ["c/4"], duration: "4r" }),
  new StaveNote({ keys: ["c/4"], duration: "8r" }),
  new StaveNote({ keys: ["f/4"], duration: "8", stem_direction: -1 }),
  new StaveNote({ keys: ["c/4"], duration: "8r" }),
  new StaveNote({ keys: ["f/4"], duration: "8", stem_direction: -1 })
];
const Drum_beam1_1 = new VF.Beam([Drum_notes1_1[3],Drum_notes1_1[5]]);


var Drum_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
insertTiePathToSVG({x:shiftGuitar1_tab4[1].x, y:shiftGuitar1_tab4[1].y + 10}, {x:shiftGuitar1_tab4[2].x + 2, y:shiftGuitar1_tab4[1].y + 10});
Drum_St1_1Voice.setStrict(true);
Drum_St1_1Voice.addTickables(Drum_notes1_1);


const Drum_St1_2 = new Stave(nHeadMargin + Base_Tab1.x, Base_Tab1.y + 120, 0).setContext(ctx);
insertTiePathToSVG({x:shiftGuitar1_tab4[4].x - 15, y:shiftGuitar1_tab4[4].y + 10}, {x:shiftGuitar1_tab4[4].x + 2, y:shiftGuitar1_tab4[4].y + 10});
Drum_St1_2.setBegBarType(VF.Barline.type.NONE);
Drum_St1_2.setEndBarType(VF.Barline.type.NONE);
Drum_St1_2.draw();


const Drum_notes1_2 = [
insertTiePathToSVG({x:shiftGuitar1_tab4[4].x, y:shiftGuitar1_tab4[4].y + 10}, {x:shiftGuitar1_tab4[5].x + 2, y:shiftGuitar1_tab4[4].y + 10});
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "16", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "16", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 })
];


const Drum_notes1_3 = [
insertTiePathToSVG({x:shiftGuitar1_tab4[6].x, y:shiftGuitar1_tab4[6].y - 10}, {x:shiftGuitar1_tab4[7].x + 2, y:shiftGuitar1_tab4[6].y - 10}, -1);
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),


  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),


  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
insertTrilPathToSVG(shiftGuitar1_tab4_tr);
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),


  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
var Guitar1_tab_notes4_tr_option = {
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
    textContent: ["tr."], // 必須文字列
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
    strID: "Guitar1_tab_notes4_tr", // 必須
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 })
    Stave_x: shiftGuitar1_tab4_tr[0].x,
];
    Stave_y: shiftGuitar1_tab4_tr[0].y,
    Stave_x_Offset: 25,
    Stave_y_Offset: -50,
    fontSize: 40,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: [0] // xのオフセット値配列
};
insertTextToSVG(Guitar1_tab_notes4_tr_option);


UniqueIds = getUniqueNoteheadIds(Drum_notes1_2, [0, 1, 3, 5, 6, 8]);
var EGuitar2Text_options = {
allUniqueIds = updateAllUniqueIds(UniqueIds);
    textContent: ["E.Guitar2"], // 必須文字列
 
    strID: "EGuitar2Text", // 必須
const Drum_beam1_2_1 = new VF.Beam([Drum_notes1_2[0], Drum_notes1_2[1]]);
    Stave_x: Guitar2Inst.x,
const Drum_beam1_2_2 = new VF.Beam([Drum_notes1_2[2], Drum_notes1_2[3], Drum_notes1_2[4]]);
    Stave_y: Guitar2Inst.y,
const Drum_beam1_2_3 = new VF.Beam([Drum_notes1_2[5], Drum_notes1_2[6], Drum_notes1_2[7], Drum_notes1_2[8]]);
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(EGuitar2Text_options);


var Drum_St1_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
var EGuitar2Tab_options = {
Drum_St1_2Voice.setStrict(true);
    textContent: ["@"], // 必須文字列
Drum_St1_2Voice.addTickables(Drum_notes1_2);
    strID: "EGuitar2Tab", // 必須
    Stave_x: Guitar2Tab1.x,
    Stave_y: Guitar2Tab1.y,
    Stave_x_Offset: 10,
    Stave_y_Offset: 80,
    fontFamily: "YonetMuFL, Arial",
};
insertTextToSVG(EGuitar2Tab_options);


var Drum_St1_3Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
var BaseText_options = {
Drum_St1_3Voice.setStrict(true);
    textContent: ["Base"], // 必須文字列
Drum_St1_3Voice.addTickables(Drum_notes1_3);
    strID: "BaseText", // 必須
    Stave_x: BaseInst.x,
    Stave_y: BaseInst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(BaseText_options);


var formatterDrum_St1_2 = new Vex.Flow.Formatter().joinVoices([Drum_St1_3Voice, Drum_St1_1Voice, Drum_St1_2Voice]);
var BaseTab_options = {
//formatter13_2.formatToStave([stave13_3Voice, stave13_1Voice, stave13_2Voice], stave13_2);
    textContent: ["@"], // 必須文字列
formatterDrum_St1_2.format([Drum_St1_3Voice, Drum_St1_1Voice, Drum_St1_2Voice], nStaveWidth - 30);
    strID: "BaseTab", // 必須
Drum_St1_1Voice.draw(ctx, Drum_St1_2);
    Stave_x: BaseTab1.x,
Drum_St1_2Voice.draw(ctx, Drum_St1_2);
    Stave_y: BaseTab1.y,
    Stave_x_Offset: 10,
    Stave_y_Offset: 90,
    fontFamily: "YonetMuFL, Arial",
};
insertTextToSVG(BaseTab_options);
insertBaseEndBarPathToSVG(StaveBase1);
insertBaseEndBarPathToSVG(StaveBase2);
insertBaseEndBarPathToSVG(StaveBase3);
insertBaseEndBarPathToSVG(StaveBase4);


Drum_beam1_1.setContext(ctx).draw();
var DrumText_options = {
    textContent: ["Drum"], // 必須文字列
    strID: "DrumText", // 必須
    Stave_x: DrumInst.x,
    Stave_y: DrumInst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(DrumText_options);


Drum_beam1_2_1.setContext(ctx).draw();
var PercText_options = {
Drum_beam1_2_2.setContext(ctx).draw();
    textContent: ["Perc."], // 必須文字列
Drum_beam1_2_3.setContext(ctx).draw();
    strID: "PercText", // 必須
    Stave_x: PercInst.x,
    Stave_y: PercInst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(PercText_options);


shiftDrum1 = addShift(
var note13_2_0_option = {
  Drum_notes1_2,
    textContent: ["\uFF65", "\uFF65", "\uFF65", "\uFF65",  
  [0, 1, 2, 3, 5, 5, 6, 6, 7, 7, 8, 8],
                  "\uFF65", "\uFF68", "\uFF66", "\uFF67", "\uFF65", "\uFF0B", "\uFF65", "\uFF0F"], // 必須文字列
   [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
                //x      ,   half_o,        ,        >,        ,      + ,        ,        o
);
    strID: "note13_2_0", // 必須
    Stave_y_Offset: [   -5,       -5,       -5,       -5,
                        -5,     -60,       -5,     -60,       -5,     -60,       -5,     -60],
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: shiftDrum1, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(note13_2_0_option);


var Perc_notes1_1_0_Shaker_option = {
    textContent: ["< Shaker >"], // 必須文字列
    strID: "Perc_notes1_1_0_shaker", // 必須
    Stave_x: Perc_note1_1_0.x,
    Stave_y: Perc_note1_1_0.y,
    Stave_x_Offset: -20,
    Stave_y_Offset: 0,
    fontSize: 60,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: [0] // xのオフセット値配列
};
insertTextToSVG(Perc_notes1_1_0_Shaker_option);


const Drum_St2 = new Stave(Drum_St1.width + Drum_St1.x, Drum_St1.y, nStaveWidth).setContext(ctx);
var Perc_notes1_1_0_option = {
Drum_St2.draw();
    textContent: ["\uFF69"], // 必須文字列
 
    strID: "Perc_notes1_1_0", // 必須
    Stave_y_Offset: -5,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: shiftPerc1, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Perc_notes1_1_0_option);


const Drum_St3 = new Stave(Drum_St2.width + Drum_St2.x, Drum_St1.y, nStaveWidth).setContext(ctx);
if(allUniqueIds !== "undefined"){
Drum_St3.draw();
// 透明にするIDの配列
// 例としてここでIDを指定
let autoUniqueIds = allUniqueIds.map(id => "vf-" + id);


// 各IDに対して処理
  autoUniqueIds.forEach(id => {
    // 該当するIDの要素を取得
    let element = svgElement.getElementById(id);
    if (element) {
      // 該当する要素があれば、描画内容を透明にする
      let paths = element.querySelectorAll("path");
      paths.forEach(path => {
          var dAttribute = path.getAttribute('d');
          // カンマで区切られた数値の数を数えます
          var numberOfValues = (dAttribute.match(/,/g) || []).length + 1; // カンマの数 + 1 = 数値の数


const Drum_St4 = new Stave(Drum_St3.width + Drum_St3.x, Drum_St1.y, nStaveWidth).setContext(ctx);
          if (numberOfValues === 9) {
Drum_St4.draw();
            var firstCoord = dAttribute.split(',')[0];
            if (dAttribute.startsWith('M')) {
              var CnumberOfValues = (dAttribute.match(/C/g) || []).length; // カンマの数 + 1 = 数値の数
              var LnumberOfValues = (dAttribute.match(/L/g) || []).length; // カンマの数 + 1 = 数値の数
                // 座標の差を計算します
              if(CnumberOfValues > 0){
                var coords = dAttribute.match(/[-+]?[0-9]*\.?[0-9]+/g).map(parseFloat);
                var xdiff = coords[0] - coords[2]; // xの差を計算
                var ydiff = coords[1] - coords[3]; // yの差を計算


                // xが0でyが0より大きい場合、描画内容を透明にします
                if (xdiff <= -3.590) {
                if (xdiff >= -3.599) {
                  if(ydiff === 0){
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
                  }
                }
                }
                if (xdiff <= -2.369) {
                if (xdiff >= -2.374) {
                  if(ydiff === 0){
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
                  }
                }
                }
                if (xdiff <= 1.000) {
                if (xdiff >= -1.000) {
                  if(ydiff === 0){
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
                  }
                }
                }
                else {
                  if(ydiff === 1.123){
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
                  }
                }
              }
            }
          }
          else if (numberOfValues === 1) {
            var firstCoord = dAttribute;
            if (dAttribute.startsWith('M')) {
              var LnumberOfValues = (dAttribute.match(/L/g) || []).length; // カンマの数 + 1 = 数値の数
                // 座標の差を計算します
              if(LnumberOfValues > 0){
                var coords = dAttribute.match(/[-+]?[0-9]*\.?[0-9]+/g).map(parseFloat);
                var xdiff = coords[0] - coords[2]; // xの差を計算
                var ydiff = coords[1] - coords[3]; // yの差を計算


const Perc_St1 = new Stave(Drum_St1.x, Drum_St1.y + 100, nHeadMargin + nStaveWidth).setContext(ctx);
                // xが0でyが0より大きい場合、描画内容を透明にします
Perc_St1.addTimeSignature('4/4').setContext(ctx);
                if (xdiff < -10) {
                if (xdiff > -18) {
                  if(ydiff === 0){
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
                  }
                }
                }
              }
            }
          }
          else if (numberOfValues === 21 || numberOfValues === 35 || numberOfValues === 95 || numberOfValues === 41) {
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
          }
      });
    }
  });
}


const Perc_St1_1 = new Stave(nHeadMargin + Drum_St1.x, Drum_St1.y + 100, 0).setContext(ctx);
if(allFlagUniqueIds !== "undefined"){
Perc_St1_1.setBegBarType(VF.Barline.type.NONE);
  let autoFlagUniqueIds = allFlagUniqueIds.map(id => "vf-" + id);
Perc_St1_1.setEndBarType(VF.Barline.type.NONE);
  autoFlagUniqueIds.forEach(id => {
Perc_St1_1.draw();
    // 該当するIDの要素を取得
    let element = svgElement.getElementById(id);
    if (element) {
      // 該当する要素があれば、描画内容を透明にする
      let flagpaths = element.querySelectorAll('path');
      flagpaths.forEach(path => {
        var dAttribute = path.getAttribute('d');
        // カンマで区切られた数値の数を数えます
        var numberOfValues = (dAttribute.match(/,/g) || []).length + 1; // カンマの数 + 1 = 数値の数


for (var i = 0; i < 5; i++) {
        // 数値の数が23であれば、このpath要素は求めるものです
  if (i == 2) continue;
        if (numberOfValues === 23) {
  Perc_St1.setConfigForLine(i, {visible: false} );
          path.setAttribute("fill", "none");
          path.setAttribute("stroke", "none");
        }
      });
    }
  });
}
}
})();
</yjavascript>


Perc_St1.draw();
 コードは以下のとおりです。


PercInst.x = Perc_St1.x - 30;
PercInst.y = Perc_St1.y + 90;


var AllConnector = new VF.StaveConnector(VocalSt1, Perc_St1);
<syntaxhighlight lang="javascript" line start="1" highlight="812-815, 817-845, 847-849, 851-853, 855-858, 860-864, 871-874, 876-909, 911, 912, 914, 915, 917-919, 921-923, 925-928, 930-934, 936, 937, 955-988, 990, 991, 993-995, 997-999, 1001-1004, 1006-1010, 1012, 1013, 1015-1021, 1028-1030, 1032-1064, 1066, 1067, 1069, 1070, 1072, 1073, 1075-1077, 1079-1081, 1083-1086, 1088-1092, 1094-1098, 1100, 1101, 1501-1512, 1514-1521, 1523-1533, 1535-1552, 1554, 1556, 1558-1568, 1570, 1572, 1574, 1576, 1578, 1581-1588, 1590-1600, 1602, 1604, 1608, 1610, 1613, 1615-1626">
AllConnector.setType(VF.StaveConnector.type.SINGLE);
<div id="yonet202403Mid_Output01"></div>
AllConnector.setContext(ctx);
<script>
AllConnector.draw();
///////////////////////
(function(){
class Position {
  constructor(x = 0, y = 0) {
    this.x = x;
    this.y = y;
  }
}
var VF = Vex.Flow;
const Vocal = new Position();
const Guitar1Inst = new Position();
const Guitar2Inst = new Position();
const Guitar2Tab1 = new Position();
const BaseInst = new Position();
const BaseTab1 = new Position();
const DrumInst = new Position();
const PercInst = new Position();
const Stave9Pos = new Position();


const Perc_notes1_1 = [
var StaveBase1;
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
var StaveBase2;
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
var StaveBase3;
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
var StaveBase4;
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),


  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
const Perc_note1_1_0 = new Position();
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),


  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
var shiftGuitar1_1;
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
var shiftGuitar1_tab4_tr;
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),


  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
var shiftGuitar1_tab1;
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
var shiftGuitar1_tab2;
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
var shiftGuitar1_tab3;
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 })
var shiftGuitar1_tab4;
];
var shiftDrum1;
UniqueIds = getUniqueNoteheadIds(Perc_notes1_1, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
var shiftPerc1;
allUniqueIds = updateAllUniqueIds(UniqueIds);


const Perc_beam1_1_1 = new VF.Beam([Perc_notes1_1[0], Perc_notes1_1[1], Perc_notes1_1[2], Perc_notes1_1[3]]);
function insertBaseEndBarPathToSVG(Stave) {
const Perc_beam1_1_2 = new VF.Beam([Perc_notes1_1[4], Perc_notes1_1[5], Perc_notes1_1[6], Perc_notes1_1[7]]);
  var newGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g');
const Perc_beam1_1_3 = new VF.Beam([Perc_notes1_1[8], Perc_notes1_1[9], Perc_notes1_1[10], Perc_notes1_1[11]]);
  newGroup.setAttribute('transform', 'translate(0, 0)');
const Perc_beam1_1_4 = new VF.Beam([Perc_notes1_1[12], Perc_notes1_1[13], Perc_notes1_1[14], Perc_notes1_1[15]]);
  var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
 
  var pathStr = 'M ' + (Stave.x + Stave.width) + ' ' + (Stave.y + 50) +
var Perc_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
    ' L ' + (Stave.x + Stave.width) + ' ' + (Stave.y + 80);
Perc_St1_1Voice.setStrict(true);
  path.setAttribute('d', pathStr);
Perc_St1_1Voice.addTickables(Perc_notes1_1);
  path.setAttribute('stroke', 'black');
  path.setAttribute('stroke-width', '1');
  path.setAttribute('fill', 'none');
  newGroup.appendChild(path);
  svgElement.appendChild(newGroup);
}


var formatterPerc_St1_1 = new Vex.Flow.Formatter().joinVoices([Perc_St1_1Voice]);
function insertTiePathToSVG(StartPos, EndPos, Direction = 1, Depth = 10) {
//formatterPerc_St1_1.formatToStave([stave17_1Voice], Perc_St1_1);
  var newGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g');
formatterPerc_St1_1.format([Perc_St1_1Voice], nStaveWidth - 30);
  newGroup.setAttribute('transform', 'translate(0, 0)');
Perc_St1_1Voice.draw(ctx, Perc_St1_1);
  var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
  var pathStr = 'M' + (StartPos.x) + ' ' + (StartPos.y) + 'Q' + (StartPos.x + (EndPos.x - StartPos.x)/2) + ' ' + ((StartPos.y + EndPos.y)/2 + Direction * (Depth - 2)) +
    ',' + (EndPos.x) + ' ' + (EndPos.y) + 'Q' + ((StartPos.x + EndPos.x)/2) + ' ' + (StartPos.y + (EndPos.y - StartPos.y)/2 + Direction * (Depth + 2)) +
    ','  + (StartPos.x) + ' ' + (StartPos.y) + 'Z';
  path.setAttribute('d', pathStr);
  path.setAttribute('stroke', 'none');
  path.setAttribute('stroke-width', '1');
  path.setAttribute('fill', 'black');
  newGroup.appendChild(path);
  svgElement.appendChild(newGroup);
}


Perc_beam1_1_1.setContext(ctx).draw();
function insertTrilPathToSVG(Shift, Direction = 1) {
Perc_beam1_1_2.setContext(ctx).draw();
  var newGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g');
Perc_beam1_1_3.setContext(ctx).draw();
  newGroup.setAttribute('transform', 'translate(0, 0)');
Perc_beam1_1_4.setContext(ctx).draw();
  var DirectionOffset = 0;
  if (Direction == -1) DirectionOffset = 60;
  var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
  var pathStr = 'M ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 40 + DirectionOffset) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 36 + DirectionOffset) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 36 + DirectionOffset) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset);
  path.setAttribute('d', pathStr);
  path.setAttribute('stroke', 'none');
  path.setAttribute('stroke-width', '1');
  path.setAttribute('fill', 'black');
  var path2 = document.createElementNS('http://www.w3.org/2000/svg', 'path');
  var pathStr2 = 'M ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset + Direction * 7) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 40 + DirectionOffset + Direction * 7) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 36 + DirectionOffset + Direction * 7) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 36 + DirectionOffset + Direction * 7) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset + Direction * 7);
  path2.setAttribute('d', pathStr2);
  path2.setAttribute('stroke', 'none');
  path2.setAttribute('stroke-width', '1');
  path2.setAttribute('fill', 'black');
  var path3 = document.createElementNS('http://www.w3.org/2000/svg', 'path');
  var pathStr3 = 'M ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset + Direction * 14) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 40 + DirectionOffset + Direction * 14) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 36 + DirectionOffset + Direction * 14) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 36 + DirectionOffset + Direction * 14) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset + Direction * 14);
  path3.setAttribute('d', pathStr3);
  path3.setAttribute('stroke', 'none');
  path3.setAttribute('stroke-width', '1');
  path3.setAttribute('fill', 'black');
  newGroup.appendChild(path);
  newGroup.appendChild(path2);
  newGroup.appendChild(path3);
  svgElement.appendChild(newGroup);
}


Perc_note1_1_0.x = Perc_notes1_1[0].getAbsoluteX();
Perc_note1_1_0.y = Perc_notes1_1[0].getStave().getYForLine(1);


shiftPerc1 = addShift(
function insertTextToSVG(options) {
  Perc_notes1_1,
    var textContent = options.textContent;
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
    var strID = options.strID;
  [4, 4, 4, 4, 4, 4, 4, 4, 4, 4,  4,  4,  4,  4,  4,  4]
    var Stave_x = options.Stave_x || 0;
);
    var Stave_y = options.Stave_y || 0;
 
    var isOffset_x_abs = options.IsOffset_x_Abs || false;
const Perc_St2 = new Stave(Perc_St1.width + Perc_St1.x, Perc_St1.y, nStaveWidth).setContext(ctx);
    var Stave_x_Offset = options.Stave_x_Offset || 0;
for (var i = 0; i < 5; i++) {
    var Stave_y_Offset = options.Stave_y_Offset || 0;
  if (i == 2) continue;
    var StaveWidth = options.StaveWidth || 0;
  Perc_St2.setConfigForLine(i, {visible: false} );
    var StaveHeight = options.StaveHeight || 0;
}
    var StaveVerticalScale = options.StaveVerticalScale || 0;
Perc_St2.draw();
    var fontSize = options.fontSize || 40;
 
    var fontFamily = options.fontFamily || "Bravura, Arial";
const Perc_St3 = new Stave(Perc_St2.width + Perc_St2.x, Perc_St2.y, nStaveWidth).setContext(ctx);
    var shift_x = options.shift_x || [0];
for (var i = 0; i < 5; i++) {
    var Rotate = options.Rotate || 0;
  if (i == 2) continue;
    var offset_sum = 0;
  Perc_St3.setConfigForLine(i, {visible: false} );
    var Stave_x_Offset_Value = 0;
}
    var Stave_y_Offset_Value = 0;
Perc_St3.draw();
    var last_Stave_x_Offset = 0;
    var last_Stave_y_Offset = 0;
    var last_textContent = "";
    shift_x.forEach(function(offset, index) {
        offset_sum = offset_sum + offset;
        var newText = document.createElementNS('http://www.w3.org/2000/svg', 'text');
        newText.setAttribute('id', strID + '_' + index); // テキスト要素にIDを付ける
        newText.setAttribute('x', 0);
        newText.setAttribute('y', 0);
        newText.setAttribute('font-family', fontFamily);
        newText.setAttribute('font-size', fontSize);
        newText.setAttribute('fill', 'black');


const Perc_St4 = new Stave(Perc_St3.width + Perc_St3.x, Perc_St3.y, nStaveWidth).setContext(ctx);
        if(typeof textContent === "string"){
for (var i = 0; i < 5; i++) {
          newText.textContent = textContent;
  if (i == 2) continue;
        }
  Perc_St4.setConfigForLine(i, {visible: false} );
        else{
}
          if(textContent.length - 1 < index){
Perc_St4.draw();
            newText.textContent = last_textContent;
 
          }
})();
          else{
            newText.textContent = textContent[index];
            last_textContent = textContent[index];
          }
        }


const svgElement2 = document.querySelector('#yonet202403Mid_Output01 svg');
        if(Stave_x_Offset.length - 1 < index){
svgElement2.style.backgroundColor = '#F5F5F5';
          Stave_x_Offset_Value = last_Stave_x_Offset;
var svgContainer = document.getElementById('yonet202403Mid_Output01');
        }
var svgElement = svgContainer.querySelector('svg');
        else{
          if(Stave_x_Offset.length >= 2){
            Stave_x_Offset_Value = Stave_x_Offset[index];
            last_Stave_x_Offset = Stave_x_Offset[index];
          }
          else{
            Stave_x_Offset_Value = Stave_x_Offset;
          }
        }


var VocalText_options = {
        if(Stave_y_Offset.length - 1 < index){
    textContent: ["Vocal"], // 必須文字列
          Stave_y_Offset_Value = last_Stave_y_Offset;
    strID: "VocalText", // 必須
        }
    Stave_x: Vocal.x,
        else{
    Stave_y: Vocal.y,
          if(Stave_y_Offset.length >= 2){
    fontFamily: "Arial, sans-serif",
            Stave_y_Offset_Value = Stave_y_Offset[index];
    fontSize: "20pt",
            last_Stave_y_Offset = Stave_y_Offset[index];
    Rotate: -90
          }
};
          else{
insertTextToSVG(VocalText_options);
            Stave_y_Offset_Value = Stave_y_Offset;
 
          }
var EGuitarText_options = {
        }
    textContent: ["E.Guitar1"], // 必須文字列
        var textGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g');
    strID: "EGuitarText", // 必須
        if(Rotate != 0){
    Stave_x: Guitar1Inst.x,
          textGroup.setAttribute('transform', 'rotate(' + Rotate + ' ' + 0 + ' ' + 0 + ')');
    Stave_y: Guitar1Inst.y,
          textGroup.appendChild(newText);
    fontFamily: "Arial, sans-serif",
          svgElement.appendChild(textGroup);
    fontSize: "20pt",
        }
    Rotate: -90
        else{
};
          svgElement.appendChild(newText);
insertTextToSVG(EGuitarText_options);
        }
        (function() {
            var textWidth = newText.getBBox().width;
            var textHeight = newText.getBBox().height;
            var horizontalScale;
            if (typeof StaveWidth === 'undefined' || StaveWidth == 0) {
                horizontalScale = 1;
            }
            else {
                horizontalScale = StaveWidth / textWidth;
            }
            var verticalScale;
            if (typeof StaveHeight === 'undefined' || StaveHeight == 0) {
                verticalScale = 1;
            }
            else if (StaveVerticalScale != 0) {
                verticalScale = StaveVerticalScale;
            }
            else {
                verticalScale = StaveHeight / textHeight;
            }
            if(isOffset_x_abs){
              var StavePos_x = offset.x + Stave_x_Offset_Value;
              var StavePos_y = offset.y + Stave_y_Offset_Value;
            }
            else{
              var StavePos_x = Stave_x + Stave_x_Offset + offset_sum;
              var StavePos_y = Stave_y + Stave_y_Offset;
            }
 
            newText.setAttribute('transform', 'translate(' + StavePos_x + ',' + StavePos_y + ') scale(' + horizontalScale + ',' + verticalScale + ')');


var EGuitarTab_options = {
            if(Rotate != 0){
    textContent: ["@"], // 必須文字列
              textGroup.setAttribute('transform', 'rotate(' + Rotate + ' ' + StavePos_x + ' ' + StavePos_y + ')');
    strID: "EGuitarTab", // 必須
            }
    Stave_x: Stave9Pos.x,
        })();
    Stave_y: Stave9Pos.y,
    Stave_x_Offset: 10,
    Stave_y_Offset: 80,
    fontFamily: "YonetMuFL, Arial",
};
insertTextToSVG(EGuitarTab_options);


var EGuitar2Text_options = {
        if(Rotate != 0){
    textContent: ["E.Guitar2"], // 必須文字列
          textGroup.appendChild(newText);
    strID: "EGuitar2Text", // 必須
          svgElement.appendChild(textGroup);
    Stave_x: Guitar2Inst.x,
        }
    Stave_y: Guitar2Inst.y,
        else{
    fontFamily: "Arial, sans-serif",
          svgElement.appendChild(newText);
    fontSize: "20pt",
        }
     Rotate: -90
     });
};
}
insertTextToSVG(EGuitar2Text_options);


var EGuitar2Tab_options = {
var allUniqueIds = [];
     textContent: ["@"], // 必須文字列
var allFlagUniqueIds = [];
     strID: "EGuitar2Tab", // 必須
(function(){
function addShift(notes, arrx = [], arry = []) {
  let tempnote;
  let retShift = [];
 
  for(let i = 0; i < arrx.length || i == 0; i++){
    const pos = new Position();
    //notesのchildrenの各要素について処理
    if(arrx.length === 0){
      tempnote = notes;
    }
    else{
      tempnote = notes[arrx[i]];
      temp_y = arry[i];
    }
    pos.x = tempnote.getAbsoluteX();
    pos.y = tempnote.getStave().getYForLine(temp_y);
 
    retShift.push(pos);
  }
  return retShift;
}
 
var UniqueIds;
function getUniqueNoteheadIds(notes, arr = []) {
    //すべてのidを格納するためのセットを作成
    let tempnote;
    uniqueIds = new Set();
    for(let i = 0; i < arr.length || i == 0; i++){
    //notesのchildrenの各要素について処理
      if(arr.length === 0){
        tempnote = notes;
      }
      else{
        tempnote = notes[arr[i]];
      }
      tempnote.children.forEach(child => {
        //typeが"notehead"であるかチェックし、idを取得
        if (child.attrs){
          if(child.attrs.type === "NoteHead") {
            uniqueIds.add(child.attrs.id);
          }
        }
      });
    }
    // セットを配列に変換して戻り値として返す
    return Array.from(uniqueIds);
}
 
function updateAllUniqueIds(UniqueIds) {
    // allUniqueIdsにUniqueIdsを追加または結合
    if (allUniqueIds.length === 0) {//allUniqueIdsはグローバルな変数
      // allUniqueIdsが空の場合、UniqueIdsをそのままコピー
      allUniqueIds = [...UniqueIds];//スプレッド演算子で要素の中身を書き出す。
    } else {
      UniqueIds.forEach(id => {
        if (!allUniqueIds.includes(id)) {
            allUniqueIds.push(id);
        }
      });
    }
    // 更新されたallUniqueIdsを戻り値として返す
    return allUniqueIds;
}
 
var SteveNoteUniqueIds;
function getUniqueStaveNotesIds(notes, arr = []) {
    //すべてのidを格納するためのセットを作成
    let tempnote;
    uniqueIds = new Set();
    for(let i = 0; i < arr.length || i == 0; i++){
    //notesのchildrenの各要素について処理
      if(arr.length === 0){
        tempnote = notes;
      }
      else{
        tempnote = notes[arr[i]];
      }
      if (tempnote.attrs){
        if(tempnote.attrs.type === "StaveNote") {
          uniqueIds.add(tempnote.attrs.id);
        }
      }
    }
    // セットを配列に変換して戻り値として返す
    return Array.from(uniqueIds);
}
 
function updateAllFlagUniqueIds(FlagUniqueIds) {
    // allUniqueIdsにUniqueIdsを追加または結合
    if (allFlagUniqueIds.length === 0) {
      // allUniqueIdsが空の場合、UniqueIdsをそのままコピー
      allFlagUniqueIds = [...FlagUniqueIds];//スプレッド演算子で要素の中身を書き出す。
    } else {
      FlagUniqueIds.forEach(id => {
        if (!allFlagUniqueIds.includes(id)) {
            allFlagUniqueIds.push(id);
        }
      });
    }
    // 更新されたallUniqueIdsを戻り値として返す
    return allFlagUniqueIds;
}
 
function dotted(staveNote, noteIndex = -1) {
  if (noteIndex < 0) {
    Dot.buildAndAttach([staveNote], {
      all: true
    });
  }
  else {
    for(noteIndexValue of noteIndex){
      Dot.buildAndAttach([staveNote], {
        index: noteIndexValue
      });
    }
  }
  return staveNote;
}
 
const {
  Factory,
  Stave,
  StaveNote,
  Formatter,
  Voice,
  StaveTie,
  BarLine,
  Beam,
  Dot,
  StaveConnector,
  Modifier,
  RenderContext,
  TextDynamics,
  Articulation,
  TextNote,
  Crescendo,
  Renderer
} = Vex.Flow;
 
let nscale = 0.64;
let nwidth = 1040;
let nheight = 1120;
 
let nHeadMargin = 70;
let nStaveWidth = 350;
 
const f = new Factory({
  renderer: { elementId: 'yonet202403Mid_Output01', width: nwidth, height: nheight * nscale }
  });
const ctx = f.getContext();
ctx.scale(nscale, nscale);
 
const defaultStyle = {
  lineWidth: ctx.lineWidth,
  strokeStyle: ctx.strokeStyle,
};
 
for (let i = 0; i <= nwidth * (1 / nscale); i += 10) {
  ctx.beginPath();
  ctx.moveTo(0 + i, 0);
  ctx.lineTo(0 + i, nheight);
  if (i % 100 === 0){
    ctx.setLineWidth(1);
    ctx.setStrokeStyle('rgba(200, 200, 200, 0.8)');
  }
  else{
    ctx.setLineWidth(0.5);
    ctx.setStrokeStyle('rgba(230, 230, 230, 0.8)');
  }
  ctx.stroke();
}
 
for (let i = 0; i <= nheight; i += 10) {
  ctx.beginPath();
  ctx.moveTo(0, i);
  ctx.lineTo(nwidth * (1 / nscale), i);
  if (i % 100 === 0){
    ctx.setLineWidth(1);
    ctx.setStrokeStyle('rgba(200, 200, 200, 0.8)');
  }
  else{
    ctx.setLineWidth(0.5);
    ctx.setStrokeStyle('rgba(230, 230, 230, 0.8)');
  }
  ctx.stroke();
}
 
ctx.lineWidth = defaultStyle.lineWidth;
ctx.strokeStyle = defaultStyle.strokeStyle;
 
const VocalSt1 = new Stave(80, 30, nHeadMargin + nStaveWidth).setContext(ctx);
VocalSt1.setClef("treble").setContext(ctx);
VocalSt1.setTimeSignature('4/4').setContext(ctx);
VocalSt1.addKeySignature('D').setContext(ctx);
VocalSt1.setMeasure(1);
VocalSt1.draw();
 
Vocal.x = VocalSt1.x - 30;
Vocal.y = VocalSt1.y + 90;
 
const VocalSt2 = f.Stave({ x: VocalSt1.width + VocalSt1.x, y: VocalSt1.y, width: nStaveWidth });
VocalSt2.setMeasure(2);
VocalSt2.setContext(ctx).draw();
 
const VocalSt3 = new Stave(VocalSt2.width + VocalSt2.x, VocalSt1.y, nStaveWidth).setContext(ctx);
VocalSt3.setMeasure(3);
VocalSt3.draw();
 
const VocalSt4 = new Stave(VocalSt3.width + VocalSt3.x, VocalSt1.y, nStaveWidth).setContext(ctx);
VocalSt4.setMeasure(4);
VocalSt4.draw();
 
const Guitar1St1 = new Stave(VocalSt1.x, VocalSt1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Guitar1St1.addClef("treble").setContext(ctx);
Guitar1St1.addTimeSignature('4/4').setContext(ctx);
Guitar1St1.addKeySignature('D').setContext(ctx);
Guitar1St1.draw();
 
const Guitar1_notes1_1 = [
  new VF.StaveNote({ keys: ["a/3", "e/4", "a/4", "c/5"], duration: "2" }),
  new VF.StaveNote({ keys: ["e/5"], duration: "8", stem_direction: -1 }),
  dotted(new VF.StaveNote({ keys: ["c/6"], duration: "4d", stem_direction: -1 })),
];
const Guitar1_notes1_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
];
var Guitar1_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St1_1Voice.setStrict(true);
Guitar1_St1_1Voice.addTickables(Guitar1_notes1_1);
 
var Guitar1_St1_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St1_2Voice.setStrict(true);
Guitar1_St1_2Voice.addTickables(Guitar1_notes1_2);
 
var formatterGuitar1_St1_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_St1_2Voice, Guitar1_St1_1Voice]);
formatterGuitar1_St1_1.format([Guitar1_St1_2Voice, Guitar1_St1_1Voice], nStaveWidth - 20 - 10);
Guitar1_St1_1Voice.draw(ctx, Guitar1St1);
Guitar1_St1_2Voice.draw(ctx, Guitar1St1);
 
const Guitar1St2 = new Stave(Guitar1St1.width + Guitar1St1.x, Guitar1St1.y, nStaveWidth).setContext(ctx);
Guitar1St2.draw();
 
const Guitar1_gracenotes2 = [
  new VF.GraceNote({ keys: ['e/5', 'g/5'], duration: '8', slash: true })
  .addModifier(new VF.Accidental('#'), 1)
];
 
const Guitar1_notes2_1 = [
  new VF.StaveNote({ keys: ["f/5", "a/5"], duration: "8", stem_direction: -1 })
  .addModifier(new VF.Accidental('n'), 0),
  new VF.StaveNote({ keys: ["e/5", "g/5"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["f/5"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["e/5"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4", "d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["f/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["e/4"], duration: "8" }),
];
const Guitar1_notes2_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
];
Guitar1_notes2_1[0].addModifier(new VF.Articulation('a.').setPosition(3));
Guitar1_notes2_1[1].addModifier(new VF.Articulation('a.').setPosition(3));
Guitar1_notes2_1[2].addModifier(new VF.Articulation('a.').setPosition(3));
Guitar1_notes2_1[3].addModifier(new VF.Articulation('a.').setPosition(3));
Guitar1_notes2_1[4].addModifier(new VF.Articulation('a.').setPosition(4));
Guitar1_notes2_1[5].addModifier(new VF.Articulation('a.').setPosition(4));
Guitar1_notes2_1[6].addModifier(new VF.Articulation('a.').setPosition(4));
Guitar1_notes2_1[7].addModifier(new VF.Articulation('a.').setPosition(4));
Guitar1_notes2_1[0].addModifier(new VF.GraceNoteGroup(Guitar1_gracenotes2, true), 0);
 
const Guitar1_beam1_1 = new VF.Beam([Guitar1_notes2_1[0], Guitar1_notes2_1[1], Guitar1_notes2_1[2], Guitar1_notes2_1[3]]);
const Guitar1_beam1_2 = new VF.Beam([Guitar1_notes2_1[4], Guitar1_notes2_1[5], Guitar1_notes2_1[6], Guitar1_notes2_1[7]]);
 
var Guitar1_St2_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St2_1Voice.setStrict(true);
Guitar1_St2_1Voice.addTickables(Guitar1_notes2_1);
 
var Guitar1_St2_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St2_2Voice.setStrict(true);
Guitar1_St2_2Voice.addTickables(Guitar1_notes2_2);
 
var formatterGuitar1_St2_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_St2_2Voice, Guitar1_St2_1Voice]);
formatterGuitar1_St2_1.format([Guitar1_St2_2Voice, Guitar1_St2_1Voice], nStaveWidth - 30);
Guitar1_St2_1Voice.draw(ctx, Guitar1St2);
Guitar1_St2_2Voice.draw(ctx, Guitar1St2);
 
Guitar1_beam1_1.setContext(ctx).draw();
Guitar1_beam1_2.setContext(ctx).draw();
 
const Guitar1St3 = new Stave(Guitar1St2.width + Guitar1St2.x, Guitar1St1.y, nStaveWidth).setContext(ctx);
Guitar1St3.draw();
 
const Guitar1_notes3_1 = [
  new VF.StaveNote({ keys: ["g/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["e/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["e/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["e/4"], duration: "2" }),
];
const Guitar1_notes3_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
];
const Guitar1_beam3_1 = new VF.Beam([Guitar1_notes3_1[0], Guitar1_notes3_1[1], Guitar1_notes3_1[2], Guitar1_notes3_1[3]]);
const Guitar1_beam3_2 = new VF.Beam([Guitar1_notes3_1[4], Guitar1_notes3_1[5], Guitar1_notes3_1[6]]);
 
var Guitar1_St3_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St3_1Voice.setStrict(true);
Guitar1_St3_1Voice.addTickables(Guitar1_notes3_1);
 
var Guitar1_St3_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St3_2Voice.setStrict(true);
Guitar1_St3_2Voice.addTickables(Guitar1_notes3_2);
 
var formatterGuitar1_St3_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_St3_2Voice, Guitar1_St3_1Voice]);
formatterGuitar1_St3_1.format([Guitar1_St3_2Voice, Guitar1_St3_1Voice], nStaveWidth - 30);
Guitar1_St3_1Voice.draw(ctx, Guitar1St3);
Guitar1_St3_2Voice.draw(ctx, Guitar1St3);
 
Guitar1_beam3_1.setContext(ctx).draw();
Guitar1_beam3_2.setContext(ctx).draw();
 
const Guitar1_ties3 = [
    new StaveTie({
        first_note: Guitar1_notes3_1[0],
        last_note: Guitar1_notes3_1[1],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes3_1[1],
        last_note: Guitar1_notes3_1[2],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes3_1[2],
        last_note: Guitar1_notes3_1[3],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes3_1[3],
        last_note: Guitar1_notes3_1[4],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes3_1[6],
        last_note: Guitar1_notes3_1[7],
        first_indices: [0],
        last_indices: [0],
    }),
];
 
Guitar1_ties3.forEach((t) => {
    t.setContext(ctx).draw();
});
 
var Guitar1_vibrato3 = new VF.VibratoBracket({
  start: Guitar1_notes3_1[7],
  stop: null,
});
Guitar1_vibrato3.setLine(0);
Guitar1_vibrato3.setHarsh(true);
Guitar1_vibrato3.setContext(ctx).draw();
 
const Guitar1St4 = new Stave(Guitar1St3.width + Guitar1St3.x, Guitar1St1.y, nStaveWidth).setContext(ctx);
Guitar1St4.draw();
 
const Guitar1_gracenotes4 = [
  new VF.GraceNote({ keys: ['a/4'], duration: '8', slash: true })
];
 
const Guitar1_notes4_1 = [
  new VF.StaveNote({ keys: ["g/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["a/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["b/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["b/4"], duration: "4" }),
  new VF.StaveNote({ keys: ["b/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 }),
];
const Guitar1_notes4_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
];
Guitar1_notes4_1[7].addModifier(new VF.Articulation('a.').setPosition(3));
Guitar1_notes4_1[3].addModifier(new VF.GraceNoteGroup(Guitar1_gracenotes4, true), 0);
 
SteveNoteUniqueIds = getUniqueStaveNotesIds(Guitar1_notes4_1, [0, 1]);
allFlagUniqueIds = updateAllFlagUniqueIds(SteveNoteUniqueIds);
 
const Guitar1_beam4_1 = new VF.Beam([Guitar1_notes4_1[2], Guitar1_notes4_1[3]]);
const Guitar1_beam4_2 = new VF.Beam([Guitar1_notes4_1[5], Guitar1_notes4_1[6], Guitar1_notes4_1[7]]);
 
var Guitar1_St4_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St4_1Voice.setStrict(true);
Guitar1_St4_1Voice.addTickables(Guitar1_notes4_1);
 
var Guitar1_St4_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St4_2Voice.setStrict(true);
Guitar1_St4_2Voice.addTickables(Guitar1_notes4_2);
 
var formatterGuitar1_St4_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_St4_2Voice, Guitar1_St4_1Voice]);
formatterGuitar1_St4_1.format([Guitar1_St4_2Voice, Guitar1_St4_1Voice], nStaveWidth - 30);
Guitar1_St4_1Voice.draw(ctx, Guitar1St4);
Guitar1_St4_2Voice.draw(ctx, Guitar1St4);
 
Guitar1_beam4_1.setContext(ctx).draw();
Guitar1_beam4_2.setContext(ctx).draw();
 
shiftGuitar1_1 = addShift(
  Guitar1_notes4_1,
  [0, 1],
  [4, 3.5]
);
 
const Guitar1_ties4 = [
    new StaveTie({
        first_note: Guitar1_notes4_1[0],
        last_note: Guitar1_notes4_1[1],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes4_1[1],
        last_note: Guitar1_notes4_1[2],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes4_1[3],
        last_note: Guitar1_notes4_1[4],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes4_1[5],
        last_note: Guitar1_notes4_1[6],
        first_indices: [0],
        last_indices: [0],
    }),
];
 
Guitar1_ties4.forEach((t) => {
    t.setContext(ctx).draw();
});
 
 
const Guitar1_tab1 = new Stave(Guitar1St1.x, Guitar1St1.y + 110, nHeadMargin + nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar1_tab1.setConfigForLine(i, {visible: false} );
}
Guitar1_tab1.draw();
 
const Guitar1_tab2 = new Stave(Guitar1_tab1.width + Guitar1_tab1.x, Guitar1_tab1.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar1_tab2.setConfigForLine(i, {visible: false} );
}
Guitar1_tab2.draw();
 
const Guitar1_tab3 = new Stave(Guitar1_tab2.width + Guitar1_tab2.x, Guitar1_tab1.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar1_tab3.setConfigForLine(i, {visible: false} );
}
Guitar1_tab3.draw();
 
const Guitar1_tab4 = new Stave(Guitar1_tab3.width + Guitar1_tab3.x, Guitar1_tab1.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar1_tab4.setConfigForLine(i, {visible: false} );
}
Guitar1_tab4.draw();
 
 
 
const Guitar1_Tab1 = new Stave(Guitar1St1.x, Guitar1St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Guitar1_Tab1.draw();
 
Stave9Pos.x = Guitar1_Tab1.x;
Stave9Pos.y = Guitar1_Tab1.y;
 
var connector9_2 = new VF.StaveConnector(Guitar1St1, Guitar1_Tab1);
connector9_2.setType(VF.StaveConnector.type.BRACKET);
connector9_2.setContext(ctx);
connector9_2.draw();
 
Guitar1Inst.x = VocalSt1.x - 30;
Guitar1Inst.y = Guitar1St1.y + ((Guitar1_Tab1.y - Guitar1St1.y) / 2) + 90;
 
 
const Guitar1_Tab1_1 = new Stave(Guitar1_Tab1.x + nHeadMargin + 20, Guitar1_Tab1.y, 0).setContext(ctx);
Guitar1_Tab1_1.setBegBarType(VF.Barline.type.NONE);
Guitar1_Tab1_1.setEndBarType(VF.Barline.type.NONE);
Guitar1_Tab1_1.draw();
 
const Guitar1_tab_notes1_1 = [
  new VF.GhostNote({ keys: ["a/3", "e/4", "a/4", "c/5"], duration: "2" }),
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 }),
  dotted(new VF.StaveNote({ keys: ["f/5"], duration: "4d", stem_direction: -1 })),
];
const Guitar1_tab_notes1_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
];
UniqueIds = getUniqueNoteheadIds(Guitar1_tab_notes1_1, [1, 2]);
allUniqueIds = updateAllUniqueIds(UniqueIds);
 
var Guitar1_tab_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St1_1Voice.setStrict(true);
Guitar1_tab_St1_1Voice.addTickables(Guitar1_tab_notes1_1);
 
var Guitar1_tab_St1_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St1_2Voice.setStrict(true);
Guitar1_tab_St1_2Voice.addTickables(Guitar1_tab_notes1_2);
 
var formatterGuitar1_tab_St1_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_tab_St1_2Voice, Guitar1_tab_St1_1Voice]);
formatterGuitar1_tab_St1_1.format([Guitar1_tab_St1_2Voice, Guitar1_tab_St1_1Voice], nStaveWidth - 20 - 10);
Guitar1_tab_St1_1Voice.draw(ctx, Guitar1_Tab1_1);
Guitar1_tab_St1_2Voice.draw(ctx, Guitar1_Tab1_1);
 
shiftGuitar1_tab1 = addShift(
  Guitar1_tab_notes1_1,
  [0, 0, 0, 0, 1,  2],
  [3, 2, 1, 0, 1, -1]
);
 
 
 
const Guitar1_Tab2 = new Stave(Guitar1_Tab1.width + Guitar1_Tab1.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
Guitar1_Tab2.draw();
 
const Guitar1_tab_gracenotes2 = [
  new VF.GraceNote({ keys: ['a/5'], duration: '8', slash: true })
  .addModifier(new VF.Accidental('#'), 0)
];
 
const Guitar1_tab_notes2_1 = [
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 })
  .addModifier(new VF.Accidental('n'), 0),
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["f/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["b/4"], duration: "8" }),
];
const Guitar1_tab_notes2_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
];
Guitar1_tab_notes2_1[0].addModifier(new VF.GraceNoteGroup(Guitar1_tab_gracenotes2, false), 0);
 
UniqueIds = getUniqueNoteheadIds(Guitar1_tab_notes2_1, [0, 1, 2, 3, 4, 5, 6, 7]);
allUniqueIds = updateAllUniqueIds(UniqueIds);
 
const Guitar1_tab_beam2_1 = new VF.Beam([Guitar1_tab_notes2_1[0], Guitar1_tab_notes2_1[1], Guitar1_tab_notes2_1[2], Guitar1_tab_notes2_1[3]]);
const Guitar1_tab_beam2_2 = new VF.Beam([Guitar1_tab_notes2_1[4], Guitar1_tab_notes2_1[5], Guitar1_tab_notes2_1[6], Guitar1_tab_notes2_1[7]]);
 
var Guitar1_tab_St2_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St2_1Voice.setStrict(true);
Guitar1_tab_St2_1Voice.addTickables(Guitar1_tab_notes2_1);
 
var Guitar1_tab_St2_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St2_2Voice.setStrict(true);
Guitar1_tab_St2_2Voice.addTickables(Guitar1_tab_notes2_2);
 
var formatterGuitar1_tab_St2_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_tab_St2_2Voice, Guitar1_tab_St2_1Voice]);
formatterGuitar1_tab_St2_1.format([Guitar1_tab_St2_2Voice, Guitar1_tab_St2_1Voice], nStaveWidth - 20);
Guitar1_tab_St2_1Voice.draw(ctx, Guitar1_Tab2);
Guitar1_tab_St2_2Voice.draw(ctx, Guitar1_Tab2);
 
shiftGuitar1_tab2 = addShift(
  Guitar1_tab_notes2_1,
  [0, 0, 0, 0, 1, 1, 2, 3, 4, 4, 5, 6, 7],
  [1, 0, 1, 0, 1, 0, 0, 1, 2, 1, 2, 2, 3]
);
 
Guitar1_tab_beam2_1.setContext(ctx).draw();
Guitar1_tab_beam2_2.setContext(ctx).draw();
 
//const Curve1_1to2_2 = new Curve(
//  Guitar1_tab_gracenotes2[0],
//  Guitar1_tab_notes2_1[0],
//  {
//    cps: [
//      { x: 0, y:10 },
//      { x: 0, y:10 },
//    ],
//  },
//);
 
 
 
const Guitar1_Tab3 = new Stave(Guitar1_Tab2.width + Guitar1_Tab2.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
Guitar1_Tab3.draw();
 
const Guitar1_tab_notes3_1 = [
  new VF.StaveNote({ keys: ["d/5"], duration: "16" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "16" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "16" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "16" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "16" }),
  new VF.GhostNote({ keys: ["b/4"], duration: "2" }),
];
const Guitar1_tab_notes3_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
];
UniqueIds = getUniqueNoteheadIds(Guitar1_tab_notes3_1, [0, 1, 2, 3, 4, 5, 6, 7]);
allUniqueIds = updateAllUniqueIds(UniqueIds);
 
const Guitar1_tab_beam3_1 = new VF.Beam([Guitar1_tab_notes3_1[0], Guitar1_tab_notes3_1[1], Guitar1_tab_notes3_1[2], Guitar1_tab_notes3_1[3]]);
const Guitar1_tab_beam3_2 = new VF.Beam([Guitar1_tab_notes3_1[4], Guitar1_tab_notes3_1[5], Guitar1_tab_notes3_1[6]]);
 
var Guitar1_tab_St3_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St3_1Voice.setStrict(true);
Guitar1_tab_St3_1Voice.addTickables(Guitar1_tab_notes3_1);
 
var Guitar1_tab_St3_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St3_2Voice.setStrict(true);
Guitar1_tab_St3_2Voice.addTickables(Guitar1_tab_notes3_2);
 
var formatterGuitar1_tab_St3_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_tab_St3_2Voice, Guitar1_tab_St3_1Voice]);
formatterGuitar1_tab_St3_1.format([Guitar1_tab_St3_2Voice, Guitar1_tab_St3_1Voice], nStaveWidth - 20);
Guitar1_tab_St3_1Voice.draw(ctx, Guitar1_Tab3);
Guitar1_tab_St3_2Voice.draw(ctx, Guitar1_Tab3);
 
shiftGuitar1_tab3 = addShift(
  Guitar1_tab_notes3_1,
  [0, 1, 2, 3, 4, 5, 6, 7],
  [2, 2, 2, 2, 2, 4, 4, 4]
);
 
Guitar1_tab_beam3_1.setContext(ctx).draw();
Guitar1_tab_beam3_2.setContext(ctx).draw();
 
var Guitar1_tab_vibrato3 = new VF.VibratoBracket({
  start: Guitar1_tab_notes3_1[7],
  stop: null,
});
Guitar1_tab_vibrato3.setLine(1);
Guitar1_tab_vibrato3.setHarsh(true);
Guitar1_tab_vibrato3.setContext(ctx).draw();
 
 
 
const Guitar1_Tab4 = new Stave(Guitar1_Tab3.width + Guitar1_Tab3.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
Guitar1_Tab4.draw();
 
const Guitar1_tab_gracenotes4 = [
  new VF.GraceNote({ keys: ['d/5'], duration: '8', slash: true })
];
 
const Guitar1_tab_notes4_1 = [
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "4" }),
  new VF.StaveNote({ keys: ["b/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["b/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 }),
];
const Guitar1_tab_notes4_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
 
];
Guitar1_tab_notes4_1[3].addModifier(new VF.GraceNoteGroup(Guitar1_tab_gracenotes4, false), 0);
 
SteveNoteUniqueIds = getUniqueStaveNotesIds(Guitar1_tab_notes4_1, [0, 1]);
allFlagUniqueIds = updateAllFlagUniqueIds(SteveNoteUniqueIds);
 
UniqueIds = getUniqueNoteheadIds(Guitar1_tab_notes4_1, [0, 1, 2, 3, 4, 5, 6, 7]);
allUniqueIds = updateAllUniqueIds(UniqueIds);
 
const Guitar1_tab_beam4_1 = new VF.Beam([Guitar1_tab_notes4_1[2], Guitar1_tab_notes4_1[3]]);
const Guitar1_tab_beam4_2 = new VF.Beam([Guitar1_tab_notes4_1[5], Guitar1_tab_notes4_1[6], Guitar1_tab_notes4_1[7]]);
 
var Guitar1_tab_St4_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St4_1Voice.setStrict(true);
Guitar1_tab_St4_1Voice.addTickables(Guitar1_tab_notes4_1);
 
var Guitar1_tab_St4_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St4_2Voice.setStrict(true);
Guitar1_tab_St4_2Voice.addTickables(Guitar1_tab_notes4_2);
 
var formatterGuitar1_tab_St4_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_tab_St4_2Voice, Guitar1_tab_St4_1Voice]);
formatterGuitar1_tab_St4_1.format([Guitar1_tab_St4_2Voice, Guitar1_tab_St4_1Voice], nStaveWidth - 20);
Guitar1_tab_St4_1Voice.draw(ctx, Guitar1_Tab4);
Guitar1_tab_St4_2Voice.draw(ctx, Guitar1_Tab4);
 
shiftGuitar1_tab4 = addShift(
  Guitar1_tab_notes4_1,
  [0, 1, 2, 3, 3, 4, 5, 6, 7, 7],
  [2, 2, 2, 2, 2, 2, 1, 1, 1, 1]
);
 
shiftGuitar1_tab4_tr = addShift(
  Guitar1_tab_notes4_1,
  [0, 1],
  [3, 2.5]
);
 
Guitar1_tab_beam4_1.setContext(ctx).draw();
Guitar1_tab_beam4_2.setContext(ctx).draw();
 
 
const Guitar2_St1 = new Stave(Guitar1_Tab1.x, Guitar1_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Guitar2_St1.addClef("treble").setContext(ctx);
Guitar2_St1.addTimeSignature('4/4').setContext(ctx);
Guitar2_St1.addKeySignature('D').setContext(ctx);
Guitar2_St1.draw();
 
const Guitar2_St2 = new Stave(Guitar2_St1.width + Guitar2_St1.x, Guitar2_St1.y, nStaveWidth).setContext(ctx);
Guitar2_St2.draw();
 
const Guitar2_St3 = new Stave(Guitar2_St2.width + Guitar2_St2.x, Guitar2_St2.y, nStaveWidth).setContext(ctx);
Guitar2_St3.draw();
 
const Guitar2_St4 = new Stave(Guitar2_St3.width + Guitar2_St3.x, Guitar2_St3.y, nStaveWidth).setContext(ctx);
Guitar2_St4.draw();
 
const Guitar2_Tab1 = new Stave(Guitar2_St1.x, Guitar2_St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Guitar2_Tab1.draw();
 
Guitar2Tab1.x = Guitar2_Tab1.x;
Guitar2Tab1.y = Guitar2_Tab1.y;
 
const Guitar2_Tab2 = new Stave(Guitar2_Tab1.width + Guitar2_Tab1.x, Guitar2_Tab1.y, nStaveWidth).setContext(ctx);
Guitar2_Tab2.draw();
 
const Guitar2_Tab3 = new Stave(Guitar2_Tab2.width + Guitar2_Tab2.x, Guitar2_Tab2.y, nStaveWidth).setContext(ctx);
Guitar2_Tab3.draw();
 
const Guitar2_Tab4 = new Stave(Guitar2_Tab3.width + Guitar2_Tab3.x, Guitar2_Tab3.y, nStaveWidth).setContext(ctx);
Guitar2_Tab4.draw();
 
var Guitar2_connect = new VF.StaveConnector(Guitar2_St1, Guitar2_Tab1);
Guitar2_connect.setType(VF.StaveConnector.type.BRACKET);
Guitar2_connect.setContext(ctx);
Guitar2_connect.draw();
 
const Guitar2_Tab1_tab = new Stave(Guitar2_Tab1.x, Guitar2_Tab1.y - 10, nHeadMargin + nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar2_Tab1_tab.setConfigForLine(i, {visible: false} );
}
Guitar2_Tab1_tab.draw();
 
const Guitar2_Tab2_tab = new Stave(Guitar2_Tab1_tab.width + Guitar2_Tab1_tab.x, Guitar2_Tab1_tab.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar2_Tab2_tab.setConfigForLine(i, {visible: false} );
}
Guitar2_Tab2_tab.draw();
 
const Guitar2_Tab3_tab = new Stave(Guitar2_Tab2_tab.width + Guitar2_Tab2_tab.x, Guitar2_Tab2_tab.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar2_Tab3_tab.setConfigForLine(i, {visible: false} );
}
Guitar2_Tab3_tab.draw();
 
const Guitar2_Tab4_tab = new Stave(Guitar2_Tab3_tab.width + Guitar2_Tab3_tab.x, Guitar2_Tab3_tab.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar2_Tab4_tab.setConfigForLine(i, {visible: false} );
}
Guitar2_Tab4_tab.draw();
 
Guitar2Inst.x = Guitar2_St1.x - 30;
Guitar2Inst.y = Guitar2_St1.y + ((Guitar2_Tab1.y - Guitar2_St1.y) / 2) + 90;
 
const Base_St1 = new Stave(Guitar2_Tab1.x, Guitar2_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Base_St1.addClef("bass").setContext(ctx);
Base_St1.addTimeSignature('4/4').setContext(ctx);
Base_St1.addKeySignature('D').setContext(ctx);
Base_St1.draw();
 
const Base_St2 = new Stave(Base_St1.width + Base_St1.x, Base_St1.y, nStaveWidth).setContext(ctx);
Base_St2.draw();
 
const Base_St3 = new Stave(Base_St2.width + Base_St2.x, Base_St2.y, nStaveWidth).setContext(ctx);
Base_St3.draw();
 
const Base_St4 = new Stave(Base_St3.width + Base_St3.x, Base_St3.y, nStaveWidth).setContext(ctx);
Base_St4.draw();
 
const Base_Tab1 = new Stave(Base_St1.x, Base_St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Base_Tab1.setEndBarType(VF.Barline.type.NONE);
for (var i = 0; i < 5; i++) {
  if (i != 0) continue;
  Base_Tab1.setConfigForLine(i, {visible: false} );
}
Base_Tab1.draw();
 
BaseTab1.x = Base_Tab1.x;
BaseTab1.y = Base_Tab1.y;
 
BaseInst.x = Base_St1.x - 30;
BaseInst.y = Base_St1.y + ((Base_Tab1.y - Base_St1.y) / 2) + 90;
 
StaveBase1 = Base_Tab1;
 
const Base_Tab2 = new Stave(Base_Tab1.width + Base_Tab1.x, Base_Tab1.y, nStaveWidth).setContext(ctx);
Base_Tab2.setBegBarType(VF.Barline.type.NONE);
Base_Tab2.setEndBarType(VF.Barline.type.NONE);
for (var i = 0; i < 5; i++) {
  if (i != 0) continue;
  Base_Tab2.setConfigForLine(i, {visible: false} );
}
Base_Tab2.draw();
 
StaveBase2 = Base_Tab2;
 
const Base_Tab3 = new Stave(Base_Tab2.width + Base_Tab2.x, Base_Tab2.y, nStaveWidth).setContext(ctx);
Base_Tab3.setBegBarType(VF.Barline.type.NONE);
Base_Tab3.setEndBarType(VF.Barline.type.NONE);
for (var i = 0; i < 5; i++) {
  if (i != 0) continue;
  Base_Tab3.setConfigForLine(i, {visible: false} );
}
Base_Tab3.draw();
 
StaveBase3 = Base_Tab3;
 
const Base_Tab4 = new Stave(Base_Tab3.width + Base_Tab3.x, Base_Tab3.y, nStaveWidth).setContext(ctx);
Base_Tab4.setBegBarType(VF.Barline.type.NONE);
Base_Tab4.setEndBarType(VF.Barline.type.NONE);
for (var i = 0; i < 5; i++) {
  if (i != 0) continue;
  Base_Tab4.setConfigForLine(i, {visible: false} );
}
Base_Tab4.draw();
 
StaveBase4 = Base_Tab4;
 
var Base_connect = new VF.StaveConnector(Base_St1, Base_Tab1);
Base_connect.setType(VF.StaveConnector.type.BRACKET);
Base_connect.setContext(ctx);
Base_connect.draw();
 
const Drum_St1 = new Stave(Base_Tab1.x, Base_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Drum_St1.addClef("bass").setContext(ctx);
Drum_St1.addTimeSignature('4/4').setContext(ctx);
Drum_St1.draw();
 
DrumInst.x = Drum_St1.x - 30;
DrumInst.y = Drum_St1.y + 90;
 
const Drum_St1_1 = new Stave(nHeadMargin + Base_Tab1.x, Base_Tab1.y + 120, 0).setContext(ctx);
Drum_St1_1.setBegBarType(VF.Barline.type.NONE);
Drum_St1_1.setEndBarType(VF.Barline.type.NONE);
Drum_St1_1.draw();
 
const Drum_notes1_1 = [
  new StaveNote({ keys: ["f/4"], duration: "4", stem_direction: -1 }),
  new StaveNote({ keys: ["c/4"], duration: "4r" }),
  new StaveNote({ keys: ["c/4"], duration: "8r" }),
  new StaveNote({ keys: ["f/4"], duration: "8", stem_direction: -1 }),
  new StaveNote({ keys: ["c/4"], duration: "8r" }),
  new StaveNote({ keys: ["f/4"], duration: "8", stem_direction: -1 })
];
const Drum_beam1_1 = new VF.Beam([Drum_notes1_1[3],Drum_notes1_1[5]]);
 
var Drum_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Drum_St1_1Voice.setStrict(true);
Drum_St1_1Voice.addTickables(Drum_notes1_1);
 
const Drum_St1_2 = new Stave(nHeadMargin + Base_Tab1.x, Base_Tab1.y + 120, 0).setContext(ctx);
Drum_St1_2.setBegBarType(VF.Barline.type.NONE);
Drum_St1_2.setEndBarType(VF.Barline.type.NONE);
Drum_St1_2.draw();
 
const Drum_notes1_2 = [
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "16", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "16", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 })
];
 
const Drum_notes1_3 = [
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
 
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
 
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
 
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 })
];
 
UniqueIds = getUniqueNoteheadIds(Drum_notes1_2, [0, 1, 3, 5, 6, 8]);
allUniqueIds = updateAllUniqueIds(UniqueIds);
 
const Drum_beam1_2_1 = new VF.Beam([Drum_notes1_2[0], Drum_notes1_2[1]]);
const Drum_beam1_2_2 = new VF.Beam([Drum_notes1_2[2], Drum_notes1_2[3], Drum_notes1_2[4]]);
const Drum_beam1_2_3 = new VF.Beam([Drum_notes1_2[5], Drum_notes1_2[6], Drum_notes1_2[7], Drum_notes1_2[8]]);
 
var Drum_St1_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Drum_St1_2Voice.setStrict(true);
Drum_St1_2Voice.addTickables(Drum_notes1_2);
 
var Drum_St1_3Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Drum_St1_3Voice.setStrict(true);
Drum_St1_3Voice.addTickables(Drum_notes1_3);
 
var formatterDrum_St1_2 = new Vex.Flow.Formatter().joinVoices([Drum_St1_3Voice, Drum_St1_1Voice, Drum_St1_2Voice]);
//formatter13_2.formatToStave([stave13_3Voice, stave13_1Voice, stave13_2Voice], stave13_2);
formatterDrum_St1_2.format([Drum_St1_3Voice, Drum_St1_1Voice, Drum_St1_2Voice], nStaveWidth - 30);
Drum_St1_1Voice.draw(ctx, Drum_St1_2);
Drum_St1_2Voice.draw(ctx, Drum_St1_2);
 
Drum_beam1_1.setContext(ctx).draw();
 
Drum_beam1_2_1.setContext(ctx).draw();
Drum_beam1_2_2.setContext(ctx).draw();
Drum_beam1_2_3.setContext(ctx).draw();
 
shiftDrum1 = addShift(
  Drum_notes1_2,
  [0, 1, 2, 3, 5, 5, 6, 6, 7, 7, 8, 8],
  [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
);
 
 
const Drum_St2 = new Stave(Drum_St1.width + Drum_St1.x, Drum_St1.y, nStaveWidth).setContext(ctx);
Drum_St2.draw();
 
 
const Drum_St3 = new Stave(Drum_St2.width + Drum_St2.x, Drum_St1.y, nStaveWidth).setContext(ctx);
Drum_St3.draw();
 
 
const Drum_St4 = new Stave(Drum_St3.width + Drum_St3.x, Drum_St1.y, nStaveWidth).setContext(ctx);
Drum_St4.draw();
 
 
const Perc_St1 = new Stave(Drum_St1.x, Drum_St1.y + 100, nHeadMargin + nStaveWidth).setContext(ctx);
Perc_St1.addTimeSignature('4/4').setContext(ctx);
 
const Perc_St1_1 = new Stave(nHeadMargin + Drum_St1.x, Drum_St1.y + 100, 0).setContext(ctx);
Perc_St1_1.setBegBarType(VF.Barline.type.NONE);
Perc_St1_1.setEndBarType(VF.Barline.type.NONE);
Perc_St1_1.draw();
 
for (var i = 0; i < 5; i++) {
  if (i == 2) continue;
  Perc_St1.setConfigForLine(i, {visible: false} );
}
 
Perc_St1.draw();
 
PercInst.x = Perc_St1.x - 30;
PercInst.y = Perc_St1.y + 90;
 
var AllConnector = new VF.StaveConnector(VocalSt1, Perc_St1);
AllConnector.setType(VF.StaveConnector.type.SINGLE);
AllConnector.setContext(ctx);
AllConnector.draw();
 
const Perc_notes1_1 = [
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
 
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
 
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
 
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 })
];
UniqueIds = getUniqueNoteheadIds(Perc_notes1_1, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
allUniqueIds = updateAllUniqueIds(UniqueIds);
 
const Perc_beam1_1_1 = new VF.Beam([Perc_notes1_1[0], Perc_notes1_1[1], Perc_notes1_1[2], Perc_notes1_1[3]]);
const Perc_beam1_1_2 = new VF.Beam([Perc_notes1_1[4], Perc_notes1_1[5], Perc_notes1_1[6], Perc_notes1_1[7]]);
const Perc_beam1_1_3 = new VF.Beam([Perc_notes1_1[8], Perc_notes1_1[9], Perc_notes1_1[10], Perc_notes1_1[11]]);
const Perc_beam1_1_4 = new VF.Beam([Perc_notes1_1[12], Perc_notes1_1[13], Perc_notes1_1[14], Perc_notes1_1[15]]);
 
var Perc_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Perc_St1_1Voice.setStrict(true);
Perc_St1_1Voice.addTickables(Perc_notes1_1);
 
var formatterPerc_St1_1 = new Vex.Flow.Formatter().joinVoices([Perc_St1_1Voice]);
//formatterPerc_St1_1.formatToStave([stave17_1Voice], Perc_St1_1);
formatterPerc_St1_1.format([Perc_St1_1Voice], nStaveWidth - 30);
Perc_St1_1Voice.draw(ctx, Perc_St1_1);
 
Perc_beam1_1_1.setContext(ctx).draw();
Perc_beam1_1_2.setContext(ctx).draw();
Perc_beam1_1_3.setContext(ctx).draw();
Perc_beam1_1_4.setContext(ctx).draw();
 
Perc_note1_1_0.x = Perc_notes1_1[0].getAbsoluteX();
Perc_note1_1_0.y = Perc_notes1_1[0].getStave().getYForLine(1);
 
shiftPerc1 = addShift(
  Perc_notes1_1,
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
  [4, 4, 4, 4, 4, 4, 4, 4, 4, 4,  4,  4,  4,  4,  4,  4]
);
 
const Perc_St2 = new Stave(Perc_St1.width + Perc_St1.x, Perc_St1.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 2) continue;
  Perc_St2.setConfigForLine(i, {visible: false} );
}
Perc_St2.draw();
 
const Perc_St3 = new Stave(Perc_St2.width + Perc_St2.x, Perc_St2.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 2) continue;
  Perc_St3.setConfigForLine(i, {visible: false} );
}
Perc_St3.draw();
 
const Perc_St4 = new Stave(Perc_St3.width + Perc_St3.x, Perc_St3.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 2) continue;
  Perc_St4.setConfigForLine(i, {visible: false} );
}
Perc_St4.draw();
 
})();
 
const svgElement2 = document.querySelector('#yonet202403Mid_Output01 svg');
svgElement2.style.backgroundColor = '#F5F5F5';
var svgContainer = document.getElementById('yonet202403Mid_Output01');
var svgElement = svgContainer.querySelector('svg');
 
var VocalText_options = {
    textContent: ["Vocal"], // 必須文字列
    strID: "VocalText", // 必須
    Stave_x: Vocal.x,
    Stave_y: Vocal.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(VocalText_options);
 
var EGuitarText_options = {
    textContent: ["E.Guitar1"], // 必須文字列
    strID: "EGuitarText", // 必須
    Stave_x: Guitar1Inst.x,
    Stave_y: Guitar1Inst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(EGuitarText_options);
 
var EGuitarTab_options = {
    textContent: ["@"], // 必須文字列
    strID: "EGuitarTab", // 必須
    Stave_x: Stave9Pos.x,
    Stave_y: Stave9Pos.y,
    Stave_x_Offset: 10,
    Stave_y_Offset: 80,
    fontFamily: "YonetMuFL, Arial",
};
insertTextToSVG(EGuitarTab_options);
 
insertTrilPathToSVG(shiftGuitar1_1);
 
var Guitar1_notes4_tr_option = {
    textContent: ["tr."], // 必須文字列
    strID: "Guitar1_notes4_tr", // 必須
    Stave_x: shiftGuitar1_1[0].x,
    Stave_y: shiftGuitar1_1[0].y,
    Stave_x_Offset: 25,
    Stave_y_Offset: -50,
    fontSize: 40,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: [0] // xのオフセット値配列
};
insertTextToSVG(Guitar1_notes4_tr_option);
 
var Guitar1_notes1_option = {
    textContent: ["0", "2", "2", "2", "9", "9"], // 必須文字列
    strID: "Guitar1_notes1", // 必須
    Stave_x_Offset: [10, 0, 10, 0, 0, 0],
    Stave_y_Offset: 0,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    fontSize: 50,
    shift_x: shiftGuitar1_tab1, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Guitar1_notes1_option);
 
var Guitar1_notes1_0_option = {
    textContent: ["\uFF7C"], // 必須文字列
    strID: "Guitar1_notes1_ele0", // 必須
    Stave_x: shiftGuitar1_tab1[0].x,
    Stave_y: shiftGuitar1_tab1[0].y,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
};
insertTextToSVG(Guitar1_notes1_0_option);
 
var Guitar1_notes2_option = {
    textContent: ["9", "9", "9", "9", "9", "9", "7", "9", "7", "7", "5", "4", "7"], // 必須文字列
    strID: "Guitar1_notes1", // 必須
    Stave_x_Offset: [-30, -40, 0, -10, 0, -10, 0, 0, 10, 0, 0, 0, 0],
    Stave_y_Offset: 0,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    fontSize: 50,
    shift_x: shiftGuitar1_tab2, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Guitar1_notes2_option);
 
var Guitar1_notes2_a_option = {
    textContent: [".", ".", ".", ".", ".", ".", ".", "."], // 必須文字列
    strID: "Guitar1_notes2", // 必須
    Stave_x_Offset: [0, 0, 0, 0, 0, 0, 0, 0],
    Stave_y_Offset: [-15, -15, -15, -15, 15, 15, 15, 15],
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    fontSize: 50,
    shift_x: [{x:shiftGuitar1_tab2[3].x, y:shiftGuitar1_tab2[3].y},
              {x:shiftGuitar1_tab2[5].x, y:shiftGuitar1_tab2[5].y},
              {x:shiftGuitar1_tab2[6].x, y:shiftGuitar1_tab2[6].y},
              {x:shiftGuitar1_tab2[7].x, y:shiftGuitar1_tab2[7].y},
              {x:shiftGuitar1_tab2[8].x, y:shiftGuitar1_tab2[8].y},
              {x:shiftGuitar1_tab2[10].x, y:shiftGuitar1_tab2[10].y},
              {x:shiftGuitar1_tab2[11].x, y:shiftGuitar1_tab2[11].y},
              {x:shiftGuitar1_tab2[12].x, y:shiftGuitar1_tab2[12].y}], // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Guitar1_notes2_a_option);
 
insertTiePathToSVG({x:shiftGuitar1_tab2[0].x - 20 - 10, y:shiftGuitar1_tab2[0].y + 10}, {x:shiftGuitar1_tab2[0].x, y:shiftGuitar1_tab2[0].y + 10});
 
insertTiePathToSVG({x:shiftGuitar1_tab2[0].x - 20 - 10, y:shiftGuitar1_tab2[0].y - 40}, {x:shiftGuitar1_tab2[0].x, y:shiftGuitar1_tab2[0].y - 40}, -1);
 
var Guitar1_notes3_option = {
    textContent: ["5", "7", "5", "7", "5", "7", "7", "7"], // 必須文字列
    strID: "Guitar1_notes3", // 必須
    Stave_x_Offset: [0, 0, 0, 0, 0, 0, 0, 5],
    Stave_y_Offset: 0,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    fontSize: 50,
    shift_x: shiftGuitar1_tab3, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Guitar1_notes3_option);
 
insertTiePathToSVG({x:shiftGuitar1_tab3[0].x , y:shiftGuitar1_tab3[0].y + 10}, {x:shiftGuitar1_tab3[1].x + 5, y:shiftGuitar1_tab3[0].y + 10});
 
insertTiePathToSVG({x:shiftGuitar1_tab3[1].x , y:shiftGuitar1_tab3[1].y + 10}, {x:shiftGuitar1_tab3[2].x + 5, y:shiftGuitar1_tab3[1].y + 10});
 
insertTiePathToSVG({x:shiftGuitar1_tab3[2].x , y:shiftGuitar1_tab3[2].y + 10}, {x:shiftGuitar1_tab3[3].x + 5, y:shiftGuitar1_tab3[2].y + 10});
 
insertTiePathToSVG({x:shiftGuitar1_tab3[3].x , y:shiftGuitar1_tab3[3].y + 10}, {x:shiftGuitar1_tab3[4].x + 5, y:shiftGuitar1_tab3[3].y + 10});
 
insertTiePathToSVG({x:shiftGuitar1_tab3[6].x , y:shiftGuitar1_tab3[6].y + 15}, {x:shiftGuitar1_tab3[6].x + 35, y:shiftGuitar1_tab3[6].y + 15});
 
 
var Guitar1_notes3_7_option = {
    textContent: ["\uFF7A"], // 必須文字列
    strID: "Guitar1_notes3_ele7", // 必須
    Stave_x: shiftGuitar1_tab3[7].x,
    Stave_y: shiftGuitar1_tab3[7].y + 5,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
};
insertTextToSVG(Guitar1_notes3_7_option);
 
var Guitar1_notes4_option = {
    textContent: ["5", "7", "5", "7", "7", "7", "4", "6", "4", "."], // 必須文字列
    strID: "Guitar1_notes3", // 必須
    Stave_x_Offset: [0, 0, 0, -20, 0, 0, 0, 0, 0,  0],
    Stave_y_Offset: [0, 0, 0,  0, 0, 0, 0, 0, 0, -15],
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    fontSize: 50,
    shift_x: shiftGuitar1_tab4, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Guitar1_notes4_option);
 
insertTiePathToSVG({x:shiftGuitar1_tab4[0].x, y:shiftGuitar1_tab4[0].y + 10}, {x:shiftGuitar1_tab4[1].x + 2, y:shiftGuitar1_tab4[0].y + 10});
 
insertTiePathToSVG({x:shiftGuitar1_tab4[1].x, y:shiftGuitar1_tab4[1].y + 10}, {x:shiftGuitar1_tab4[2].x + 2, y:shiftGuitar1_tab4[1].y + 10});
 
insertTiePathToSVG({x:shiftGuitar1_tab4[4].x - 15, y:shiftGuitar1_tab4[4].y + 10}, {x:shiftGuitar1_tab4[4].x + 2, y:shiftGuitar1_tab4[4].y + 10});
 
insertTiePathToSVG({x:shiftGuitar1_tab4[4].x, y:shiftGuitar1_tab4[4].y + 10}, {x:shiftGuitar1_tab4[5].x + 2, y:shiftGuitar1_tab4[4].y + 10});
 
insertTiePathToSVG({x:shiftGuitar1_tab4[6].x, y:shiftGuitar1_tab4[6].y - 10}, {x:shiftGuitar1_tab4[7].x + 2, y:shiftGuitar1_tab4[6].y - 10}, -1);
 
 
insertTrilPathToSVG(shiftGuitar1_tab4_tr);
 
var Guitar1_tab_notes4_tr_option = {
    textContent: ["tr."], // 必須文字列
    strID: "Guitar1_tab_notes4_tr", // 必須
    Stave_x: shiftGuitar1_tab4_tr[0].x,
    Stave_y: shiftGuitar1_tab4_tr[0].y,
    Stave_x_Offset: 25,
    Stave_y_Offset: -50,
    fontSize: 40,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: [0] // xのオフセット値配列
};
insertTextToSVG(Guitar1_tab_notes4_tr_option);
 
var EGuitar2Text_options = {
    textContent: ["E.Guitar2"], // 必須文字列
    strID: "EGuitar2Text", // 必須
    Stave_x: Guitar2Inst.x,
    Stave_y: Guitar2Inst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(EGuitar2Text_options);
 
var EGuitar2Tab_options = {
     textContent: ["@"], // 必須文字列
     strID: "EGuitar2Tab", // 必須
     Stave_x: Guitar2Tab1.x,
     Stave_x: Guitar2Tab1.x,
     Stave_y: Guitar2Tab1.y,
     Stave_y: Guitar2Tab1.y,
     Stave_x_Offset: 10,
     Stave_x_Offset: 10,
     Stave_y_Offset: 80,
     Stave_y_Offset: 80,
     fontFamily: "YonetMuFL, Arial",
     fontFamily: "YonetMuFL, Arial",
};
};
insertTextToSVG(EGuitar2Tab_options);
insertTextToSVG(EGuitar2Tab_options);
 
var BaseText_options = {
    textContent: ["Base"], // 必須文字列
    strID: "BaseText", // 必須
    Stave_x: BaseInst.x,
    Stave_y: BaseInst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(BaseText_options);
 
var BaseTab_options = {
    textContent: ["@"], // 必須文字列
    strID: "BaseTab", // 必須
    Stave_x: BaseTab1.x,
    Stave_y: BaseTab1.y,
    Stave_x_Offset: 10,
    Stave_y_Offset: 90,
    fontFamily: "YonetMuFL, Arial",
};
insertTextToSVG(BaseTab_options);
insertBaseEndBarPathToSVG(StaveBase1);
insertBaseEndBarPathToSVG(StaveBase2);
insertBaseEndBarPathToSVG(StaveBase3);
insertBaseEndBarPathToSVG(StaveBase4);
 
var DrumText_options = {
    textContent: ["Drum"], // 必須文字列
    strID: "DrumText", // 必須
    Stave_x: DrumInst.x,
    Stave_y: DrumInst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(DrumText_options);
 
var PercText_options = {
    textContent: ["Perc."], // 必須文字列
    strID: "PercText", // 必須
    Stave_x: PercInst.x,
    Stave_y: PercInst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(PercText_options);
 
var note13_2_0_option = {
    textContent: ["\uFF65", "\uFF65", "\uFF65", "\uFF65",
                  "\uFF65", "\uFF68", "\uFF66", "\uFF67", "\uFF65", "\uFF0B", "\uFF65", "\uFF0F"], // 必須文字列
                //x      ,  half_o,        ,        >,        ,      + ,        ,        o
    strID: "note13_2_0", // 必須
    Stave_y_Offset: [  -5,      -5,      -5,      -5,
                        -5,      -60,      -5,      -60,      -5,      -60,      -5,      -60],
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: shiftDrum1, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(note13_2_0_option);
 
var Perc_notes1_1_0_Shaker_option = {
    textContent: ["< Shaker >"], // 必須文字列
    strID: "Perc_notes1_1_0_shaker", // 必須
    Stave_x: Perc_note1_1_0.x,
    Stave_y: Perc_note1_1_0.y,
    Stave_x_Offset: -20,
    Stave_y_Offset: 0,
    fontSize: 60,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: [0] // xのオフセット値配列
};
insertTextToSVG(Perc_notes1_1_0_Shaker_option);
 
var Perc_notes1_1_0_option = {
    textContent: ["\uFF69"], // 必須文字列
    strID: "Perc_notes1_1_0", // 必須
    Stave_y_Offset: -5,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: shiftPerc1, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Perc_notes1_1_0_option);
 
if(allUniqueIds !== "undefined"){
// 透明にするIDの配列
// 例としてここでIDを指定
let autoUniqueIds = allUniqueIds.map(id => "vf-" + id);
 
// 各IDに対して処理
  autoUniqueIds.forEach(id => {
    // 該当するIDの要素を取得
    let element = svgElement.getElementById(id);
    if (element) {
      // 該当する要素があれば、描画内容を透明にする
      let paths = element.querySelectorAll("path");
      paths.forEach(path => {
          var dAttribute = path.getAttribute('d');
          // カンマで区切られた数値の数を数えます
          var numberOfValues = (dAttribute.match(/,/g) || []).length + 1; // カンマの数 + 1 = 数値の数
 
          if (numberOfValues === 9) {
            var firstCoord = dAttribute.split(',')[0];
            if (dAttribute.startsWith('M')) {
              var CnumberOfValues = (dAttribute.match(/C/g) || []).length; // カンマの数 + 1 = 数値の数
              var LnumberOfValues = (dAttribute.match(/L/g) || []).length; // カンマの数 + 1 = 数値の数
                // 座標の差を計算します
              if(CnumberOfValues > 0){
                var coords = dAttribute.match(/[-+]?[0-9]*\.?[0-9]+/g).map(parseFloat);
                var xdiff = coords[0] - coords[2]; // xの差を計算
                var ydiff = coords[1] - coords[3]; // yの差を計算
 
                // xが0でyが0より大きい場合、描画内容を透明にします
                if (xdiff <= -3.590) {
                if (xdiff >= -3.599) {
                  if(ydiff === 0){
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
                  }
                }
                }
                if (xdiff <= -2.369) {
                if (xdiff >= -2.374) {
                  if(ydiff === 0){
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
                  }
                }
                }
                if (xdiff <= 1.000) {
                if (xdiff >= -1.000) {
                  if(ydiff === 0){
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
                  }
                }
                }
                else {
                  if(ydiff === 1.123){
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
                  }
                }
              }
            }
          }
          else if (numberOfValues === 1) {
            var firstCoord = dAttribute;
            if (dAttribute.startsWith('M')) {
              var LnumberOfValues = (dAttribute.match(/L/g) || []).length; // カンマの数 + 1 = 数値の数
                // 座標の差を計算します
              if(LnumberOfValues > 0){
                var coords = dAttribute.match(/[-+]?[0-9]*\.?[0-9]+/g).map(parseFloat);
                var xdiff = coords[0] - coords[2]; // xの差を計算
                var ydiff = coords[1] - coords[3]; // yの差を計算
 
                // xが0でyが0より大きい場合、描画内容を透明にします
                if (xdiff < -10) {
                if (xdiff > -18) {
                  if(ydiff === 0){
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
                  }
                }
                }
              }
            }
          }//21は全音符、2分音符の符頭です。35はナチュラル、95はシャープ、41はフラット
          else if (numberOfValues === 21 || numberOfValues === 35 || numberOfValues === 95 || numberOfValues === 41) {
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
          }
      });
    }
  });
}
 
if(allFlagUniqueIds !== "undefined"){
  let autoFlagUniqueIds = allFlagUniqueIds.map(id => "vf-" + id);
  autoFlagUniqueIds.forEach(id => {
    // 該当するIDの要素を取得
    let element = svgElement.getElementById(id);
    if (element) {
      // 該当する要素があれば、描画内容を透明にする
      let flagpaths = element.querySelectorAll('path');
      flagpaths.forEach(path => {
        var dAttribute = path.getAttribute('d');
        // カンマで区切られた数値の数を数えます
        var numberOfValues = (dAttribute.match(/,/g) || []).length + 1; // カンマの数 + 1 = 数値の数
 
        // 数値の数が23であれば、このpath要素は求めるものです
        if (numberOfValues === 23) {
          path.setAttribute("fill", "none");
          path.setAttribute("stroke", "none");
        }
      });
    }
  });
}
})();
</script>
</syntaxhighlight>
 
 
 ものすごく長いコードになったな。1ページみっちり楽譜を描くだけでも、相当のコード量になりますね。
 
 
 812行目からタブ譜を描くための5線譜描画が始まります。Tab譜には調号や拍子に関する記号が記載されないので、左側の余白が大きくなりますので、仮想的な透明の小節を作って、そこを起点に符棒と符旗や連桁を描画します。あとで、符頭を消す関数を作ってあるので、普通に描画してから消すという方式です。UniqueIds = getUniqueNoteheadIds(Guitar1_tab_notes1_1, [1, 2]);のようにするとGuitar1_tab_notes1_1というSteveNoteオブジェクトの要素1と2の符頭を消すIDをUniqueIdsに格納します。VexFlowによる描画が終わったあとでUniqueIdsを使って、符頭を消します。
 
 
 以下のように
 
 
<syntaxhighlight lang="javascript">
shiftGuitar1_tab1 = addShift(
  Guitar1_tab_notes1_1,
  [0, 0, 0, 0, 1,  2],
  [3, 2, 1, 0, 1, -1]
);
</syntaxhighlight>


var BaseText_options = {
    textContent: ["Base"], // 必須文字列
    strID: "BaseText", // 必須
    Stave_x: BaseInst.x,
    Stave_y: BaseInst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(BaseText_options);


var BaseTab_options = {
 フレット番号を記述する位置をaddShift関数でStaveNoteオブジェクトを基準に取得します。1拍目からの2分音符のx方向の値を4要素分取得する必要がありますので、要素の0を4回取得するように[0, 0, 0, 0, …]として同じ要素を繰り返し指定しています。y方向には5弦、4弦、3弦、2弦の位置を取得するべく、[3, 2, 1, 0, …]のように指定います。1弦は-1、6弦は4が対応しています。したがって
    textContent: ["@"], // 必須文字列
    strID: "BaseTab", // 必須
    Stave_x: BaseTab1.x,
    Stave_y: BaseTab1.y,
    Stave_x_Offset: 10,
    Stave_y_Offset: 90,
    fontFamily: "YonetMuFL, Arial",
};
insertTextToSVG(BaseTab_options);


insertBaseEndBarPathToSVG(StaveBase1);
insertBaseEndBarPathToSVG(StaveBase2);
insertBaseEndBarPathToSVG(StaveBase3);
insertBaseEndBarPathToSVG(StaveBase4);


var DrumText_options = {
<table style="border: 0; border-collapse: collapse;">
    textContent: ["Drum"], // 必須文字列
<tr border="0" style="color: white; background-color:#666666; font-weight: bolder;">
    strID: "DrumText", // 必須
  <td>弦</td>
    Stave_x: DrumInst.x,
  <td>位置番号</td>
    Stave_y: DrumInst.y,
</tr>
    fontFamily: "Arial, sans-serif",
<tr>
    fontSize: "20pt",
  <td>第1弦</td>
    Rotate: -90
  <td style="text-align: right;">-1</td>
};
</tr>
insertTextToSVG(DrumText_options);
<tr style="background-color: #cccccc;">
  <td>第2弦</td>
  <td style="text-align: right;">0</td>
</tr>
<tr>
  <td>第3弦</td>
  <td style="text-align: right;">1</td>
</tr>
<tr style="background-color: #cccccc;">
  <td>第4弦</td>
  <td style="text-align: right;">2</td>
</tr>
<tr>
  <td>第5弦</td>
  <td style="text-align: right;">3</td>
</tr>
<tr style="background-color: #cccccc;">
  <td>第6弦</td>
  <td style="text-align: right;">4</td>
</tr>
</table>


var PercText_options = {
    textContent: ["Perc."], // 必須文字列
    strID: "PercText", // 必須
    Stave_x: PercInst.x,
    Stave_y: PercInst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(PercText_options);


var note13_2_0_option = {
 1101行目までが、同じように2小節目から4小節目にもタブ譜内に符棒や符旗や連桁の記号をしるすための指示がつづきます。
    textContent: ["\uFF65", "\uFF65", "\uFF65", "\uFF65",
                  "\uFF65", "\uFF68", "\uFF66", "\uFF67", "\uFF65", "\uFF0B", "\uFF65", "\uFF0F"], // 必須文字列
                //x      ,  half_o,        ,        >,        ,      + ,        ,        o
    strID: "note13_2_0", // 必須
    Stave_y_Offset: [  -5,      -5,      -5,      -5,
                        -5,      -60,      -5,      -60,      -5,      -60,      -5,      -60],
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: shiftDrum1, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(note13_2_0_option);


var Perc_notes1_1_0_Shaker_option = {
    textContent: ["< Shaker >"], // 必須文字列
    strID: "Perc_notes1_1_0_shaker", // 必須
    Stave_x: Perc_note1_1_0.x,
    Stave_y: Perc_note1_1_0.y,
    Stave_x_Offset: -20,
    Stave_y_Offset: 0,
    fontSize: 60,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: [0] // xのオフセット値配列
};
insertTextToSVG(Perc_notes1_1_0_Shaker_option);


var Perc_notes1_1_0_option = {
 1502行目からはVexFlowで描画できない記号をペタペタ表示していく関数になっています。全角の数字はタブ譜に表示するフレット番号の文字を表すコードポイントになっていて、全角の数字と1桁のフレット番号が対になっています。"", "", "2", "2", "9", "9"のようにポジションを記録しているshiftなんちゃらとした名前のオブジェクトに格納されている座標の順番どおりにコードポイントを示しています。10より大きい値のフレット番号は別のコードポイントに格納されていて、\uXXXXのような形式でXXXXに16進数を指定して、表示させます。Stave_x_Offsetキーの値も[10, 0, 10, 0, 0, 0],のように配列要素ごとに個別の値を指定できます。配列ではない数値を付与すると、その数値が全てに適用されますし、配列要素値が足りない場合は最後に指定した要素の値が使いまわされます。Stave_y_Offsetも同じ仕組みです。
    textContent: ["\uFF69"], // 必須文字列
    strID: "Perc_notes1_1_0", // 必須
    Stave_y_Offset: -5,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: shiftPerc1, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Perc_notes1_1_0_option);


// 透明にするIDの配列
// 例としてここでIDを指定
let autoUniqueIds = allUniqueIds.map(id => "vf-" + id);


// 各IDに対して処理
 \uFF7Cは上向きの2分音符の4フレット幅のタブ譜向け記号です。""全角のドットは付点やアクセントに使えるドットになっています。\uFF7Aは1フレット幅の2分音符です。ちょっと大きすぎるっすね。次の記事ではちょうどいい感じの2分音符も表示しています。
autoUniqueIds.forEach(id => {
    // 該当するIDの要素を取得
    let element = svgElement.getElementById(id);
    if (element) {
        // 該当する要素があれば、描画内容を透明にする
        let paths = element.querySelectorAll("path");
        paths.forEach(path => {
            path.setAttribute("fill", "none");
            path.setAttribute("stroke", "none");
        });
    }
});


})();


</script>
</syntaxhighlight>


 あとはTr.のような文字を表示したい場合は全角で"Tr."のように指定するとちょうどいい感じの大きさ手書き英文字が描けるようになっています。コードポイントごとの文字の解説は別の記事で詳しく解説するようにするつもりです。


 


 
 


[[VexFlow 使い方]]に戻る。
[[VexFlow 使い方]]に戻る。

2024年4月15日 (月) 20:27時点における最新版

VexFlow 使い方に戻る。

概要

 五線譜で音が指定されていれば、フレット番号と弦の位置は数パターンに絞られます。が、一意には決まらないのがギターのややこしいところ、それでは弾けないので親切に押さえ方を教えてくれるのがタブ譜の役割です。一番上が一番細い弦で第一弦。一番下は一番太い弦で第六弦です。押さえなければ、上からE, B, G, D, A, Eという音がなります。一番上の弦と一番下の弦は音の高さこそ違えど同じ音がなります。


 あー。できないことがまた一つ見つかった。トリルができない。8分音符なのに譜旗の旗の部分がいらない。そしてトレモロのような記号を音符と音符の間に置かないといけない。できない。ちょっと考えよか。まただ。次々とできないことが判明するね。あとタイとかスラーのデフォルト値短すぎ。わかりやすく長めに書いてほしいのに16分音符のタイとスラー役にたってない。VexFlow。やるな!管理人を困らせるの得意すぎる。


 頑張ってタブ譜をなっとくいくレベルの描画をしてみました。これくらいの描画がVexFlowで出来たら、まじでバリバリ使ってたと思う。けど、ほとんど自作の描画です。慣れないうちは疲れるね。スライド、ハンマリング、プリングオフといった指示を省略しています。次の記事でつけよかな。


 追加した関数は


  • insertTiePathToSVG({x:(始点x座標), y:(始点y座標)}, {x:終点x座標, y:終点y座標}, 方向数値(1 or -1), 深さ数値);
  • insertTrilPathToSVG([{x:(始点x座標), y:(始点y座標)}, {x:終点x座標, y:終点y座標}], 方向数値(1 or -1));
  • getUniqueStaveNotesIds(StaveNote notes, arr = [])
  • updateAllFlagUniqueIds(getUniqueStaveNotesIds()の戻り値)


 で、タイやスラーを独自で描く関数と音符と音符の間に描くトリル記号を描く関数を追加しました。いずれの関数も始点と終点のキー.xと.yを含むオブジェクトを引数に受け取ります。方向数値はstem_directionに準じて1が規定値で、1なら下向きに膨らんだタイ、スラーになり、トリルは旗が上向きのときのトリル記号になり-1なら逆向きです。insertTiePathToSVGが引数にとる深さ数値は10ピクセル±2がベジェ曲線のハンドル値になるカーブの深さになります。もっと深くしたい場合は大きい値を指定するとよいですが、カーブの内側と外側の±2は固定なので、薄い線になるでしょう。


 トリルの時は4分音符の長さで行うときは旗の無い8分音符が2つの間をすばやく何回か繰り返すという意味なので8分音符で描いてから、旗を消すという処理が必要になります。2分音符のときは2分音符の符頭に置き換えないとだめでしょう。全音符のときは2分音符二つの旗と符棒を消さないと駄目ですね。符棒も旗も消す関数も必要かもしれませんね。あとでつくっておこうかな。


 最後の部分でupdateAllUniqueIdsに取得した符頭を消す全てのノートidの集合を処理する部分の精度をあげる改造をしました。前の項目までの処理だとノートに付随する付点を消したり、結局ほとんどのアクセントは使えないのですが、アクセント記号が消えたりする可能性がありました。


 タブ譜の音の高さはならす弦の高さで旗の付け根の位置をきめるだけの音の高さです。一番低い位置の弦か、高い位置の弦を音として指定するだけです。6弦は一番下の線で、E/4の位置ですから、G/4で旗の長さは十分でしょう。1弦の位置は五線譜の一個上の位置なので、A/5の位置で、そのままだと追加線が表示されますが、下向きの符棒なら、stem_directionを-1にして、F/5までの線でよいでしょう。そういう感じで音の高さを弦の位置におきかえて考えます。1弦でも装飾音符なら上向きの旗になることもあるので、その場合はB/5とかを指定してstem_directionを1というのもあるでしょう。でも大丈夫です。符頭消去処理では五線譜の追加線も消えるようになっていますので、きにせず、高い位置の弦も高い音符を使えばいいのです。1弦を描くために使った、五線譜で音符を書き始めるとバランスが難しくなってきますので、使わない方がよいでしょう。


 弦をひとつしかつかわない音なんかで、VexFlowの機能をアクセント記号を書きたいときには書けばいいでしょう。2弦以上同時に鳴らすアーティキュレーションは、符旗がながくなってしまうので、描けません。基本的には、手動でアーティキュレーション記号もBravuraフォントを使って描くのがよいでしょう。タブ譜を描くという目的のためにはアクセントは消さず、臨時記号は消した方がよさそうです。あと、追加の五線譜もタブ譜にはいらないので消す対象としました。四分音符と二分音符、全音符の符頭は消します。


 タブ譜の数字は自作フォントでは全角の数字に割り当てていますので、9までなら全角文字でいけます。10以降も全角文字2つの数字を使えばよいのでしょうけれど、つめつめにした専用の数字が違うコードポイントに格納されています。

 

タブ譜 フレット番号と旗表示


 コードは以下のとおりです。


<div id="yonet202403Mid_Output01"></div>
<script>
///////////////////////
(function(){
class Position {
  constructor(x = 0, y = 0) {
    this.x = x;
    this.y = y;
  }
}
var VF = Vex.Flow;
const Vocal = new Position();
const Guitar1Inst = new Position();
const Guitar2Inst = new Position();
const Guitar2Tab1 = new Position();
const BaseInst = new Position();
const BaseTab1 = new Position();
const DrumInst = new Position();
const PercInst = new Position();
const Stave9Pos = new Position();

var StaveBase1;
var StaveBase2;
var StaveBase3;
var StaveBase4;

const Perc_note1_1_0 = new Position();

var shiftGuitar1_1;
var shiftGuitar1_tab4_tr;

var shiftGuitar1_tab1;
var shiftGuitar1_tab2;
var shiftGuitar1_tab3;
var shiftGuitar1_tab4;
var shiftDrum1;
var shiftPerc1;

function insertBaseEndBarPathToSVG(Stave) {
  var newGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g');
  newGroup.setAttribute('transform', 'translate(0, 0)');
  var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
  var pathStr = 'M ' + (Stave.x + Stave.width) + ' ' + (Stave.y + 50) +
    ' L ' + (Stave.x + Stave.width) + ' ' + (Stave.y + 80);
  path.setAttribute('d', pathStr);
  path.setAttribute('stroke', 'black');
  path.setAttribute('stroke-width', '1');
  path.setAttribute('fill', 'none');
  newGroup.appendChild(path);
  svgElement.appendChild(newGroup);
}

function insertTiePathToSVG(StartPos, EndPos, Direction = 1, Depth = 10) {
  var newGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g');
  newGroup.setAttribute('transform', 'translate(0, 0)');
  var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
  var pathStr = 'M' + (StartPos.x) + ' ' + (StartPos.y) + 'Q' + (StartPos.x + (EndPos.x - StartPos.x)/2) + ' ' + ((StartPos.y + EndPos.y)/2 + Direction * (Depth - 2)) + 
    ',' + (EndPos.x) + ' ' + (EndPos.y) + 'Q' + ((StartPos.x + EndPos.x)/2) + ' ' + (StartPos.y + (EndPos.y - StartPos.y)/2 + Direction * (Depth + 2)) + 
    ','  + (StartPos.x) + ' ' + (StartPos.y) + 'Z';
  path.setAttribute('d', pathStr);
  path.setAttribute('stroke', 'none');
  path.setAttribute('stroke-width', '1');
  path.setAttribute('fill', 'black');
  newGroup.appendChild(path);
  svgElement.appendChild(newGroup);
}

function insertTrilPathToSVG(Shift, Direction = 1) {
  var newGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g');
  newGroup.setAttribute('transform', 'translate(0, 0)');
  var DirectionOffset = 0;
  if (Direction == -1) DirectionOffset = 60;
  var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
  var pathStr = 'M ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 40 + DirectionOffset) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 36 + DirectionOffset) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 36 + DirectionOffset) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset);
  path.setAttribute('d', pathStr);
  path.setAttribute('stroke', 'none');
  path.setAttribute('stroke-width', '1');
  path.setAttribute('fill', 'black');
  var path2 = document.createElementNS('http://www.w3.org/2000/svg', 'path');
  var pathStr2 = 'M ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset + Direction * 7) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 40 + DirectionOffset + Direction * 7) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 36 + DirectionOffset + Direction * 7) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 36 + DirectionOffset + Direction * 7) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset + Direction * 7);
  path2.setAttribute('d', pathStr2);
  path2.setAttribute('stroke', 'none');
  path2.setAttribute('stroke-width', '1');
  path2.setAttribute('fill', 'black');
  var path3 = document.createElementNS('http://www.w3.org/2000/svg', 'path');
  var pathStr3 = 'M ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset + Direction * 14) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 40 + DirectionOffset + Direction * 14) +
    ' L ' + (Shift[1].x + 11.934 - 5) + ' ' + (Shift[1].y - 36 + DirectionOffset + Direction * 14) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 36 + DirectionOffset + Direction * 14) +
    ' L ' + (Shift[0].x + 11.934 + 5) + ' ' + (Shift[0].y - 40 + DirectionOffset + Direction * 14);
  path3.setAttribute('d', pathStr3);
  path3.setAttribute('stroke', 'none');
  path3.setAttribute('stroke-width', '1');
  path3.setAttribute('fill', 'black');
  newGroup.appendChild(path);
  newGroup.appendChild(path2);
  newGroup.appendChild(path3);
  svgElement.appendChild(newGroup);
}


function insertTextToSVG(options) {
    var textContent = options.textContent;
    var strID = options.strID;
    var Stave_x = options.Stave_x || 0;
    var Stave_y = options.Stave_y || 0;
    var isOffset_x_abs = options.IsOffset_x_Abs || false;
    var Stave_x_Offset = options.Stave_x_Offset || 0;
    var Stave_y_Offset = options.Stave_y_Offset || 0;
    var StaveWidth = options.StaveWidth || 0;
    var StaveHeight = options.StaveHeight || 0;
    var StaveVerticalScale = options.StaveVerticalScale || 0;
    var fontSize = options.fontSize || 40;
    var fontFamily = options.fontFamily || "Bravura, Arial";
    var shift_x = options.shift_x || [0];
    var Rotate = options.Rotate || 0;
    var offset_sum = 0;
    var Stave_x_Offset_Value = 0;
    var Stave_y_Offset_Value = 0;
    var last_Stave_x_Offset = 0;
    var last_Stave_y_Offset = 0;
    var last_textContent = "";
    shift_x.forEach(function(offset, index) {
        offset_sum = offset_sum + offset;
        var newText = document.createElementNS('http://www.w3.org/2000/svg', 'text');
        newText.setAttribute('id', strID + '_' + index); // テキスト要素にIDを付ける
        newText.setAttribute('x', 0);
        newText.setAttribute('y', 0);
        newText.setAttribute('font-family', fontFamily);
        newText.setAttribute('font-size', fontSize);
        newText.setAttribute('fill', 'black');

        if(typeof textContent === "string"){
          newText.textContent = textContent;
        }
        else{
          if(textContent.length - 1 < index){
            newText.textContent = last_textContent;
          }
          else{
            newText.textContent = textContent[index];
            last_textContent = textContent[index];
          }
        }

        if(Stave_x_Offset.length - 1 < index){
          Stave_x_Offset_Value = last_Stave_x_Offset;
        }
        else{
          if(Stave_x_Offset.length >= 2){
            Stave_x_Offset_Value = Stave_x_Offset[index];
            last_Stave_x_Offset = Stave_x_Offset[index];
          }
          else{
            Stave_x_Offset_Value = Stave_x_Offset;
          }
        }

        if(Stave_y_Offset.length - 1 < index){
          Stave_y_Offset_Value = last_Stave_y_Offset;
        }
        else{
          if(Stave_y_Offset.length >= 2){
            Stave_y_Offset_Value = Stave_y_Offset[index];
            last_Stave_y_Offset = Stave_y_Offset[index];
          }
          else{
            Stave_y_Offset_Value = Stave_y_Offset;
          }
        }
        var textGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g');
        if(Rotate != 0){
          textGroup.setAttribute('transform', 'rotate(' + Rotate + ' ' + 0 + ' ' + 0 + ')');
          textGroup.appendChild(newText);
          svgElement.appendChild(textGroup);
        }
        else{
          svgElement.appendChild(newText);
        }
        (function() {
            var textWidth = newText.getBBox().width;
            var textHeight = newText.getBBox().height;
            var horizontalScale;
            if (typeof StaveWidth === 'undefined' || StaveWidth == 0) {
                horizontalScale = 1;
            } 
            else {
                horizontalScale = StaveWidth / textWidth;
            }
            var verticalScale;
            if (typeof StaveHeight === 'undefined' || StaveHeight == 0) {
                verticalScale = 1;
            } 
            else if (StaveVerticalScale != 0) {
                verticalScale = StaveVerticalScale;
            } 
            else {
                verticalScale = StaveHeight / textHeight;
            }
            if(isOffset_x_abs){
              var StavePos_x = offset.x + Stave_x_Offset_Value;
              var StavePos_y = offset.y + Stave_y_Offset_Value;
            }
            else{
              var StavePos_x = Stave_x + Stave_x_Offset + offset_sum;
              var StavePos_y = Stave_y + Stave_y_Offset;
            }

            newText.setAttribute('transform', 'translate(' + StavePos_x + ',' + StavePos_y + ') scale(' + horizontalScale + ',' + verticalScale + ')');

            if(Rotate != 0){
              textGroup.setAttribute('transform', 'rotate(' + Rotate + ' ' + StavePos_x + ' ' + StavePos_y + ')');
            }
        })();

        if(Rotate != 0){
          textGroup.appendChild(newText);
          svgElement.appendChild(textGroup);
        }
        else{
          svgElement.appendChild(newText);
        }
    });
}

var allUniqueIds = [];
var allFlagUniqueIds = [];
(function(){
function addShift(notes, arrx = [], arry = []) {
 
  let tempnote;
  let retShift = [];
  
  for(let i = 0; i < arrx.length || i == 0; i++){
    const pos = new Position();
    //notesのchildrenの各要素について処理
    if(arrx.length === 0){
      tempnote = notes;
    }
    else{
      tempnote = notes[arrx[i]];
      temp_y = arry[i];
    }
    pos.x = tempnote.getAbsoluteX();
    pos.y = tempnote.getStave().getYForLine(temp_y);

    retShift.push(pos);
  }
  return retShift;
}

var UniqueIds;
function getUniqueNoteheadIds(notes, arr = []) {
    //すべてのidを格納するためのセットを作成
    let tempnote;
    uniqueIds = new Set();
    for(let i = 0; i < arr.length || i == 0; i++){
    //notesのchildrenの各要素について処理
      if(arr.length === 0){
        tempnote = notes;
      }
      else{
        tempnote = notes[arr[i]];
      }
      tempnote.children.forEach(child => {
        //typeが"notehead"であるかチェックし、idを取得
        if (child.attrs){
          if(child.attrs.type === "NoteHead") {
            uniqueIds.add(child.attrs.id);
          }
        }
      });
    }
    // セットを配列に変換して戻り値として返す
    return Array.from(uniqueIds);
}

function updateAllUniqueIds(UniqueIds) {
    // allUniqueIdsにUniqueIdsを追加または結合
    if (allUniqueIds.length === 0) {//allUniqueIdsはグローバルな変数
      // allUniqueIdsが空の場合、UniqueIdsをそのままコピー
      allUniqueIds = [...UniqueIds];//スプレッド演算子で要素の中身を書き出す。
    } else {
      UniqueIds.forEach(id => {
        if (!allUniqueIds.includes(id)) {
            allUniqueIds.push(id);
        }
      });
    }
    // 更新されたallUniqueIdsを戻り値として返す
    return allUniqueIds;
}

var SteveNoteUniqueIds;
function getUniqueStaveNotesIds(notes, arr = []) {
    //すべてのidを格納するためのセットを作成
    let tempnote;
    uniqueIds = new Set();
    for(let i = 0; i < arr.length || i == 0; i++){
    //notesのchildrenの各要素について処理
      if(arr.length === 0){
        tempnote = notes;
      }
      else{
        tempnote = notes[arr[i]];
      }
      if (tempnote.attrs){
        if(tempnote.attrs.type === "StaveNote") {
          uniqueIds.add(tempnote.attrs.id);
        }
      }
    }
    // セットを配列に変換して戻り値として返す
    return Array.from(uniqueIds);
}

function updateAllFlagUniqueIds(FlagUniqueIds) {
    // allUniqueIdsにUniqueIdsを追加または結合
    if (allFlagUniqueIds.length === 0) {
      // allUniqueIdsが空の場合、UniqueIdsをそのままコピー
      allFlagUniqueIds = [...FlagUniqueIds];//スプレッド演算子で要素の中身を書き出す。
    } else {
      FlagUniqueIds.forEach(id => {
        if (!allFlagUniqueIds.includes(id)) {
            allFlagUniqueIds.push(id);
        }
      });
    }
    // 更新されたallUniqueIdsを戻り値として返す
    return allFlagUniqueIds;
}

function dotted(staveNote, noteIndex = -1) {
  if (noteIndex < 0) {
    Dot.buildAndAttach([staveNote], {
      all: true
    });
  } 
  else {
    for(noteIndexValue of noteIndex){
      Dot.buildAndAttach([staveNote], {
        index: noteIndexValue
      });
    }
  }
  return staveNote;
}

const {
  Factory,
  Stave,
  StaveNote,
  Formatter,
  Voice,
  StaveTie,
  BarLine,
  Beam,
  Dot,
  StaveConnector,
  Modifier,
  RenderContext,
  TextDynamics,
  Articulation,
  TextNote,
  Crescendo,
  Renderer
} = Vex.Flow;

let nscale = 0.64;
let nwidth = 1040;
let nheight = 1120;

let nHeadMargin = 70;
let nStaveWidth = 350;

const f = new Factory({ 
  renderer: { elementId: 'yonet202403Mid_Output01', width: nwidth, height: nheight * nscale }
  });
const ctx = f.getContext();
ctx.scale(nscale, nscale);

const defaultStyle = {
  lineWidth: ctx.lineWidth,
  strokeStyle: ctx.strokeStyle,
};

for (let i = 0; i <= nwidth * (1 / nscale); i += 10) {
  ctx.beginPath();
  ctx.moveTo(0 + i, 0);
  ctx.lineTo(0 + i, nheight);
  if (i % 100 === 0){
    ctx.setLineWidth(1);
    ctx.setStrokeStyle('rgba(200, 200, 200, 0.8)');
  }
  else{
    ctx.setLineWidth(0.5);
    ctx.setStrokeStyle('rgba(230, 230, 230, 0.8)');
  }
  ctx.stroke();
}

for (let i = 0; i <= nheight; i += 10) {
  ctx.beginPath();
  ctx.moveTo(0, i);
  ctx.lineTo(nwidth * (1 / nscale), i);
  if (i % 100 === 0){
    ctx.setLineWidth(1);
    ctx.setStrokeStyle('rgba(200, 200, 200, 0.8)');
  }
  else{
    ctx.setLineWidth(0.5);
    ctx.setStrokeStyle('rgba(230, 230, 230, 0.8)');
  }
  ctx.stroke();
}

ctx.lineWidth = defaultStyle.lineWidth;
ctx.strokeStyle = defaultStyle.strokeStyle;

const VocalSt1 = new Stave(80, 30, nHeadMargin + nStaveWidth).setContext(ctx);
VocalSt1.setClef("treble").setContext(ctx);
VocalSt1.setTimeSignature('4/4').setContext(ctx);
VocalSt1.addKeySignature('D').setContext(ctx);
VocalSt1.setMeasure(1);
VocalSt1.draw();

Vocal.x = VocalSt1.x - 30;
Vocal.y = VocalSt1.y + 90; 

const VocalSt2 = f.Stave({ x: VocalSt1.width + VocalSt1.x, y: VocalSt1.y, width: nStaveWidth });
VocalSt2.setMeasure(2);
VocalSt2.setContext(ctx).draw();

const VocalSt3 = new Stave(VocalSt2.width + VocalSt2.x, VocalSt1.y, nStaveWidth).setContext(ctx);
VocalSt3.setMeasure(3);
VocalSt3.draw();

const VocalSt4 = new Stave(VocalSt3.width + VocalSt3.x, VocalSt1.y, nStaveWidth).setContext(ctx);
VocalSt4.setMeasure(4);
VocalSt4.draw();

const Guitar1St1 = new Stave(VocalSt1.x, VocalSt1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Guitar1St1.addClef("treble").setContext(ctx);
Guitar1St1.addTimeSignature('4/4').setContext(ctx);
Guitar1St1.addKeySignature('D').setContext(ctx);
Guitar1St1.draw();

const Guitar1_notes1_1 = [
  new VF.StaveNote({ keys: ["a/3", "e/4", "a/4", "c/5"], duration: "2" }),
  new VF.StaveNote({ keys: ["e/5"], duration: "8", stem_direction: -1 }),
  dotted(new VF.StaveNote({ keys: ["c/6"], duration: "4d", stem_direction: -1 })),
];
const Guitar1_notes1_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

];
var Guitar1_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St1_1Voice.setStrict(true);
Guitar1_St1_1Voice.addTickables(Guitar1_notes1_1);

var Guitar1_St1_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St1_2Voice.setStrict(true);
Guitar1_St1_2Voice.addTickables(Guitar1_notes1_2);

var formatterGuitar1_St1_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_St1_2Voice, Guitar1_St1_1Voice]);
formatterGuitar1_St1_1.format([Guitar1_St1_2Voice, Guitar1_St1_1Voice], nStaveWidth - 20 - 10);
Guitar1_St1_1Voice.draw(ctx, Guitar1St1);
Guitar1_St1_2Voice.draw(ctx, Guitar1St1);

const Guitar1St2 = new Stave(Guitar1St1.width + Guitar1St1.x, Guitar1St1.y, nStaveWidth).setContext(ctx);
Guitar1St2.draw();

const Guitar1_gracenotes2 = [
  new VF.GraceNote({ keys: ['e/5', 'g/5'], duration: '8', slash: true })
  .addModifier(new VF.Accidental('#'), 1)
];

const Guitar1_notes2_1 = [
  new VF.StaveNote({ keys: ["f/5", "a/5"], duration: "8", stem_direction: -1 })
  .addModifier(new VF.Accidental('n'), 0),
  new VF.StaveNote({ keys: ["e/5", "g/5"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["f/5"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["e/5"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4", "d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["f/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["e/4"], duration: "8" }),
];
const Guitar1_notes2_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

];
Guitar1_notes2_1[0].addModifier(new VF.Articulation('a.').setPosition(3));
Guitar1_notes2_1[1].addModifier(new VF.Articulation('a.').setPosition(3));
Guitar1_notes2_1[2].addModifier(new VF.Articulation('a.').setPosition(3));
Guitar1_notes2_1[3].addModifier(new VF.Articulation('a.').setPosition(3));
Guitar1_notes2_1[4].addModifier(new VF.Articulation('a.').setPosition(4));
Guitar1_notes2_1[5].addModifier(new VF.Articulation('a.').setPosition(4));
Guitar1_notes2_1[6].addModifier(new VF.Articulation('a.').setPosition(4));
Guitar1_notes2_1[7].addModifier(new VF.Articulation('a.').setPosition(4));
Guitar1_notes2_1[0].addModifier(new VF.GraceNoteGroup(Guitar1_gracenotes2, true), 0);

const Guitar1_beam1_1 = new VF.Beam([Guitar1_notes2_1[0], Guitar1_notes2_1[1], Guitar1_notes2_1[2], Guitar1_notes2_1[3]]);
const Guitar1_beam1_2 = new VF.Beam([Guitar1_notes2_1[4], Guitar1_notes2_1[5], Guitar1_notes2_1[6], Guitar1_notes2_1[7]]);

var Guitar1_St2_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St2_1Voice.setStrict(true);
Guitar1_St2_1Voice.addTickables(Guitar1_notes2_1);

var Guitar1_St2_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St2_2Voice.setStrict(true);
Guitar1_St2_2Voice.addTickables(Guitar1_notes2_2);

var formatterGuitar1_St2_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_St2_2Voice, Guitar1_St2_1Voice]);
formatterGuitar1_St2_1.format([Guitar1_St2_2Voice, Guitar1_St2_1Voice], nStaveWidth - 30);
Guitar1_St2_1Voice.draw(ctx, Guitar1St2);
Guitar1_St2_2Voice.draw(ctx, Guitar1St2);

Guitar1_beam1_1.setContext(ctx).draw();
Guitar1_beam1_2.setContext(ctx).draw();

const Guitar1St3 = new Stave(Guitar1St2.width + Guitar1St2.x, Guitar1St1.y, nStaveWidth).setContext(ctx);
Guitar1St3.draw();

const Guitar1_notes3_1 = [
  new VF.StaveNote({ keys: ["g/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["e/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["e/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["e/4"], duration: "2" }),
];
const Guitar1_notes3_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

];
const Guitar1_beam3_1 = new VF.Beam([Guitar1_notes3_1[0], Guitar1_notes3_1[1], Guitar1_notes3_1[2], Guitar1_notes3_1[3]]);
const Guitar1_beam3_2 = new VF.Beam([Guitar1_notes3_1[4], Guitar1_notes3_1[5], Guitar1_notes3_1[6]]);

var Guitar1_St3_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St3_1Voice.setStrict(true);
Guitar1_St3_1Voice.addTickables(Guitar1_notes3_1);

var Guitar1_St3_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St3_2Voice.setStrict(true);
Guitar1_St3_2Voice.addTickables(Guitar1_notes3_2);

var formatterGuitar1_St3_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_St3_2Voice, Guitar1_St3_1Voice]);
formatterGuitar1_St3_1.format([Guitar1_St3_2Voice, Guitar1_St3_1Voice], nStaveWidth - 30);
Guitar1_St3_1Voice.draw(ctx, Guitar1St3);
Guitar1_St3_2Voice.draw(ctx, Guitar1St3);

Guitar1_beam3_1.setContext(ctx).draw();
Guitar1_beam3_2.setContext(ctx).draw();

const Guitar1_ties3 = [
    new StaveTie({
        first_note: Guitar1_notes3_1[0],
        last_note: Guitar1_notes3_1[1],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes3_1[1],
        last_note: Guitar1_notes3_1[2],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes3_1[2],
        last_note: Guitar1_notes3_1[3],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes3_1[3],
        last_note: Guitar1_notes3_1[4],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes3_1[6],
        last_note: Guitar1_notes3_1[7],
        first_indices: [0],
        last_indices: [0],
    }),
];

Guitar1_ties3.forEach((t) => {
    t.setContext(ctx).draw();
});

var Guitar1_vibrato3 = new VF.VibratoBracket({
  start: Guitar1_notes3_1[7],
  stop: null,
});
Guitar1_vibrato3.setLine(0);
Guitar1_vibrato3.setHarsh(true);
Guitar1_vibrato3.setContext(ctx).draw();

const Guitar1St4 = new Stave(Guitar1St3.width + Guitar1St3.x, Guitar1St1.y, nStaveWidth).setContext(ctx);
Guitar1St4.draw();

const Guitar1_gracenotes4 = [
  new VF.GraceNote({ keys: ['a/4'], duration: '8', slash: true })
];

const Guitar1_notes4_1 = [
  new VF.StaveNote({ keys: ["g/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["a/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["b/4"], duration: "8" }),
  new VF.StaveNote({ keys: ["b/4"], duration: "4" }),
  new VF.StaveNote({ keys: ["b/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 }),
];
const Guitar1_notes4_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

];
Guitar1_notes4_1[7].addModifier(new VF.Articulation('a.').setPosition(3));
Guitar1_notes4_1[3].addModifier(new VF.GraceNoteGroup(Guitar1_gracenotes4, true), 0);

SteveNoteUniqueIds = getUniqueStaveNotesIds(Guitar1_notes4_1, [0, 1]);
allFlagUniqueIds = updateAllFlagUniqueIds(SteveNoteUniqueIds);

const Guitar1_beam4_1 = new VF.Beam([Guitar1_notes4_1[2], Guitar1_notes4_1[3]]);
const Guitar1_beam4_2 = new VF.Beam([Guitar1_notes4_1[5], Guitar1_notes4_1[6], Guitar1_notes4_1[7]]);

var Guitar1_St4_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St4_1Voice.setStrict(true);
Guitar1_St4_1Voice.addTickables(Guitar1_notes4_1);

var Guitar1_St4_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_St4_2Voice.setStrict(true);
Guitar1_St4_2Voice.addTickables(Guitar1_notes4_2);

var formatterGuitar1_St4_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_St4_2Voice, Guitar1_St4_1Voice]);
formatterGuitar1_St4_1.format([Guitar1_St4_2Voice, Guitar1_St4_1Voice], nStaveWidth - 30);
Guitar1_St4_1Voice.draw(ctx, Guitar1St4);
Guitar1_St4_2Voice.draw(ctx, Guitar1St4);

Guitar1_beam4_1.setContext(ctx).draw();
Guitar1_beam4_2.setContext(ctx).draw();

shiftGuitar1_1 = addShift(
  Guitar1_notes4_1, 
  [0, 1],
  [4, 3.5]
);

const Guitar1_ties4 = [
    new StaveTie({
        first_note: Guitar1_notes4_1[0],
        last_note: Guitar1_notes4_1[1],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes4_1[1],
        last_note: Guitar1_notes4_1[2],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes4_1[3],
        last_note: Guitar1_notes4_1[4],
        first_indices: [0],
        last_indices: [0],
    }),
    new StaveTie({
        first_note: Guitar1_notes4_1[5],
        last_note: Guitar1_notes4_1[6],
        first_indices: [0],
        last_indices: [0],
    }),
];

Guitar1_ties4.forEach((t) => {
    t.setContext(ctx).draw();
});


const Guitar1_tab1 = new Stave(Guitar1St1.x, Guitar1St1.y + 110, nHeadMargin + nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar1_tab1.setConfigForLine(i, {visible: false} );
}
Guitar1_tab1.draw();

const Guitar1_tab2 = new Stave(Guitar1_tab1.width + Guitar1_tab1.x, Guitar1_tab1.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar1_tab2.setConfigForLine(i, {visible: false} );
}
Guitar1_tab2.draw();

const Guitar1_tab3 = new Stave(Guitar1_tab2.width + Guitar1_tab2.x, Guitar1_tab1.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar1_tab3.setConfigForLine(i, {visible: false} );
}
Guitar1_tab3.draw();

const Guitar1_tab4 = new Stave(Guitar1_tab3.width + Guitar1_tab3.x, Guitar1_tab1.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar1_tab4.setConfigForLine(i, {visible: false} );
}
Guitar1_tab4.draw();



const Guitar1_Tab1 = new Stave(Guitar1St1.x, Guitar1St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Guitar1_Tab1.draw();

Stave9Pos.x = Guitar1_Tab1.x;
Stave9Pos.y = Guitar1_Tab1.y;

var connector9_2 = new VF.StaveConnector(Guitar1St1, Guitar1_Tab1);
connector9_2.setType(VF.StaveConnector.type.BRACKET);
connector9_2.setContext(ctx);
connector9_2.draw();

Guitar1Inst.x = VocalSt1.x - 30;
Guitar1Inst.y = Guitar1St1.y + ((Guitar1_Tab1.y - Guitar1St1.y) / 2) + 90; 


const Guitar1_Tab1_1 = new Stave(Guitar1_Tab1.x + nHeadMargin + 20, Guitar1_Tab1.y, 0).setContext(ctx);
Guitar1_Tab1_1.setBegBarType(VF.Barline.type.NONE);
Guitar1_Tab1_1.setEndBarType(VF.Barline.type.NONE);
Guitar1_Tab1_1.draw();

const Guitar1_tab_notes1_1 = [
  new VF.GhostNote({ keys: ["a/3", "e/4", "a/4", "c/5"], duration: "2" }),
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 }),
  dotted(new VF.StaveNote({ keys: ["f/5"], duration: "4d", stem_direction: -1 })),
];
const Guitar1_tab_notes1_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

];
UniqueIds = getUniqueNoteheadIds(Guitar1_tab_notes1_1, [1, 2]);
allUniqueIds = updateAllUniqueIds(UniqueIds);

var Guitar1_tab_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St1_1Voice.setStrict(true);
Guitar1_tab_St1_1Voice.addTickables(Guitar1_tab_notes1_1);

var Guitar1_tab_St1_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St1_2Voice.setStrict(true);
Guitar1_tab_St1_2Voice.addTickables(Guitar1_tab_notes1_2);

var formatterGuitar1_tab_St1_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_tab_St1_2Voice, Guitar1_tab_St1_1Voice]);
formatterGuitar1_tab_St1_1.format([Guitar1_tab_St1_2Voice, Guitar1_tab_St1_1Voice], nStaveWidth - 20 - 10);
Guitar1_tab_St1_1Voice.draw(ctx, Guitar1_Tab1_1);
Guitar1_tab_St1_2Voice.draw(ctx, Guitar1_Tab1_1);

shiftGuitar1_tab1 = addShift(
  Guitar1_tab_notes1_1, 
  [0, 0, 0, 0, 1,  2],
  [3, 2, 1, 0, 1, -1]
);



const Guitar1_Tab2 = new Stave(Guitar1_Tab1.width + Guitar1_Tab1.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
Guitar1_Tab2.draw();

const Guitar1_tab_gracenotes2 = [
  new VF.GraceNote({ keys: ['a/5'], duration: '8', slash: true })
  .addModifier(new VF.Accidental('#'), 0)
];

const Guitar1_tab_notes2_1 = [
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 })
  .addModifier(new VF.Accidental('n'), 0),
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["f/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["b/4"], duration: "8" }),
];
const Guitar1_tab_notes2_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

];
Guitar1_tab_notes2_1[0].addModifier(new VF.GraceNoteGroup(Guitar1_tab_gracenotes2, false), 0);

UniqueIds = getUniqueNoteheadIds(Guitar1_tab_notes2_1, [0, 1, 2, 3, 4, 5, 6, 7]);
allUniqueIds = updateAllUniqueIds(UniqueIds);

const Guitar1_tab_beam2_1 = new VF.Beam([Guitar1_tab_notes2_1[0], Guitar1_tab_notes2_1[1], Guitar1_tab_notes2_1[2], Guitar1_tab_notes2_1[3]]);
const Guitar1_tab_beam2_2 = new VF.Beam([Guitar1_tab_notes2_1[4], Guitar1_tab_notes2_1[5], Guitar1_tab_notes2_1[6], Guitar1_tab_notes2_1[7]]);

var Guitar1_tab_St2_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St2_1Voice.setStrict(true);
Guitar1_tab_St2_1Voice.addTickables(Guitar1_tab_notes2_1);

var Guitar1_tab_St2_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St2_2Voice.setStrict(true);
Guitar1_tab_St2_2Voice.addTickables(Guitar1_tab_notes2_2);

var formatterGuitar1_tab_St2_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_tab_St2_2Voice, Guitar1_tab_St2_1Voice]);
formatterGuitar1_tab_St2_1.format([Guitar1_tab_St2_2Voice, Guitar1_tab_St2_1Voice], nStaveWidth - 20);
Guitar1_tab_St2_1Voice.draw(ctx, Guitar1_Tab2);
Guitar1_tab_St2_2Voice.draw(ctx, Guitar1_Tab2);

shiftGuitar1_tab2 = addShift(
  Guitar1_tab_notes2_1, 
  [0, 0, 0, 0, 1, 1, 2, 3, 4, 4, 5, 6, 7],
  [1, 0, 1, 0, 1, 0, 0, 1, 2, 1, 2, 2, 3]
);

Guitar1_tab_beam2_1.setContext(ctx).draw();
Guitar1_tab_beam2_2.setContext(ctx).draw();

//const Curve1_1to2_2 = new Curve(
//  Guitar1_tab_gracenotes2[0],
//  Guitar1_tab_notes2_1[0],
//  {
//    cps: [
//      { x: 0, y:10 },
//      { x: 0, y:10 },
//    ],
//  },
//);



const Guitar1_Tab3 = new Stave(Guitar1_Tab2.width + Guitar1_Tab2.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
Guitar1_Tab3.draw();

const Guitar1_tab_notes3_1 = [
  new VF.StaveNote({ keys: ["d/5"], duration: "16" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "16" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "16" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "16" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "16" }),
  new VF.StaveNote({ keys: ["g/4"], duration: "16" }),
  new VF.GhostNote({ keys: ["b/4"], duration: "2" }),
];
const Guitar1_tab_notes3_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

];
UniqueIds = getUniqueNoteheadIds(Guitar1_tab_notes3_1, [0, 1, 2, 3, 4, 5, 6, 7]);
allUniqueIds = updateAllUniqueIds(UniqueIds);

const Guitar1_tab_beam3_1 = new VF.Beam([Guitar1_tab_notes3_1[0], Guitar1_tab_notes3_1[1], Guitar1_tab_notes3_1[2], Guitar1_tab_notes3_1[3]]);
const Guitar1_tab_beam3_2 = new VF.Beam([Guitar1_tab_notes3_1[4], Guitar1_tab_notes3_1[5], Guitar1_tab_notes3_1[6]]);

var Guitar1_tab_St3_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St3_1Voice.setStrict(true);
Guitar1_tab_St3_1Voice.addTickables(Guitar1_tab_notes3_1);

var Guitar1_tab_St3_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St3_2Voice.setStrict(true);
Guitar1_tab_St3_2Voice.addTickables(Guitar1_tab_notes3_2);

var formatterGuitar1_tab_St3_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_tab_St3_2Voice, Guitar1_tab_St3_1Voice]);
formatterGuitar1_tab_St3_1.format([Guitar1_tab_St3_2Voice, Guitar1_tab_St3_1Voice], nStaveWidth - 20);
Guitar1_tab_St3_1Voice.draw(ctx, Guitar1_Tab3);
Guitar1_tab_St3_2Voice.draw(ctx, Guitar1_Tab3);

shiftGuitar1_tab3 = addShift(
  Guitar1_tab_notes3_1, 
  [0, 1, 2, 3, 4, 5, 6, 7],
  [2, 2, 2, 2, 2, 4, 4, 4]
);

Guitar1_tab_beam3_1.setContext(ctx).draw();
Guitar1_tab_beam3_2.setContext(ctx).draw();

var Guitar1_tab_vibrato3 = new VF.VibratoBracket({
  start: Guitar1_tab_notes3_1[7],
  stop: null,
});
Guitar1_tab_vibrato3.setLine(1);
Guitar1_tab_vibrato3.setHarsh(true);
Guitar1_tab_vibrato3.setContext(ctx).draw();



const Guitar1_Tab4 = new Stave(Guitar1_Tab3.width + Guitar1_Tab3.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
Guitar1_Tab4.draw();

const Guitar1_tab_gracenotes4 = [
  new VF.GraceNote({ keys: ['d/5'], duration: '8', slash: true })
];

const Guitar1_tab_notes4_1 = [
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "8" }),
  new VF.StaveNote({ keys: ["d/5"], duration: "4" }),
  new VF.StaveNote({ keys: ["b/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["b/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["b/4"], duration: "8", stem_direction: -1 }),
];
const Guitar1_tab_notes4_2 = [
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),
  new VF.GhostNote({ keys: ["f/4"], duration: "16"}),

];
Guitar1_tab_notes4_1[3].addModifier(new VF.GraceNoteGroup(Guitar1_tab_gracenotes4, false), 0);

SteveNoteUniqueIds = getUniqueStaveNotesIds(Guitar1_tab_notes4_1, [0, 1]);
allFlagUniqueIds = updateAllFlagUniqueIds(SteveNoteUniqueIds);

UniqueIds = getUniqueNoteheadIds(Guitar1_tab_notes4_1, [0, 1, 2, 3, 4, 5, 6, 7]);
allUniqueIds = updateAllUniqueIds(UniqueIds);

const Guitar1_tab_beam4_1 = new VF.Beam([Guitar1_tab_notes4_1[2], Guitar1_tab_notes4_1[3]]);
const Guitar1_tab_beam4_2 = new VF.Beam([Guitar1_tab_notes4_1[5], Guitar1_tab_notes4_1[6], Guitar1_tab_notes4_1[7]]);

var Guitar1_tab_St4_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St4_1Voice.setStrict(true);
Guitar1_tab_St4_1Voice.addTickables(Guitar1_tab_notes4_1);

var Guitar1_tab_St4_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Guitar1_tab_St4_2Voice.setStrict(true);
Guitar1_tab_St4_2Voice.addTickables(Guitar1_tab_notes4_2);

var formatterGuitar1_tab_St4_1 = new Vex.Flow.Formatter().joinVoices([Guitar1_tab_St4_2Voice, Guitar1_tab_St4_1Voice]);
formatterGuitar1_tab_St4_1.format([Guitar1_tab_St4_2Voice, Guitar1_tab_St4_1Voice], nStaveWidth - 20);
Guitar1_tab_St4_1Voice.draw(ctx, Guitar1_Tab4);
Guitar1_tab_St4_2Voice.draw(ctx, Guitar1_Tab4);

shiftGuitar1_tab4 = addShift(
  Guitar1_tab_notes4_1, 
  [0, 1, 2, 3, 3, 4, 5, 6, 7, 7],
  [2, 2, 2, 2, 2, 2, 1, 1, 1, 1]
);

shiftGuitar1_tab4_tr = addShift(
  Guitar1_tab_notes4_1, 
  [0, 1],
  [3, 2.5]
);

Guitar1_tab_beam4_1.setContext(ctx).draw();
Guitar1_tab_beam4_2.setContext(ctx).draw();


const Guitar2_St1 = new Stave(Guitar1_Tab1.x, Guitar1_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Guitar2_St1.addClef("treble").setContext(ctx);
Guitar2_St1.addTimeSignature('4/4').setContext(ctx);
Guitar2_St1.addKeySignature('D').setContext(ctx);
Guitar2_St1.draw();

const Guitar2_St2 = new Stave(Guitar2_St1.width + Guitar2_St1.x, Guitar2_St1.y, nStaveWidth).setContext(ctx);
Guitar2_St2.draw();

const Guitar2_St3 = new Stave(Guitar2_St2.width + Guitar2_St2.x, Guitar2_St2.y, nStaveWidth).setContext(ctx);
Guitar2_St3.draw();

const Guitar2_St4 = new Stave(Guitar2_St3.width + Guitar2_St3.x, Guitar2_St3.y, nStaveWidth).setContext(ctx);
Guitar2_St4.draw();

const Guitar2_Tab1 = new Stave(Guitar2_St1.x, Guitar2_St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Guitar2_Tab1.draw();

Guitar2Tab1.x = Guitar2_Tab1.x;
Guitar2Tab1.y = Guitar2_Tab1.y;

const Guitar2_Tab2 = new Stave(Guitar2_Tab1.width + Guitar2_Tab1.x, Guitar2_Tab1.y, nStaveWidth).setContext(ctx);
Guitar2_Tab2.draw();

const Guitar2_Tab3 = new Stave(Guitar2_Tab2.width + Guitar2_Tab2.x, Guitar2_Tab2.y, nStaveWidth).setContext(ctx);
Guitar2_Tab3.draw();

const Guitar2_Tab4 = new Stave(Guitar2_Tab3.width + Guitar2_Tab3.x, Guitar2_Tab3.y, nStaveWidth).setContext(ctx);
Guitar2_Tab4.draw();

var Guitar2_connect = new VF.StaveConnector(Guitar2_St1, Guitar2_Tab1);
Guitar2_connect.setType(VF.StaveConnector.type.BRACKET);
Guitar2_connect.setContext(ctx);
Guitar2_connect.draw();

const Guitar2_Tab1_tab = new Stave(Guitar2_Tab1.x, Guitar2_Tab1.y - 10, nHeadMargin + nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar2_Tab1_tab.setConfigForLine(i, {visible: false} );
}
Guitar2_Tab1_tab.draw();

const Guitar2_Tab2_tab = new Stave(Guitar2_Tab1_tab.width + Guitar2_Tab1_tab.x, Guitar2_Tab1_tab.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar2_Tab2_tab.setConfigForLine(i, {visible: false} );
}
Guitar2_Tab2_tab.draw();

const Guitar2_Tab3_tab = new Stave(Guitar2_Tab2_tab.width + Guitar2_Tab2_tab.x, Guitar2_Tab2_tab.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar2_Tab3_tab.setConfigForLine(i, {visible: false} );
}
Guitar2_Tab3_tab.draw();

const Guitar2_Tab4_tab = new Stave(Guitar2_Tab3_tab.width + Guitar2_Tab3_tab.x, Guitar2_Tab3_tab.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 0) continue;
  Guitar2_Tab4_tab.setConfigForLine(i, {visible: false} );
}
Guitar2_Tab4_tab.draw();

Guitar2Inst.x = Guitar2_St1.x - 30;
Guitar2Inst.y = Guitar2_St1.y + ((Guitar2_Tab1.y - Guitar2_St1.y) / 2) + 90; 

const Base_St1 = new Stave(Guitar2_Tab1.x, Guitar2_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Base_St1.addClef("bass").setContext(ctx);
Base_St1.addTimeSignature('4/4').setContext(ctx);
Base_St1.addKeySignature('D').setContext(ctx);
Base_St1.draw();

const Base_St2 = new Stave(Base_St1.width + Base_St1.x, Base_St1.y, nStaveWidth).setContext(ctx);
Base_St2.draw();

const Base_St3 = new Stave(Base_St2.width + Base_St2.x, Base_St2.y, nStaveWidth).setContext(ctx);
Base_St3.draw();

const Base_St4 = new Stave(Base_St3.width + Base_St3.x, Base_St3.y, nStaveWidth).setContext(ctx);
Base_St4.draw();

const Base_Tab1 = new Stave(Base_St1.x, Base_St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Base_Tab1.setEndBarType(VF.Barline.type.NONE);
for (var i = 0; i < 5; i++) {
  if (i != 0) continue;
  Base_Tab1.setConfigForLine(i, {visible: false} );
}
Base_Tab1.draw();

BaseTab1.x = Base_Tab1.x;
BaseTab1.y = Base_Tab1.y;

BaseInst.x = Base_St1.x - 30;
BaseInst.y = Base_St1.y + ((Base_Tab1.y - Base_St1.y) / 2) + 90; 

StaveBase1 = Base_Tab1;

const Base_Tab2 = new Stave(Base_Tab1.width + Base_Tab1.x, Base_Tab1.y, nStaveWidth).setContext(ctx);
Base_Tab2.setBegBarType(VF.Barline.type.NONE);
Base_Tab2.setEndBarType(VF.Barline.type.NONE);
for (var i = 0; i < 5; i++) {
  if (i != 0) continue;
  Base_Tab2.setConfigForLine(i, {visible: false} );
}
Base_Tab2.draw();

StaveBase2 = Base_Tab2;

const Base_Tab3 = new Stave(Base_Tab2.width + Base_Tab2.x, Base_Tab2.y, nStaveWidth).setContext(ctx);
Base_Tab3.setBegBarType(VF.Barline.type.NONE);
Base_Tab3.setEndBarType(VF.Barline.type.NONE);
for (var i = 0; i < 5; i++) {
  if (i != 0) continue;
  Base_Tab3.setConfigForLine(i, {visible: false} );
}
Base_Tab3.draw();

StaveBase3 = Base_Tab3;

const Base_Tab4 = new Stave(Base_Tab3.width + Base_Tab3.x, Base_Tab3.y, nStaveWidth).setContext(ctx);
Base_Tab4.setBegBarType(VF.Barline.type.NONE);
Base_Tab4.setEndBarType(VF.Barline.type.NONE);
for (var i = 0; i < 5; i++) {
  if (i != 0) continue;
  Base_Tab4.setConfigForLine(i, {visible: false} );
}
Base_Tab4.draw();

StaveBase4 = Base_Tab4;

var Base_connect = new VF.StaveConnector(Base_St1, Base_Tab1);
Base_connect.setType(VF.StaveConnector.type.BRACKET);
Base_connect.setContext(ctx);
Base_connect.draw();

const Drum_St1 = new Stave(Base_Tab1.x, Base_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Drum_St1.addClef("bass").setContext(ctx);
Drum_St1.addTimeSignature('4/4').setContext(ctx);
Drum_St1.draw();

DrumInst.x = Drum_St1.x - 30;
DrumInst.y = Drum_St1.y + 90; 

const Drum_St1_1 = new Stave(nHeadMargin + Base_Tab1.x, Base_Tab1.y + 120, 0).setContext(ctx);
Drum_St1_1.setBegBarType(VF.Barline.type.NONE);
Drum_St1_1.setEndBarType(VF.Barline.type.NONE);
Drum_St1_1.draw();

const Drum_notes1_1 = [
  new StaveNote({ keys: ["f/4"], duration: "4", stem_direction: -1 }),
  new StaveNote({ keys: ["c/4"], duration: "4r" }),
  new StaveNote({ keys: ["c/4"], duration: "8r" }),
  new StaveNote({ keys: ["f/4"], duration: "8", stem_direction: -1 }),
  new StaveNote({ keys: ["c/4"], duration: "8r" }),
  new StaveNote({ keys: ["f/4"], duration: "8", stem_direction: -1 })
];
const Drum_beam1_1 = new VF.Beam([Drum_notes1_1[3],Drum_notes1_1[5]]);

var Drum_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Drum_St1_1Voice.setStrict(true);
Drum_St1_1Voice.addTickables(Drum_notes1_1);

const Drum_St1_2 = new Stave(nHeadMargin + Base_Tab1.x, Base_Tab1.y + 120, 0).setContext(ctx);
Drum_St1_2.setBegBarType(VF.Barline.type.NONE);
Drum_St1_2.setEndBarType(VF.Barline.type.NONE);
Drum_St1_2.draw();

const Drum_notes1_2 = [
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "16", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "16", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["c/5"], duration: "8", stem_direction: 1 }),
  new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 })
];

const Drum_notes1_3 = [
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),

  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),

  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),

  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 }),
  new VF.GhostNote({ keys: ["a/5"], duration: "16", stem_direction: 1 })
];

UniqueIds = getUniqueNoteheadIds(Drum_notes1_2, [0, 1, 3, 5, 6, 8]);
allUniqueIds = updateAllUniqueIds(UniqueIds);

const Drum_beam1_2_1 = new VF.Beam([Drum_notes1_2[0], Drum_notes1_2[1]]);
const Drum_beam1_2_2 = new VF.Beam([Drum_notes1_2[2], Drum_notes1_2[3], Drum_notes1_2[4]]);
const Drum_beam1_2_3 = new VF.Beam([Drum_notes1_2[5], Drum_notes1_2[6], Drum_notes1_2[7], Drum_notes1_2[8]]);

var Drum_St1_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Drum_St1_2Voice.setStrict(true);
Drum_St1_2Voice.addTickables(Drum_notes1_2);

var Drum_St1_3Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Drum_St1_3Voice.setStrict(true);
Drum_St1_3Voice.addTickables(Drum_notes1_3);

var formatterDrum_St1_2 = new Vex.Flow.Formatter().joinVoices([Drum_St1_3Voice, Drum_St1_1Voice, Drum_St1_2Voice]);
//formatter13_2.formatToStave([stave13_3Voice, stave13_1Voice, stave13_2Voice], stave13_2);
formatterDrum_St1_2.format([Drum_St1_3Voice, Drum_St1_1Voice, Drum_St1_2Voice], nStaveWidth - 30);
Drum_St1_1Voice.draw(ctx, Drum_St1_2);
Drum_St1_2Voice.draw(ctx, Drum_St1_2);

Drum_beam1_1.setContext(ctx).draw();

Drum_beam1_2_1.setContext(ctx).draw();
Drum_beam1_2_2.setContext(ctx).draw();
Drum_beam1_2_3.setContext(ctx).draw();

shiftDrum1 = addShift(
  Drum_notes1_2, 
  [0, 1, 2, 3, 5, 5, 6, 6, 7, 7, 8, 8],
  [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
);


const Drum_St2 = new Stave(Drum_St1.width + Drum_St1.x, Drum_St1.y, nStaveWidth).setContext(ctx);
Drum_St2.draw();


const Drum_St3 = new Stave(Drum_St2.width + Drum_St2.x, Drum_St1.y, nStaveWidth).setContext(ctx);
Drum_St3.draw();


const Drum_St4 = new Stave(Drum_St3.width + Drum_St3.x, Drum_St1.y, nStaveWidth).setContext(ctx);
Drum_St4.draw();


const Perc_St1 = new Stave(Drum_St1.x, Drum_St1.y + 100, nHeadMargin + nStaveWidth).setContext(ctx);
Perc_St1.addTimeSignature('4/4').setContext(ctx);

const Perc_St1_1 = new Stave(nHeadMargin + Drum_St1.x, Drum_St1.y + 100, 0).setContext(ctx);
Perc_St1_1.setBegBarType(VF.Barline.type.NONE);
Perc_St1_1.setEndBarType(VF.Barline.type.NONE);
Perc_St1_1.draw();

for (var i = 0; i < 5; i++) {
  if (i == 2) continue;
  Perc_St1.setConfigForLine(i, {visible: false} );
}

Perc_St1.draw();

PercInst.x = Perc_St1.x - 30;
PercInst.y = Perc_St1.y + 90; 

var AllConnector = new VF.StaveConnector(VocalSt1, Perc_St1);
AllConnector.setType(VF.StaveConnector.type.SINGLE);
AllConnector.setContext(ctx);
AllConnector.draw();

const Perc_notes1_1 = [
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),

  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),

  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),

  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 }),
  new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 })
];
UniqueIds = getUniqueNoteheadIds(Perc_notes1_1, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
allUniqueIds = updateAllUniqueIds(UniqueIds);

const Perc_beam1_1_1 = new VF.Beam([Perc_notes1_1[0], Perc_notes1_1[1], Perc_notes1_1[2], Perc_notes1_1[3]]);
const Perc_beam1_1_2 = new VF.Beam([Perc_notes1_1[4], Perc_notes1_1[5], Perc_notes1_1[6], Perc_notes1_1[7]]);
const Perc_beam1_1_3 = new VF.Beam([Perc_notes1_1[8], Perc_notes1_1[9], Perc_notes1_1[10], Perc_notes1_1[11]]);
const Perc_beam1_1_4 = new VF.Beam([Perc_notes1_1[12], Perc_notes1_1[13], Perc_notes1_1[14], Perc_notes1_1[15]]);

var Perc_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
Perc_St1_1Voice.setStrict(true);
Perc_St1_1Voice.addTickables(Perc_notes1_1);

var formatterPerc_St1_1 = new Vex.Flow.Formatter().joinVoices([Perc_St1_1Voice]);
//formatterPerc_St1_1.formatToStave([stave17_1Voice], Perc_St1_1);
formatterPerc_St1_1.format([Perc_St1_1Voice], nStaveWidth - 30);
Perc_St1_1Voice.draw(ctx, Perc_St1_1);

Perc_beam1_1_1.setContext(ctx).draw();
Perc_beam1_1_2.setContext(ctx).draw();
Perc_beam1_1_3.setContext(ctx).draw();
Perc_beam1_1_4.setContext(ctx).draw();

Perc_note1_1_0.x = Perc_notes1_1[0].getAbsoluteX();
Perc_note1_1_0.y = Perc_notes1_1[0].getStave().getYForLine(1);

shiftPerc1 = addShift(
  Perc_notes1_1, 
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
  [4, 4, 4, 4, 4, 4, 4, 4, 4, 4,  4,  4,  4,  4,  4,  4]
);

const Perc_St2 = new Stave(Perc_St1.width + Perc_St1.x, Perc_St1.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 2) continue;
  Perc_St2.setConfigForLine(i, {visible: false} );
}
Perc_St2.draw();

const Perc_St3 = new Stave(Perc_St2.width + Perc_St2.x, Perc_St2.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 2) continue;
  Perc_St3.setConfigForLine(i, {visible: false} );
}
Perc_St3.draw();

const Perc_St4 = new Stave(Perc_St3.width + Perc_St3.x, Perc_St3.y, nStaveWidth).setContext(ctx);
for (var i = 0; i < 5; i++) {
  if (i == 2) continue;
  Perc_St4.setConfigForLine(i, {visible: false} );
}
Perc_St4.draw();

})();

const svgElement2 = document.querySelector('#yonet202403Mid_Output01 svg');
svgElement2.style.backgroundColor = '#F5F5F5';
var svgContainer = document.getElementById('yonet202403Mid_Output01');
var svgElement = svgContainer.querySelector('svg');

var VocalText_options = {
    textContent: ["Vocal"], // 必須文字列
    strID: "VocalText", // 必須
    Stave_x: Vocal.x,
    Stave_y: Vocal.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(VocalText_options);

var EGuitarText_options = {
    textContent: ["E.Guitar1"], // 必須文字列
    strID: "EGuitarText", // 必須
    Stave_x: Guitar1Inst.x,
    Stave_y: Guitar1Inst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(EGuitarText_options);

var EGuitarTab_options = {
    textContent: ["@"], // 必須文字列
    strID: "EGuitarTab", // 必須
    Stave_x: Stave9Pos.x,
    Stave_y: Stave9Pos.y,
    Stave_x_Offset: 10,
    Stave_y_Offset: 80,
    fontFamily: "YonetMuFL, Arial",
};
insertTextToSVG(EGuitarTab_options);

insertTrilPathToSVG(shiftGuitar1_1);

var Guitar1_notes4_tr_option = {
    textContent: ["tr."], // 必須文字列
    strID: "Guitar1_notes4_tr", // 必須
    Stave_x: shiftGuitar1_1[0].x,
    Stave_y: shiftGuitar1_1[0].y,
    Stave_x_Offset: 25,
    Stave_y_Offset: -50,
    fontSize: 40,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: [0] // xのオフセット値配列
};
insertTextToSVG(Guitar1_notes4_tr_option);

var Guitar1_notes1_option = {
    textContent: ["0", "2", "2", "2", "9", "9"], // 必須文字列
    strID: "Guitar1_notes1", // 必須
    Stave_x_Offset: [10, 0, 10, 0, 0, 0],
    Stave_y_Offset: 0,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    fontSize: 50,
    shift_x: shiftGuitar1_tab1, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Guitar1_notes1_option);

var Guitar1_notes1_0_option = {
    textContent: ["\uFF7C"], // 必須文字列
    strID: "Guitar1_notes1_ele0", // 必須
    Stave_x: shiftGuitar1_tab1[0].x,
    Stave_y: shiftGuitar1_tab1[0].y,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
};
insertTextToSVG(Guitar1_notes1_0_option);

var Guitar1_notes2_option = {
    textContent: ["9", "9", "9", "9", "9", "9", "7", "9", "7", "7", "5", "4", "7"], // 必須文字列
    strID: "Guitar1_notes1", // 必須
    Stave_x_Offset: [-30, -40, 0, -10, 0, -10, 0, 0, 10, 0, 0, 0, 0],
    Stave_y_Offset: 0,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    fontSize: 50,
    shift_x: shiftGuitar1_tab2, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Guitar1_notes2_option);

var Guitar1_notes2_a_option = {
    textContent: [".", ".", ".", ".", ".", ".", ".", "."], // 必須文字列
    strID: "Guitar1_notes2", // 必須
    Stave_x_Offset: [0, 0, 0, 0, 0, 0, 0, 0],
    Stave_y_Offset: [-15, -15, -15, -15, 15, 15, 15, 15],
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    fontSize: 50,
    shift_x: [{x:shiftGuitar1_tab2[3].x, y:shiftGuitar1_tab2[3].y},
              {x:shiftGuitar1_tab2[5].x, y:shiftGuitar1_tab2[5].y}, 
              {x:shiftGuitar1_tab2[6].x, y:shiftGuitar1_tab2[6].y}, 
              {x:shiftGuitar1_tab2[7].x, y:shiftGuitar1_tab2[7].y}, 
              {x:shiftGuitar1_tab2[8].x, y:shiftGuitar1_tab2[8].y}, 
              {x:shiftGuitar1_tab2[10].x, y:shiftGuitar1_tab2[10].y}, 
              {x:shiftGuitar1_tab2[11].x, y:shiftGuitar1_tab2[11].y}, 
              {x:shiftGuitar1_tab2[12].x, y:shiftGuitar1_tab2[12].y}], // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Guitar1_notes2_a_option);

insertTiePathToSVG({x:shiftGuitar1_tab2[0].x - 20 - 10, y:shiftGuitar1_tab2[0].y + 10}, {x:shiftGuitar1_tab2[0].x, y:shiftGuitar1_tab2[0].y + 10});

insertTiePathToSVG({x:shiftGuitar1_tab2[0].x - 20 - 10, y:shiftGuitar1_tab2[0].y - 40}, {x:shiftGuitar1_tab2[0].x, y:shiftGuitar1_tab2[0].y - 40}, -1);

var Guitar1_notes3_option = {
    textContent: ["5", "7", "5", "7", "5", "7", "7", "7"], // 必須文字列
    strID: "Guitar1_notes3", // 必須
    Stave_x_Offset: [0, 0, 0, 0, 0, 0, 0, 5],
    Stave_y_Offset: 0,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    fontSize: 50,
    shift_x: shiftGuitar1_tab3, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Guitar1_notes3_option);

insertTiePathToSVG({x:shiftGuitar1_tab3[0].x , y:shiftGuitar1_tab3[0].y + 10}, {x:shiftGuitar1_tab3[1].x + 5, y:shiftGuitar1_tab3[0].y + 10});

insertTiePathToSVG({x:shiftGuitar1_tab3[1].x , y:shiftGuitar1_tab3[1].y + 10}, {x:shiftGuitar1_tab3[2].x + 5, y:shiftGuitar1_tab3[1].y + 10});

insertTiePathToSVG({x:shiftGuitar1_tab3[2].x , y:shiftGuitar1_tab3[2].y + 10}, {x:shiftGuitar1_tab3[3].x + 5, y:shiftGuitar1_tab3[2].y + 10});

insertTiePathToSVG({x:shiftGuitar1_tab3[3].x , y:shiftGuitar1_tab3[3].y + 10}, {x:shiftGuitar1_tab3[4].x + 5, y:shiftGuitar1_tab3[3].y + 10});

insertTiePathToSVG({x:shiftGuitar1_tab3[6].x , y:shiftGuitar1_tab3[6].y + 15}, {x:shiftGuitar1_tab3[6].x + 35, y:shiftGuitar1_tab3[6].y + 15});


var Guitar1_notes3_7_option = {
    textContent: ["\uFF7A"], // 必須文字列
    strID: "Guitar1_notes3_ele7", // 必須
    Stave_x: shiftGuitar1_tab3[7].x,
    Stave_y: shiftGuitar1_tab3[7].y + 5,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
};
insertTextToSVG(Guitar1_notes3_7_option);

var Guitar1_notes4_option = {
    textContent: ["5", "7", "5", "7", "7", "7", "4", "6", "4", "."], // 必須文字列
    strID: "Guitar1_notes3", // 必須
    Stave_x_Offset: [0, 0, 0, -20, 0, 0, 0, 0, 0,   0],
    Stave_y_Offset: [0, 0, 0,   0, 0, 0, 0, 0, 0, -15],
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    fontSize: 50,
    shift_x: shiftGuitar1_tab4, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Guitar1_notes4_option);

insertTiePathToSVG({x:shiftGuitar1_tab4[0].x, y:shiftGuitar1_tab4[0].y + 10}, {x:shiftGuitar1_tab4[1].x + 2, y:shiftGuitar1_tab4[0].y + 10});

insertTiePathToSVG({x:shiftGuitar1_tab4[1].x, y:shiftGuitar1_tab4[1].y + 10}, {x:shiftGuitar1_tab4[2].x + 2, y:shiftGuitar1_tab4[1].y + 10});

insertTiePathToSVG({x:shiftGuitar1_tab4[4].x - 15, y:shiftGuitar1_tab4[4].y + 10}, {x:shiftGuitar1_tab4[4].x + 2, y:shiftGuitar1_tab4[4].y + 10});

insertTiePathToSVG({x:shiftGuitar1_tab4[4].x, y:shiftGuitar1_tab4[4].y + 10}, {x:shiftGuitar1_tab4[5].x + 2, y:shiftGuitar1_tab4[4].y + 10});

insertTiePathToSVG({x:shiftGuitar1_tab4[6].x, y:shiftGuitar1_tab4[6].y - 10}, {x:shiftGuitar1_tab4[7].x + 2, y:shiftGuitar1_tab4[6].y - 10}, -1);


insertTrilPathToSVG(shiftGuitar1_tab4_tr);

var Guitar1_tab_notes4_tr_option = {
    textContent: ["tr."], // 必須文字列
    strID: "Guitar1_tab_notes4_tr", // 必須
    Stave_x: shiftGuitar1_tab4_tr[0].x,
    Stave_y: shiftGuitar1_tab4_tr[0].y,
    Stave_x_Offset: 25,
    Stave_y_Offset: -50,
    fontSize: 40,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: [0] // xのオフセット値配列
};
insertTextToSVG(Guitar1_tab_notes4_tr_option);

var EGuitar2Text_options = {
    textContent: ["E.Guitar2"], // 必須文字列
    strID: "EGuitar2Text", // 必須
    Stave_x: Guitar2Inst.x,
    Stave_y: Guitar2Inst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(EGuitar2Text_options);

var EGuitar2Tab_options = {
    textContent: ["@"], // 必須文字列
    strID: "EGuitar2Tab", // 必須
    Stave_x: Guitar2Tab1.x,
    Stave_y: Guitar2Tab1.y,
    Stave_x_Offset: 10,
    Stave_y_Offset: 80,
    fontFamily: "YonetMuFL, Arial",
};
insertTextToSVG(EGuitar2Tab_options);

var BaseText_options = {
    textContent: ["Base"], // 必須文字列
    strID: "BaseText", // 必須
    Stave_x: BaseInst.x,
    Stave_y: BaseInst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(BaseText_options);

var BaseTab_options = {
    textContent: ["@"], // 必須文字列
    strID: "BaseTab", // 必須
    Stave_x: BaseTab1.x,
    Stave_y: BaseTab1.y,
    Stave_x_Offset: 10,
    Stave_y_Offset: 90,
    fontFamily: "YonetMuFL, Arial",
};
insertTextToSVG(BaseTab_options);
insertBaseEndBarPathToSVG(StaveBase1);
insertBaseEndBarPathToSVG(StaveBase2);
insertBaseEndBarPathToSVG(StaveBase3);
insertBaseEndBarPathToSVG(StaveBase4);

var DrumText_options = {
    textContent: ["Drum"], // 必須文字列
    strID: "DrumText", // 必須
    Stave_x: DrumInst.x,
    Stave_y: DrumInst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(DrumText_options);

var PercText_options = {
    textContent: ["Perc."], // 必須文字列
    strID: "PercText", // 必須
    Stave_x: PercInst.x,
    Stave_y: PercInst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(PercText_options);

var note13_2_0_option = {
    textContent: ["\uFF65", "\uFF65", "\uFF65", "\uFF65", 
                  "\uFF65", "\uFF68", "\uFF66", "\uFF67", "\uFF65", "\uFF0B", "\uFF65", "\uFF0F"], // 必須文字列
                 //x      ,   half_o,         ,        >,         ,       + ,         ,        o
    strID: "note13_2_0", // 必須
    Stave_y_Offset: [   -5,       -5,       -5,       -5,
                        -5,      -60,       -5,      -60,       -5,      -60,       -5,      -60],
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: shiftDrum1, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(note13_2_0_option);

var Perc_notes1_1_0_Shaker_option = {
    textContent: ["< Shaker >"], // 必須文字列
    strID: "Perc_notes1_1_0_shaker", // 必須
    Stave_x: Perc_note1_1_0.x,
    Stave_y: Perc_note1_1_0.y,
    Stave_x_Offset: -20,
    Stave_y_Offset: 0,
    fontSize: 60,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: [0] // xのオフセット値配列
};
insertTextToSVG(Perc_notes1_1_0_Shaker_option);

var Perc_notes1_1_0_option = {
    textContent: ["\uFF69"], // 必須文字列
    strID: "Perc_notes1_1_0", // 必須
    Stave_y_Offset: -5,
    fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: shiftPerc1, // xのオフセット値配列
    IsOffset_x_Abs: true
};
insertTextToSVG(Perc_notes1_1_0_option);

if(allUniqueIds !== "undefined"){
// 透明にするIDの配列
// 例としてここでIDを指定
let autoUniqueIds = allUniqueIds.map(id => "vf-" + id);

// 各IDに対して処理
  autoUniqueIds.forEach(id => {
    // 該当するIDの要素を取得
    let element = svgElement.getElementById(id);
    if (element) {
      // 該当する要素があれば、描画内容を透明にする
      let paths = element.querySelectorAll("path");
      paths.forEach(path => {
          var dAttribute = path.getAttribute('d');
          // カンマで区切られた数値の数を数えます
          var numberOfValues = (dAttribute.match(/,/g) || []).length + 1; // カンマの数 + 1 = 数値の数

          if (numberOfValues === 9) {
            var firstCoord = dAttribute.split(',')[0];
            if (dAttribute.startsWith('M')) {
              var CnumberOfValues = (dAttribute.match(/C/g) || []).length; // カンマの数 + 1 = 数値の数
              var LnumberOfValues = (dAttribute.match(/L/g) || []).length; // カンマの数 + 1 = 数値の数
                // 座標の差を計算します
              if(CnumberOfValues > 0){
                var coords = dAttribute.match(/[-+]?[0-9]*\.?[0-9]+/g).map(parseFloat);
                var xdiff = coords[0] - coords[2]; // xの差を計算
                var ydiff = coords[1] - coords[3]; // yの差を計算

                // xが0でyが0より大きい場合、描画内容を透明にします
                if (xdiff <= -3.590) {
                if (xdiff >= -3.599) {
                  if(ydiff === 0){
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
                  }
                }
                }
                if (xdiff <= -2.369) {
                if (xdiff >= -2.374) {
                  if(ydiff === 0){
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
                  }
                }
                }
                if (xdiff <= 1.000) {
                if (xdiff >= -1.000) {
                  if(ydiff === 0){
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
                  }
                }
                }
                else {
                  if(ydiff === 1.123){
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
                  }
                }
              }
            }
          }
          else if (numberOfValues === 1) {
            var firstCoord = dAttribute;
            if (dAttribute.startsWith('M')) {
              var LnumberOfValues = (dAttribute.match(/L/g) || []).length; // カンマの数 + 1 = 数値の数
                // 座標の差を計算します
              if(LnumberOfValues > 0){
                var coords = dAttribute.match(/[-+]?[0-9]*\.?[0-9]+/g).map(parseFloat);
                var xdiff = coords[0] - coords[2]; // xの差を計算
                var ydiff = coords[1] - coords[3]; // yの差を計算

                // xが0でyが0より大きい場合、描画内容を透明にします
                if (xdiff < -10) {
                if (xdiff > -18) {
                  if(ydiff === 0){
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
                  }
                }
                }
              }
            }
          }//21は全音符、2分音符の符頭です。35はナチュラル、95はシャープ、41はフラット
          else if (numberOfValues === 21 || numberOfValues === 35 || numberOfValues === 95 || numberOfValues === 41) {
                    path.setAttribute("fill", "none");
                    path.setAttribute("stroke", "none");
          }
      });
    }
  });
}

if(allFlagUniqueIds !== "undefined"){
  let autoFlagUniqueIds = allFlagUniqueIds.map(id => "vf-" + id);
  autoFlagUniqueIds.forEach(id => {
    // 該当するIDの要素を取得
    let element = svgElement.getElementById(id);
    if (element) {
      // 該当する要素があれば、描画内容を透明にする
      let flagpaths = element.querySelectorAll('path');
      flagpaths.forEach(path => {
        var dAttribute = path.getAttribute('d');
        // カンマで区切られた数値の数を数えます
        var numberOfValues = (dAttribute.match(/,/g) || []).length + 1; // カンマの数 + 1 = 数値の数

        // 数値の数が23であれば、このpath要素は求めるものです
        if (numberOfValues === 23) {
          path.setAttribute("fill", "none");
          path.setAttribute("stroke", "none");
        }
      });
    }
  });
}
})();
</script>


 ものすごく長いコードになったな。1ページみっちり楽譜を描くだけでも、相当のコード量になりますね。


 812行目からタブ譜を描くための5線譜描画が始まります。Tab譜には調号や拍子に関する記号が記載されないので、左側の余白が大きくなりますので、仮想的な透明の小節を作って、そこを起点に符棒と符旗や連桁を描画します。あとで、符頭を消す関数を作ってあるので、普通に描画してから消すという方式です。UniqueIds = getUniqueNoteheadIds(Guitar1_tab_notes1_1, [1, 2]);のようにするとGuitar1_tab_notes1_1というSteveNoteオブジェクトの要素1と2の符頭を消すIDをUniqueIdsに格納します。VexFlowによる描画が終わったあとでUniqueIdsを使って、符頭を消します。


 以下のように


shiftGuitar1_tab1 = addShift(
  Guitar1_tab_notes1_1, 
  [0, 0, 0, 0, 1,  2],
  [3, 2, 1, 0, 1, -1]
);


 フレット番号を記述する位置をaddShift関数でStaveNoteオブジェクトを基準に取得します。1拍目からの2分音符のx方向の値を4要素分取得する必要がありますので、要素の0を4回取得するように[0, 0, 0, 0, …]として同じ要素を繰り返し指定しています。y方向には5弦、4弦、3弦、2弦の位置を取得するべく、[3, 2, 1, 0, …]のように指定います。1弦は-1、6弦は4が対応しています。したがって


位置番号
第1弦 -1
第2弦 0
第3弦 1
第4弦 2
第5弦 3
第6弦 4


 1101行目までが、同じように2小節目から4小節目にもタブ譜内に符棒や符旗や連桁の記号をしるすための指示がつづきます。


 1502行目からはVexFlowで描画できない記号をペタペタ表示していく関数になっています。全角の数字はタブ譜に表示するフレット番号の文字を表すコードポイントになっていて、全角の数字と1桁のフレット番号が対になっています。"0", "2", "2", "2", "9", "9"のようにポジションを記録しているshiftなんちゃらとした名前のオブジェクトに格納されている座標の順番どおりにコードポイントを示しています。10より大きい値のフレット番号は別のコードポイントに格納されていて、\uXXXXのような形式でXXXXに16進数を指定して、表示させます。Stave_x_Offsetキーの値も[10, 0, 10, 0, 0, 0],のように配列要素ごとに個別の値を指定できます。配列ではない数値を付与すると、その数値が全てに適用されますし、配列要素値が足りない場合は最後に指定した要素の値が使いまわされます。Stave_y_Offsetも同じ仕組みです。


 \uFF7Cは上向きの2分音符の4フレット幅のタブ譜向け記号です。"."全角のドットは付点やアクセントに使えるドットになっています。\uFF7Aは1フレット幅の2分音符です。ちょっと大きすぎるっすね。次の記事ではちょうどいい感じの2分音符も表示しています。


 あとはTr.のような文字を表示したい場合は全角で"Tr."のように指定するとちょうどいい感じの大きさ手書き英文字が描けるようになっています。コードポイントごとの文字の解説は別の記事で詳しく解説するようにするつもりです。


 

VexFlow 使い方に戻る。