「VexFlow タブ譜」の版間の差分

提供:yonewiki
編集の要約なし
 
(同じ利用者による、間の36版が非表示)
9行目: 9行目:




 ちな、2024年4月上旬、まだ書きかけの記事です。
 変数名を一旦リセットして、タブ譜スコアを描こうとしている感じの名前に変えてみました。わかりにくい感じになりましたが、Vocalの1小節目ならVocal_St1みたいな名前です。A5サイズの1ページあたりにはだいたい3小節か4小節しか配置できないので、これであとは3小節バージョンをつくったりもしないといけないかもしれませんし、今回はGutar1とGuitar2というGuitarを重ねどりするようなタイプの4ピースバンド向けの構成を作りました。KeyboardやPianoを使うバンドもあるのでもうちょっといろんなひな形を作る必要もありそうです。A5サイズを2段組にしたA4サイズやもうちょっと小さいサイズのスコアもありますよね。手書きするのに小さいサイズのは使いにくいかもだけどね。自分で書いた楽譜を製本したい場合は、InDesignにsvgを埋め込むことも考えないとだめかもしれませんね。もし流行り始めたら、楽譜革命到来だな。自分で製本とか夢みたいだわ。まぁメンドクサくてやってらんねってなるでしょうけど、楽譜フォントを自作できる人も増えたら、個性的な楽譜本とかもつくれちゃうわけで、夢あるな。AIとかいっている時代にようやく自主出版のスコア譜とか描けるようになるっていう時代錯誤。いいね。なんでこんなに楽譜出版業界の個人製作は出遅れるんだろうな。やっぱ楽譜を描くって、まだまだ敷居が高いんだな。バンド譜作成アプリの決定版がいまだに存在しないというね。AdobeやRolandやYAMAHAや各種音楽製品の会社や出版関係の会社やソフトウェア屋さんは、はやく事業化するべきだよね。投資対回収効果があるといいんだけどクラシック用の楽譜作りで満足してる場合じゃないよね。ドレミ出版やシンコーミュージックが手の内を明かさないだろうから難しいのかな。スコアがデジタルで出回り始めたら、耳コピして自分で作ったモノなのかスコア出版社のコピーなのかとかいろいろ権利がわかりづらくなるという問題が発生しそうだし、さすがに作曲者・作詞者・オリジナル演奏者とレーベルも完璧なスコアが知らぬ間に出回ったら、困るだろうね。権利関係を解決してから出まわせってね。お金が4者5者に還元される状況でデジタルスコア時代を迎えないといけない。
 
 
 まぁいろいろ気にしてもしょうがないので、学習記事が出来上がったら、手書きで作曲する人向けの印刷して使うひな型を提供しようと思います。ひな形には方眼紙模様はいらないよね。そういえば、そういったひな形を配布してくれてる便利なサイトってあるのかな。あとで調べてみよう。


 
 


== '''タブ譜''' ==
== '''タブ譜''' ==
<div id="notation"></div>
<div id="notation"></div>
<div id="yonet202403Mid_Output01"></div>
<div id="yonet202403Mid_Output01"></div>
<yjavascript></script>
<yjavascript></script>
<script>
<script>
30行目: 31行目:
var VF = Vex.Flow;
var VF = Vex.Flow;
const Vocal = new Position();
const Vocal = new Position();
const Instrument2 = new Position();
const Guitar1Inst = new Position();
const Guitar2Inst = new Position();
const Guitar2Inst = new Position();
const Guitar2Tab1 = new Position();
const Guitar2Tab1 = new Position();
const BaseInst = new Position();
const BaseInst = new Position();
const BaseTab1 = new Position();
const BaseTab1 = new Position();
const Instrument13 = new Position();
const DrumInst = new Position();
const Instrument17 = new Position();
const PercInst = new Position();
const Stave9Pos = new Position();
const Stave9Pos = new Position();


43行目: 44行目:
var StaveBase3;
var StaveBase3;
var StaveBase4;
var StaveBase4;
//const Stave3Pos = new Position();
//const Stave6Pos = new Position();
//const Stave10Pos = new Position();
//const Stave11Pos = new Position();


const note17_1_0 = new Position();
const Perc_note1_1_0 = new Position();


var shift13;
var shiftDrum1;
var shift17;
var shiftPerc1;


function insertBaseEndBarPathToSVG(Stave) {
function insertBaseEndBarPathToSVG(Stave) {
68行目: 65行目:


function insertTextToSVG(options) {
function insertTextToSVG(options) {
     var textContent = options.textContent;
     var textContent = options.textContent;
     var strID = options.strID;
     var strID = options.strID;
98行目: 94行目:
         newText.setAttribute('font-size', fontSize);
         newText.setAttribute('font-size', fontSize);
         newText.setAttribute('fill', 'black');
         newText.setAttribute('fill', 'black');


         if(typeof textContent === "string"){
         if(typeof textContent === "string"){
348行目: 342行目:
ctx.strokeStyle = defaultStyle.strokeStyle;
ctx.strokeStyle = defaultStyle.strokeStyle;


const stave1 = new Stave(80, 30, nHeadMargin + nStaveWidth).setContext(ctx);
const VocalSt1 = new Stave(80, 30, nHeadMargin + nStaveWidth).setContext(ctx);
stave1.setClef("treble").setContext(ctx);
VocalSt1.setClef("treble").setContext(ctx);
stave1.setTimeSignature('4/4').setContext(ctx);
VocalSt1.setTimeSignature('4/4').setContext(ctx);
stave1.setMeasure(1);
VocalSt1.setMeasure(1);
stave1.draw();
VocalSt1.draw();
 
Vocal.x = stave1.x - 30;
Vocal.y = stave1.y + 90;
 
const stave2 = f.Stave({ x: stave1.width + stave1.x, y: stave1.y, width: nStaveWidth });
stave2.setMeasure(2);
stave2.setContext(ctx).draw();
 
//Stave2Pos.x = stave2.x;
//Stave2Pos.y = stave2.y;
//f.draw();


const stave3 = new Stave(stave2.width + stave2.x, stave1.y, nStaveWidth).setContext(ctx);
Vocal.x = VocalSt1.x - 30;
stave3.setMeasure(3);
Vocal.y = VocalSt1.y + 90;  
stave3.draw();


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


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


const stave5 = new Stave(stave1.x, stave1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
const VocalSt4 = new Stave(VocalSt3.width + VocalSt3.x, VocalSt1.y, nStaveWidth).setContext(ctx);
stave5.addClef("treble").setContext(ctx);
VocalSt4.setMeasure(4);
stave5.addTimeSignature('4/4').setContext(ctx);
VocalSt4.draw();
stave5.draw();


var connector = new VF.StaveConnector(stave1, stave5);
const Guitar1St1 = new Stave(VocalSt1.x, VocalSt1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
connector.setType(VF.StaveConnector.type.SINGLE);
Guitar1St1.addClef("treble").setContext(ctx);
connector.setContext(ctx);
Guitar1St1.addTimeSignature('4/4').setContext(ctx);
connector.draw();
Guitar1St1.draw();


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


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


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


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


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


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


const stave12_tab = new Stave(stave11_tab.width + stave11_tab.x, stave9_tab.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++) {
for (var i = 0; i < 5; i++) {
   if (i == 0) continue;
   if (i == 0) continue;
   stave12_tab.setConfigForLine(i, {visible: false} );
   Guitar1_tab4.setConfigForLine(i, {visible: false} );
}
}
stave12_tab.draw();
Guitar1_tab4.draw();
 
const stave9 = new Stave(stave5.x, stave5.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
stave9.draw();


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


var connector9 = new VF.StaveConnector(stave5, stave9);
Stave9Pos.x = Guitar1_Tab1.x;
connector9.setType(VF.StaveConnector.type.SINGLE);
Stave9Pos.y = Guitar1_Tab1.y;
connector9.setContext(ctx);
connector9.draw();


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


Instrument2.x = stave1.x - 30;
Guitar1Inst.x = VocalSt1.x - 30;
Instrument2.y = stave5.y + ((stave9.y - stave5.y) / 2) + 90;
Guitar1Inst.y = Guitar1St1.y + ((Guitar1_Tab1.y - Guitar1St1.y) / 2) + 90;  
 
const stave10 = new Stave(stave9.width + stave9.x, stave9.y, nStaveWidth).setContext(ctx);
stave10.draw();


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


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


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


const stave12 = new Stave(stave11.width + stave11.x, stave9.y, nStaveWidth).setContext(ctx);
const Guitar2_St1 = new Stave(Guitar1_Tab1.x, Guitar1_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
stave12.draw();
 
const Guitar2_St1 = new Stave(stave9.x, stave9.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
Guitar2_St1.addClef("treble").setContext(ctx);
Guitar2_St1.addClef("treble").setContext(ctx);
Guitar2_St1.addTimeSignature('4/4').setContext(ctx);
Guitar2_St1.addTimeSignature('4/4').setContext(ctx);
Guitar2_St1.draw();
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);
const Guitar2_Tab1 = new Stave(Guitar2_St1.x, Guitar2_St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
470行目: 447行目:
Guitar2Tab1.x = Guitar2_Tab1.x;
Guitar2Tab1.x = Guitar2_Tab1.x;
Guitar2Tab1.y = Guitar2_Tab1.y;
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);
var Guitar2_connect = new VF.StaveConnector(Guitar2_St1, Guitar2_Tab1);
482行目: 468行目:
}
}
Guitar2_Tab1_tab.draw();
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.x = Guitar2_St1.x - 30;
490行目: 497行目:
Base_St1.addTimeSignature('4/4').setContext(ctx);
Base_St1.addTimeSignature('4/4').setContext(ctx);
Base_St1.draw();
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);
const Base_Tab1 = new Stave(Base_St1.x, Base_St1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
506行目: 522行目:


StaveBase1 = Base_Tab1;
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);
var Base_connect = new VF.StaveConnector(Base_St1, Base_Tab1);
512行目: 561行目:
Base_connect.draw();
Base_connect.draw();


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


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


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


const notes13_1 = [
const Drum_notes1_1 = [
   new StaveNote({ keys: ["f/4"], duration: "4", stem_direction: -1 }),
   new StaveNote({ keys: ["f/4"], duration: "4", stem_direction: -1 }),
   new StaveNote({ keys: ["c/4"], duration: "4r" }),
   new StaveNote({ keys: ["c/4"], duration: "4r" }),
533行目: 582行目:
   new StaveNote({ keys: ["f/4"], duration: "8", stem_direction: -1 })
   new StaveNote({ keys: ["f/4"], duration: "8", stem_direction: -1 })
];
];
const beam13_1 = new VF.Beam([notes13_1[3],notes13_1[5]]);
const Drum_beam1_1 = new VF.Beam([Drum_notes1_1[3],Drum_notes1_1[5]]);
 
var stave13_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
stave13_1Voice.setStrict(true);
stave13_1Voice.addTickables(notes13_1);


//var formatter13_1 = new Vex.Flow.Formatter().joinVoices([stave13_1Voice]);
var Drum_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
//formatter13_1.formatToStave([stave13_1Voice], stave13_1);
Drum_St1_1Voice.setStrict(true);
//formatter13_1.format([stave13_1Voice], nStaveWidth - 30);
Drum_St1_1Voice.addTickables(Drum_notes1_1);
//stave13_1Voice.draw(ctx, stave13_1);


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


const notes13_2 = [
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: ["g/5"], duration: "8", stem_direction: 1 }),
   new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
561行目: 605行目:
];
];


const notes13_3 = [
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 }),
583行目: 627行目:
];
];


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


const beam13_2_1 = new VF.Beam([notes13_2[0], notes13_2[1]]);
const Drum_beam1_2_1 = new VF.Beam([Drum_notes1_2[0], Drum_notes1_2[1]]);
const beam13_2_2 = new VF.Beam([notes13_2[2], notes13_2[3], notes13_2[4]]);
const Drum_beam1_2_2 = new VF.Beam([Drum_notes1_2[2], Drum_notes1_2[3], Drum_notes1_2[4]]);
const beam13_2_3 = new VF.Beam([notes13_2[5], notes13_2[6], notes13_2[7], notes13_2[8]]);
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 stave13_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
var Drum_St1_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
stave13_2Voice.setStrict(true);
Drum_St1_2Voice.setStrict(true);
stave13_2Voice.addTickables(notes13_2);
Drum_St1_2Voice.addTickables(Drum_notes1_2);


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


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


beam13_1.setContext(ctx).draw();
Drum_beam1_1.setContext(ctx).draw();


beam13_2_1.setContext(ctx).draw();
Drum_beam1_2_1.setContext(ctx).draw();
beam13_2_2.setContext(ctx).draw();
Drum_beam1_2_2.setContext(ctx).draw();
beam13_2_3.setContext(ctx).draw();
Drum_beam1_2_3.setContext(ctx).draw();


shift13 = addShift(
shiftDrum1 = addShift(
   notes13_2,  
   Drum_notes1_2,  
   [0, 1, 2, 3, 5, 5, 6, 6, 7, 7, 8, 8],
   [0, 1, 2, 3, 5, 5, 6, 6, 7, 7, 8, 8],
   [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
   [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
617行目: 661行目:




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




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




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




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


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


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


stave17.draw();
Perc_St1.draw();


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


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


const notes17_1 = [
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 }),
673行目: 717行目:
   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 })
   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 })
];
];
UniqueIds = getUniqueNoteheadIds(notes17_1, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
UniqueIds = getUniqueNoteheadIds(Perc_notes1_1, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
allUniqueIds = updateAllUniqueIds(UniqueIds);
allUniqueIds = updateAllUniqueIds(UniqueIds);


const beam17_1_1 = new VF.Beam([notes17_1[0], notes17_1[1], notes17_1[2], notes17_1[3]]);
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 beam17_1_2 = new VF.Beam([notes17_1[4], notes17_1[5], notes17_1[6], notes17_1[7]]);
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 beam17_1_3 = new VF.Beam([notes17_1[8], notes17_1[9], notes17_1[10], notes17_1[11]]);
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 beam17_1_4 = new VF.Beam([notes17_1[12], notes17_1[13], notes17_1[14], notes17_1[15]]);
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 stave17_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
var Perc_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
stave17_1Voice.setStrict(true);
Perc_St1_1Voice.setStrict(true);
stave17_1Voice.addTickables(notes17_1);
Perc_St1_1Voice.addTickables(Perc_notes1_1);


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


beam17_1_1.setContext(ctx).draw();
Perc_beam1_1_1.setContext(ctx).draw();
beam17_1_2.setContext(ctx).draw();
Perc_beam1_1_2.setContext(ctx).draw();
beam17_1_3.setContext(ctx).draw();
Perc_beam1_1_3.setContext(ctx).draw();
beam17_1_4.setContext(ctx).draw();
Perc_beam1_1_4.setContext(ctx).draw();


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


shift17 = addShift(
shiftPerc1 = addShift(
   notes17_1,  
   Perc_notes1_1,  
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
   [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]
   [4, 4, 4, 4, 4, 4, 4, 4, 4, 4,  4,  4,  4,  4,  4,  4]
);
);


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


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


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


})();
})();
737行目: 775行目:
var svgContainer = document.getElementById('yonet202403Mid_Output01');
var svgContainer = document.getElementById('yonet202403Mid_Output01');
var svgElement = svgContainer.querySelector('svg');
var svgElement = svgContainer.querySelector('svg');
insertBaseEndBarPathToSVG(StaveBase1);


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


var EGuitarText_options = {
var EGuitarText_options = {
     textContent: ["E.Guitar1"], // 必須文字列
     textContent: ["E.Guitar1"], // 必須文字列
     strID: "EGuitarText", // 必須
     strID: "EGuitarText", // 必須
     Stave_x: Instrument2.x,
     Stave_x: Guitar1Inst.x,
     Stave_y: Instrument2.y,
     Stave_y: Guitar1Inst.y,
     fontFamily: "Arial, sans-serif",
     fontFamily: "Arial, sans-serif",
     fontSize: "20pt",
     fontSize: "20pt",
828行目: 852行目:
};
};
insertTextToSVG(BaseTab_options);
insertTextToSVG(BaseTab_options);
insertBaseEndBarPathToSVG(StaveBase1);
insertBaseEndBarPathToSVG(StaveBase2);
insertBaseEndBarPathToSVG(StaveBase3);
insertBaseEndBarPathToSVG(StaveBase4);


var DrumText_options = {
var DrumText_options = {
     textContent: ["Drum"], // 必須文字列
     textContent: ["Drum"], // 必須文字列
     strID: "DrumText", // 必須
     strID: "DrumText", // 必須
     Stave_x: Instrument13.x,
     Stave_x: DrumInst.x,
     Stave_y: Instrument13.y,
     Stave_y: DrumInst.y,
     fontFamily: "Arial, sans-serif",
     fontFamily: "Arial, sans-serif",
     fontSize: "20pt",
     fontSize: "20pt",
843行目: 872行目:
     textContent: ["Perc."], // 必須文字列
     textContent: ["Perc."], // 必須文字列
     strID: "PercText", // 必須
     strID: "PercText", // 必須
     Stave_x: Instrument17.x,
     Stave_x: PercInst.x,
     Stave_y: Instrument17.y,
     Stave_y: PercInst.y,
     fontFamily: "Arial, sans-serif",
     fontFamily: "Arial, sans-serif",
     fontSize: "20pt",
     fontSize: "20pt",
850行目: 879行目:
};
};
insertTextToSVG(PercText_options);
insertTextToSVG(PercText_options);
var rest10_options = {
    textContent: ["\uE503\uE504\uE504\uE504\uE504\uE505"], // 必須文字列
    strID: "rest10_r", // 必須
//    Stave_x: Stave10Pos.x,
//    Stave_y: Stave10Pos.y,
    Stave_x_Offset: 325, //
    Stave_y_Offset: 60 // 60
};
//insertTextToSVG(rest10_options);
var options = {
    textContent: ["\uE503", "\uE504", "\uE504", "\uE504", "\uE504", "\uE504", "\uE504", "\uE504", "\uE504", "\uE505"], // 必須文字列
    strID: "rest11", // 必須
//    Stave_x: Stave11Pos.x,
//    Stave_y: Stave11Pos.y,
    Stave_x_Offset: 305, // オプション、デフォルトは0
    Stave_y_Offset: 60, // オプション、デフォルトは0
    StaveWidth: 0, // オプション、デフォルトは0
    StaveHeight: 0, // オプション、デフォルトは0
    StaveVerticalScale: 0, // オプション、デフォルトは0
    fontSize: 40, // オプション、デフォルトは40
    fontFamily: "Bravura, Arial", // オプション、デフォルトは"Bravura, Arial"
    shift_x: [0, 0, 10, 10, 10, 10, 10, 10, 10, 15], // xのオフセット値配列
    IsOffset_x_Abs: false
};
//insertTextToSVG(options);


var note13_2_0_option = {
var note13_2_0_option = {
887行目: 888行目:
                         -5,      -60,      -5,      -60,      -5,      -60,      -5,      -60],
                         -5,      -60,      -5,      -60,      -5,      -60,      -5,      -60],
     fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
     fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
     shift_x: shift13, // xのオフセット値配列
     shift_x: shiftDrum1, // xのオフセット値配列
     IsOffset_x_Abs: true
     IsOffset_x_Abs: true
};
};
insertTextToSVG(note13_2_0_option);
insertTextToSVG(note13_2_0_option);


var note17_1_0_Shaker_option = {
var Perc_notes1_1_0_Shaker_option = {
     textContent: ["< Shaker >"], // 必須文字列
     textContent: ["< Shaker >"], // 必須文字列
     strID: "note17_1_0", // 必須
     strID: "Perc_notes1_1_0_shaker", // 必須
     Stave_x: note17_1_0.x,
     Stave_x: Perc_note1_1_0.x,
     Stave_y: note17_1_0.y,
     Stave_y: Perc_note1_1_0.y,
     Stave_x_Offset: -20,
     Stave_x_Offset: -20,
     Stave_y_Offset: 0,
     Stave_y_Offset: 0,
903行目: 904行目:
     shift_x: [0] // xのオフセット値配列
     shift_x: [0] // xのオフセット値配列
};
};
insertTextToSVG(note17_1_0_Shaker_option);
insertTextToSVG(Perc_notes1_1_0_Shaker_option);


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


// 透明にするIDの配列
// 透明にするIDの配列
940行目: 941行目:




<syntaxhighlight lang="javascript" line start="1" highlight="">
<syntaxhighlight lang="javascript" line start="1" highlight="359-364, 366-371, 373-378, 380-385, 444-449, 451-456, 458-463, 465-470, 489-495, 497, 498, 503, 505-512, 514, 516-523, 525, 527-534, 536, 835-838">
<div id="yonet202403Mid_Output01"></div>
<div id="yonet202403Mid_Output01"></div>
<script>
<script>
952行目: 953行目:
}
}
var VF = Vex.Flow;
var VF = Vex.Flow;
const Instrument1 = new Position();
const Vocal = new Position();
const Instrument2 = new Position();
const Guitar1Inst = new Position();
const Instrument13 = new Position();
const Guitar2Inst = new Position();
const Instrument17 = new Position();
const Guitar2Tab1 = new Position();
const Stave2Pos = new Position();
const BaseInst = new Position();
const Stave3Pos = new Position();
const BaseTab1 = new Position();
const Stave6Pos = new Position();
const DrumInst = new Position();
const Stave10Pos = new Position();
const PercInst = new Position();
const Stave11Pos = new Position();
const Stave9Pos = new Position();


const note17_1_0 = new Position();
var StaveBase1;
var StaveBase2;
var StaveBase3;
var StaveBase4;
 
const Perc_note1_1_0 = new Position();


var shift13;
var shiftDrum1;
var shift17;
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 insertTextToSVG(options) {
function insertTextToSVG(options) {
     var textContent = options.textContent;
     var textContent = options.textContent;
     var strID = options.strID;
     var strID = options.strID;
982行目: 1,001行目:
     var fontFamily = options.fontFamily || "Bravura, Arial";
     var fontFamily = options.fontFamily || "Bravura, Arial";
     var shift_x = options.shift_x || [0];
     var shift_x = options.shift_x || [0];
    var Rotate = options.Rotate || 0;
     var offset_sum = 0;
     var offset_sum = 0;
     var Stave_x_Offset_Value = 0;
     var Stave_x_Offset_Value = 0;
997行目: 1,017行目:
         newText.setAttribute('font-size', fontSize);
         newText.setAttribute('font-size', fontSize);
         newText.setAttribute('fill', 'black');
         newText.setAttribute('fill', 'black');


         if(typeof textContent === "string"){
         if(typeof textContent === "string"){
1,037行目: 1,056行目:
           }
           }
         }
         }
         svgElement.appendChild(newText);
         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() {
         (function() {
             var textWidth = newText.getBBox().width;
             var textWidth = newText.getBBox().width;
1,068行目: 1,095行目:


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


         svgElement.appendChild(newText);
         if(Rotate != 0){
          textGroup.appendChild(newText);
          svgElement.appendChild(textGroup);
        }
        else{
          svgElement.appendChild(newText);
        }
     });
     });
}
}
1,228行目: 1,265行目:
ctx.strokeStyle = defaultStyle.strokeStyle;
ctx.strokeStyle = defaultStyle.strokeStyle;


const stave1 = new Stave(80, 150, nHeadMargin + nStaveWidth).setContext(ctx);
const VocalSt1 = new Stave(80, 30, nHeadMargin + nStaveWidth).setContext(ctx);
stave1.setClef("treble").setContext(ctx);
VocalSt1.setClef("treble").setContext(ctx);
stave1.setTimeSignature('4/4').setContext(ctx);
VocalSt1.setTimeSignature('4/4').setContext(ctx);
stave1.setMeasure(1);
VocalSt1.setMeasure(1);
stave1.draw();
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.draw();
 
const Guitar1St2 = new Stave(Guitar1St1.width + Guitar1St1.x, Guitar1St1.y, nStaveWidth).setContext(ctx);
Guitar1St2.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);
Guitar1St4.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_Tab2 = new Stave(Guitar1_Tab1.width + Guitar1_Tab1.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
Guitar1_Tab2.draw();
 
const Guitar1_Tab3 = new Stave(Guitar1_Tab2.width + Guitar1_Tab2.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
Guitar1_Tab3.draw();
 
const Guitar1_Tab4 = new Stave(Guitar1_Tab3.width + Guitar1_Tab3.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
Guitar1_Tab4.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.draw();
 
const Guitar2_St2 = new Stave(Guitar2_St1.width + Guitar2_St1.x, Guitar2_St1.y, nStaveWidth).setContext(ctx);
Guitar2_St2.draw();


Instrument1.x = stave1.x - 30;
const Guitar2_St3 = new Stave(Guitar2_St2.width + Guitar2_St2.x, Guitar2_St2.y, nStaveWidth).setContext(ctx);
Instrument1.y = stave1.y + 90;  
Guitar2_St3.draw();


const notes1 = [
const Guitar2_St4 = new Stave(Guitar2_St3.width + Guitar2_St3.x, Guitar2_St3.y, nStaveWidth).setContext(ctx);
  new StaveNote({ keys: ["c/4"], duration: "4" }),
Guitar2_St4.draw();
  new StaveNote({ keys: ["d/4"], duration: "4" }),
  new StaveNote({ keys: ["e/4"], duration: "4" }),
  new StaveNote({ keys: ["f/4"], duration: "4" })
];


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


var formatter1 = new Vex.Flow.Formatter().joinVoices([stave1Voice]);
Guitar2Tab1.x = Guitar2_Tab1.x;
formatter1.formatToStave([stave1Voice], stave1);
Guitar2Tab1.y = Guitar2_Tab1.y;
stave1Voice.draw(ctx, stave1);


const stave2 = f.Stave({ x: stave1.width + stave1.x, y: stave1.y, width: nStaveWidth });
const Guitar2_Tab2 = new Stave(Guitar2_Tab1.width + Guitar2_Tab1.x, Guitar2_Tab1.y, nStaveWidth).setContext(ctx);
stave2.setMeasure(2);
Guitar2_Tab2.draw();
stave2.setContext(ctx).draw();


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


const stave3 = new Stave(stave2.width + stave2.x, stave1.y, nStaveWidth).setContext(ctx);
const Guitar2_Tab4 = new Stave(Guitar2_Tab3.width + Guitar2_Tab3.x, Guitar2_Tab3.y, nStaveWidth).setContext(ctx);
stave3.setMeasure(3);
Guitar2_Tab4.draw();
stave3.draw();


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


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


const stave5 = new Stave(stave1.x, stave1.y + 200, nHeadMargin + nStaveWidth).setContext(ctx);
const Guitar2_Tab2_tab = new Stave(Guitar2_Tab1_tab.width + Guitar2_Tab1_tab.x, Guitar2_Tab1_tab.y, nStaveWidth).setContext(ctx);
stave5.addClef("treble").setContext(ctx);
for (var i = 0; i < 5; i++) {
stave5.addTimeSignature('4/4').setContext(ctx);
  if (i == 0) continue;
stave5.setMeasure(5);
  Guitar2_Tab2_tab.setConfigForLine(i, {visible: false} );
stave5.draw();
}
Guitar2_Tab2_tab.draw();


var connector = new VF.StaveConnector(stave1, stave5);
const Guitar2_Tab3_tab = new Stave(Guitar2_Tab2_tab.width + Guitar2_Tab2_tab.x, Guitar2_Tab2_tab.y, nStaveWidth).setContext(ctx);
connector.setType(VF.StaveConnector.type.SINGLE);
for (var i = 0; i < 5; i++) {
connector.setContext(ctx);
  if (i == 0) continue;
connector.draw();
  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("treble").setContext(ctx);
Base_St1.addTimeSignature('4/4').setContext(ctx);
Base_St1.draw();


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


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


const stave7 = new Stave(stave6.width + stave6.x, stave5.y, nStaveWidth).setContext(ctx);
const Base_St4 = new Stave(Base_St3.width + Base_St3.x, Base_St3.y, nStaveWidth).setContext(ctx);
stave7.setMeasure(7);
Base_St4.draw();
stave7.draw();


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


const stave9 = new Stave(stave5.x, stave5.y + 200, nHeadMargin + nStaveWidth).setContext(ctx);
BaseTab1.x = Base_Tab1.x;
stave9.setMeasure(9);
BaseTab1.y = Base_Tab1.y;
stave9.draw();


var connector9 = new VF.StaveConnector(stave5, stave9);
BaseInst.x = Base_St1.x - 30;
connector9.setType(VF.StaveConnector.type.SINGLE);
BaseInst.y = Base_St1.y + ((Base_Tab1.y - Base_St1.y) / 2) + 90;  
connector9.setContext(ctx);
connector9.draw();


var connector9_2 = new VF.StaveConnector(stave5, stave9);
StaveBase1 = Base_Tab1;
connector9_2.setType(VF.StaveConnector.type.BRACKET);
connector9_2.setContext(ctx);
connector9_2.draw();


Instrument2.x = stave1.x - 30;
const Base_Tab2 = new Stave(Base_Tab1.width + Base_Tab1.x, Base_Tab1.y, nStaveWidth).setContext(ctx);
Instrument2.y = stave5.y + ((stave9.y - stave5.y) / 2) + 90;  
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();


const stave10 = new Stave(stave9.width + stave9.x, stave9.y, nStaveWidth).setContext(ctx);
StaveBase2 = Base_Tab2;
stave10.setMeasure(10);
stave10.draw();


Stave10Pos.x = stave10.x;
const Base_Tab3 = new Stave(Base_Tab2.width + Base_Tab2.x, Base_Tab2.y, nStaveWidth).setContext(ctx);
Stave10Pos.y = stave10.y;
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();


const stave11 = new Stave(stave10.width + stave10.x, stave9.y, nStaveWidth).setContext(ctx);
StaveBase3 = Base_Tab3;
stave11.setMeasure(11);
stave11.draw();


Stave11Pos.x = stave11.x;
const Base_Tab4 = new Stave(Base_Tab3.width + Base_Tab3.x, Base_Tab3.y, nStaveWidth).setContext(ctx);
Stave11Pos.y = stave11.y;
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();


const stave12 = new Stave(stave11.width + stave11.x, stave9.y, nStaveWidth).setContext(ctx);
StaveBase4 = Base_Tab4;
stave12.setMeasure(12);
stave12.draw();


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 stave13 = new Stave(stave9.x, stave9.y + 200, nHeadMargin + nStaveWidth).setContext(ctx);
const Drum_St1 = new Stave(Base_Tab1.x, Base_Tab1.y + 120, nHeadMargin + nStaveWidth).setContext(ctx);
stave13.setMeasure(13);
Drum_St1.addClef("bass").setContext(ctx);
stave13.addClef("bass").setContext(ctx);
Drum_St1.addTimeSignature('4/4').setContext(ctx);
stave13.addTimeSignature('4/4').setContext(ctx);
Drum_St1.draw();
stave13.draw();


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


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


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


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


//var formatter13_1 = new Vex.Flow.Formatter().joinVoices([stave13_1Voice]);
const Drum_St1_2 = new Stave(nHeadMargin + Base_Tab1.x, Base_Tab1.y + 120, 0).setContext(ctx);
//formatter13_1.formatToStave([stave13_1Voice], stave13_1);
Drum_St1_2.setBegBarType(VF.Barline.type.NONE);
//formatter13_1.format([stave13_1Voice], nStaveWidth - 30);
Drum_St1_2.setEndBarType(VF.Barline.type.NONE);
//stave13_1Voice.draw(ctx, stave13_1);
Drum_St1_2.draw();


 
const Drum_notes1_2 = [
 
const stave13_2 = new Stave(nHeadMargin + stave9.x, stave9.y + 200, 0).setContext(ctx);
stave13_2.setBegBarType(VF.Barline.type.NONE);
stave13_2.setEndBarType(VF.Barline.type.NONE);
stave13_2.draw();
 
const notes13_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: ["g/5"], duration: "8", stem_direction: 1 }),
   new VF.StaveNote({ keys: ["g/5"], duration: "8", stem_direction: 1 }),
1,387行目: 1,528行目:
];
];


const notes13_3 = [
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 }),
1,409行目: 1,550行目:
];
];


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


const beam13_2_1 = new VF.Beam([notes13_2[0], notes13_2[1]]);
const Drum_beam1_2_1 = new VF.Beam([Drum_notes1_2[0], Drum_notes1_2[1]]);
const beam13_2_2 = new VF.Beam([notes13_2[2], notes13_2[3], notes13_2[4]]);
const Drum_beam1_2_2 = new VF.Beam([Drum_notes1_2[2], Drum_notes1_2[3], Drum_notes1_2[4]]);
const beam13_2_3 = new VF.Beam([notes13_2[5], notes13_2[6], notes13_2[7], notes13_2[8]]);
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 stave13_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
var Drum_St1_2Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
stave13_2Voice.setStrict(true);
Drum_St1_2Voice.setStrict(true);
stave13_2Voice.addTickables(notes13_2);
Drum_St1_2Voice.addTickables(Drum_notes1_2);


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


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


beam13_1.setContext(ctx).draw();
Drum_beam1_1.setContext(ctx).draw();


beam13_2_1.setContext(ctx).draw();
Drum_beam1_2_1.setContext(ctx).draw();
beam13_2_2.setContext(ctx).draw();
Drum_beam1_2_2.setContext(ctx).draw();
beam13_2_3.setContext(ctx).draw();
Drum_beam1_2_3.setContext(ctx).draw();


shift13 = addShift(
shiftDrum1 = addShift(
   notes13_2,  
   Drum_notes1_2,  
   [0, 1, 2, 3, 5, 5, 6, 6, 7, 7, 8, 8],
   [0, 1, 2, 3, 5, 5, 6, 6, 7, 7, 8, 8],
   [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
   [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
1,443行目: 1,584行目:




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




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




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




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


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


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


stave17.draw();
Perc_St1.draw();


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


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


const notes17_1 = [
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 }),
1,503行目: 1,640行目:
   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 })
   new VF.StaveNote({ keys: ["a/4"], duration: "16", stem_direction: -1 })
];
];
UniqueIds = getUniqueNoteheadIds(notes17_1, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
UniqueIds = getUniqueNoteheadIds(Perc_notes1_1, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
allUniqueIds = updateAllUniqueIds(UniqueIds);
allUniqueIds = updateAllUniqueIds(UniqueIds);


const beam17_1_1 = new VF.Beam([notes17_1[0], notes17_1[1], notes17_1[2], notes17_1[3]]);
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 beam17_1_2 = new VF.Beam([notes17_1[4], notes17_1[5], notes17_1[6], notes17_1[7]]);
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 beam17_1_3 = new VF.Beam([notes17_1[8], notes17_1[9], notes17_1[10], notes17_1[11]]);
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 beam17_1_4 = new VF.Beam([notes17_1[12], notes17_1[13], notes17_1[14], notes17_1[15]]);
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 stave17_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
var Perc_St1_1Voice = new Vex.Flow.Voice({ num_beats: 4, beat_value: 4 });
stave17_1Voice.setStrict(true);
Perc_St1_1Voice.setStrict(true);
stave17_1Voice.addTickables(notes17_1);
Perc_St1_1Voice.addTickables(Perc_notes1_1);


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


beam17_1_1.setContext(ctx).draw();
Perc_beam1_1_1.setContext(ctx).draw();
beam17_1_2.setContext(ctx).draw();
Perc_beam1_1_2.setContext(ctx).draw();
beam17_1_3.setContext(ctx).draw();
Perc_beam1_1_3.setContext(ctx).draw();
beam17_1_4.setContext(ctx).draw();
Perc_beam1_1_4.setContext(ctx).draw();


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


shift17 = addShift(
shiftPerc1 = addShift(
   notes17_1,  
   Perc_notes1_1,  
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
   [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]
   [4, 4, 4, 4, 4, 4, 4, 4, 4, 4,  4,  4,  4,  4,  4,  4]
);
);


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


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


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


})();
})();
1,571行目: 1,699行目:
var svgElement = svgContainer.querySelector('svg');
var svgElement = svgContainer.querySelector('svg');


var newText = document.createElementNS('http://www.w3.org/2000/svg', 'text');
var VocalText_options = {
newText.setAttribute('x', '100');
    textContent: ["Vocal"], // 必須文字列
newText.setAttribute('y', '100');
    strID: "VocalText", // 必須
newText.setAttribute('font-family', 'Hiragino Kaku Gothic Pro, メイリオ, MS Gothic, sans-serif');
    Stave_x: Vocal.x,
newText.setAttribute('font-size', '50');
    Stave_y: Vocal.y,
newText.setAttribute('fill', 'black');
    fontFamily: "Arial, sans-serif",
newText.textContent = 'TestTitle - subTitle - lyrics: yo-net, music: yo-net';
    fontSize: "20pt",
svgElement.appendChild(newText);
    Rotate: -90
};
insertTextToSVG(VocalText_options);


var newText2 = document.createElementNS('http://www.w3.org/2000/svg', 'text');
var EGuitarText_options = {
newText2.setAttribute('x', Instrument1.x);
    textContent: ["E.Guitar1"], // 必須文字列
newText2.setAttribute('y', Instrument1.y);
    strID: "EGuitarText", // 必須
newText2.setAttribute('font-family', 'Bravura, VexFlow, Arial, sans-serif');
    Stave_x: Guitar1Inst.x,
newText2.setAttribute('font-size', '20pt');
    Stave_y: Guitar1Inst.y,
newText2.setAttribute('fill', 'black');
    fontFamily: "Arial, sans-serif",
newText2.textContent = 'Vocal';
    fontSize: "20pt",
var textGroup2 = document.createElementNS('http://www.w3.org/2000/svg', 'g');
    Rotate: -90
textGroup2.setAttribute('transform', 'rotate(-90 ' + Instrument1.x + ' ' + Instrument1.y + ')');
};
textGroup2.appendChild(newText2);
insertTextToSVG(EGuitarText_options);
svgElement.appendChild(textGroup2);


var newText3 = document.createElementNS('http://www.w3.org/2000/svg', 'text');
var EGuitarTab_options = {
newText3.setAttribute('x', Instrument2.x);
    textContent: ["@"], // 必須文字列
newText3.setAttribute('y', Instrument2.y);
    strID: "EGuitarTab", // 必須
newText3.setAttribute('font-family', 'Bravura, VexFlow, Arial, sans-serif');
    Stave_x: Stave9Pos.x,
newText3.setAttribute('font-size', '20pt');
    Stave_y: Stave9Pos.y,
newText3.setAttribute('fill', 'black');
    Stave_x_Offset: 10,
newText3.textContent = 'E.Guitar';
    Stave_y_Offset: 80,
var textGroup3 = document.createElementNS('http://www.w3.org/2000/svg', 'g');
    fontFamily: "YonetMuFL, Arial",
textGroup3.setAttribute('transform', 'rotate(-90 ' + Instrument2.x + ' ' + Instrument2.y + ')');
};
textGroup3.appendChild(newText3);
insertTextToSVG(EGuitarTab_options);
svgElement.appendChild(textGroup3);


var newText13 = document.createElementNS('http://www.w3.org/2000/svg', 'text');
var EGuitar2Text_options = {
newText13.setAttribute('x', Instrument13.x);
    textContent: ["E.Guitar2"], // 必須文字列
newText13.setAttribute('y', Instrument13.y);
    strID: "EGuitar2Text", // 必須
newText13.setAttribute('font-family', 'Bravura, VexFlow, Arial, sans-serif');
    Stave_x: Guitar2Inst.x,
newText13.setAttribute('font-size', '20pt');
    Stave_y: Guitar2Inst.y,
newText13.setAttribute('fill', 'black');
    fontFamily: "Arial, sans-serif",
newText13.textContent = 'Drum';
    fontSize: "20pt",
var textGroup13 = document.createElementNS('http://www.w3.org/2000/svg', 'g');
    Rotate: -90
textGroup13.setAttribute('transform', 'rotate(-90 ' + Instrument13.x + ' ' + Instrument13.y + ')');
};
textGroup13.appendChild(newText13);
insertTextToSVG(EGuitar2Text_options);
svgElement.appendChild(textGroup13);


var newText17 = document.createElementNS('http://www.w3.org/2000/svg', 'text');
var EGuitar2Tab_options = {
newText17.setAttribute('x', Instrument17.x);
    textContent: ["@"], // 必須文字列
newText17.setAttribute('y', Instrument17.y);
    strID: "EGuitar2Tab", // 必須
newText17.setAttribute('font-family', 'Bravura, VexFlow, Arial, sans-serif');
    Stave_x: Guitar2Tab1.x,
newText17.setAttribute('font-size', '20pt');
    Stave_y: Guitar2Tab1.y,
newText17.setAttribute('fill', 'black');
    Stave_x_Offset: 10,
newText17.textContent = 'Percussion';
    Stave_y_Offset: 80,
var textGroup17 = document.createElementNS('http://www.w3.org/2000/svg', 'g');
    fontFamily: "YonetMuFL, Arial",
textGroup17.setAttribute('transform', 'rotate(-90 ' + Instrument17.x + ' ' + Instrument17.y + ')');
};
textGroup17.appendChild(newText17);
insertTextToSVG(EGuitar2Tab_options);
svgElement.appendChild(textGroup17);


//設定
var BaseText_options = {
var fontSize2 = 40; // フォントサイズ
    textContent: ["Base"], // 必須文字列
var fontFamily2 = "Bravura, Arial"; //Bravuraフォントファミリー
    strID: "BaseText", // 必須
var textContent2 = "\uE500";//符頭E0A4
    Stave_x: BaseInst.x,
    Stave_y: BaseInst.y,
    fontFamily: "Arial, sans-serif",
    fontSize: "20pt",
    Rotate: -90
};
insertTextToSVG(BaseText_options);


// テキスト要素の作成
var BaseTab_options = {
var newText2 = document.createElementNS('http://www.w3.org/2000/svg', 'text');
    textContent: ["@"], // 必須文字列
newText2.setAttribute('id', 'rest2'); //テキスト要素にIDを付ける
    strID: "BaseTab", // 必須
newText2.setAttribute('x', 0);
    Stave_x: BaseTab1.x,
newText2.setAttribute('y', 0);
    Stave_y: BaseTab1.y,
newText2.setAttribute('font-family', fontFamily2);
    Stave_x_Offset: 10,
newText2.setAttribute('font-size', fontSize2);
    Stave_y_Offset: 90,
newText2.setAttribute('fill', 'black');
    fontFamily: "YonetMuFL, Arial",
newText2.textContent = textContent2;
};
insertTextToSVG(BaseTab_options);


// SVG要素にテキストを追加
insertBaseEndBarPathToSVG(StaveBase1);
svgElement.appendChild(newText2);
insertBaseEndBarPathToSVG(StaveBase2);
insertBaseEndBarPathToSVG(StaveBase3);
insertBaseEndBarPathToSVG(StaveBase4);


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


    //スケーリング
var PercText_options = {
    var horizontalScale = 1;
     textContent: ["Perc."], // 必須文字列
    var verticalScale = 1;
     strID: "PercText", // 必須
 
     Stave_x: PercInst.x,
    var StavePos_x = Stave2Pos.x + 170;
     Stave_y: PercInst.y,
    var StavePos_y = Stave2Pos.y + 60;
     fontFamily: "Arial, sans-serif",
 
     fontSize: "20pt",
    newText2.setAttribute('transform', 'translate(' + StavePos_x  + ',' + StavePos_y + ') scale(' + horizontalScale + ',' + verticalScale + ')');
     Rotate: -90
 
    //SVG要素に追加する
    svgElement.appendChild(newText2);
})();
 
 
//設定
var fontSize3 = 40; // フォントサイズ
var fontFamily3 = "Bravura, Arial"; //Bravuraフォントファミリー
var textContent3 = "\uE501";//符頭E0A4
 
// テキスト要素の作成
var newText3 = document.createElementNS('http://www.w3.org/2000/svg', 'text');
newText3.setAttribute('id', 'rest3'); // テキスト要素にIDを付ける
newText3.setAttribute('x', 0);
newText3.setAttribute('y', 0);
newText3.setAttribute('font-family', fontFamily3);
newText3.setAttribute('font-size', fontSize3);
newText3.setAttribute('fill', 'black');
newText3.textContent = textContent3;
 
// SVG要素にテキストを追加
svgElement.appendChild(newText3);
 
(function(){
    var textWidth = document.getElementById('rest3').getBBox().width;
    var textHeight = document.getElementById('rest3').getBBox().height;
 
    //スケーリング
    var horizontalScale = 1;
    var verticalScale = 1;
 
    var StavePos_x = Stave3Pos.x + 335;
    var StavePos_y = Stave3Pos.y + 60;
 
    newText3.setAttribute('transform', 'translate(' + StavePos_x  + ',' + StavePos_y + ') scale(' + horizontalScale + ',' + verticalScale + ')');
 
    //SVG要素に追加する
    svgElement.appendChild(newText3);
})();
 
//設定
var fontSize6 = 40; // フォントサイズ
var fontFamily6 = "Bravura, Arial"; //Bravuraフォントファミリー
var textContent6 = "\uE502";//符頭E0A4
 
// テキスト要素の作成
var newText6 = document.createElementNS('http://www.w3.org/2000/svg', 'text');
newText6.setAttribute('id', 'rest6'); // テキスト要素にIDを付ける
newText6.setAttribute('x', 0);
newText6.setAttribute('y', 0);
newText6.setAttribute('font-family', fontFamily6);
newText6.setAttribute('font-size', fontSize6);
newText6.setAttribute('fill', 'black');
newText6.textContent = textContent6;
 
// SVG要素にテキストを追加
svgElement.appendChild(newText6);
 
(function(){
    var textWidth = document.getElementById('rest6').getBBox().width;
    var textHeight = document.getElementById('rest6').getBBox().height;
 
    //スケーリング
    var horizontalScale = 1;
    var verticalScale = 1;
 
    var StavePos_x = Stave6Pos.x + 325;
    var StavePos_y = Stave6Pos.y + 60;
 
    newText6.setAttribute('transform', 'translate(' + StavePos_x  + ',' + StavePos_y + ') scale(' + horizontalScale + ',' + verticalScale + ')');
 
    // クレシェンド記号をSVG要素に追加する
    svgElement.appendChild(newText6);
})();
 
//設定
var fontSize10 = 40; // フォントサイズ
var fontFamily10 = "Bravura, Arial"; // Bravuraフォントファミリー
var textContent10 = "\uE503\uE504\uE504\uE504\uE504\uE505";// 符頭E0A4
 
// テキスト要素の作成
var newText10 = document.createElementNS('http://www.w3.org/2000/svg', 'text');
newText10.setAttribute('id', 'rest10'); // テキスト要素にIDを付ける
newText10.setAttribute('x', 0);
newText10.setAttribute('y', 0);
newText10.setAttribute('font-family', fontFamily10);
newText10.setAttribute('font-size', fontSize10);
newText10.setAttribute('fill', 'black');
newText10.textContent = textContent10;
 
// SVG要素にテキストを追加
svgElement.appendChild(newText10);
 
(function(){
    var textWidth = document.getElementById('rest10').getBBox().width;
    var textHeight = document.getElementById('rest10').getBBox().height;
 
    //スケーリング
    var horizontalScale = 1;
    var verticalScale = 1;
 
    var StavePos_x = Stave10Pos.x + 325;
    var StavePos_y = Stave10Pos.y + 60;
 
    newText10.setAttribute('transform', 'translate(' + StavePos_x  + ',' + StavePos_y + ') scale(' + horizontalScale + ',' + verticalScale + ')');
 
    //SVG要素に追加する
    svgElement.appendChild(newText10);
})();
 
 
 
var options = {
     textContent: ["\uE503", "\uE504", "\uE504", "\uE504", "\uE504", "\uE504", "\uE504", "\uE504", "\uE504", "\uE505"], // 必須文字列
     strID: "rest11", // 必須
     Stave_x: Stave11Pos.x,
     Stave_y: Stave11Pos.y,
    Stave_x_Offset: 305, // オプション、デフォルトは0
    Stave_y_Offset: 60, // オプション、デフォルトは0
    StaveWidth: 0, // オプション、デフォルトは0
    StaveHeight: 0, // オプション、デフォルトは0
    StaveVerticalScale: 0, // オプション、デフォルトは0
    fontSize: 40, // オプション、デフォルトは40
     fontFamily: "Bravura, Arial", // オプション、デフォルトは"Bravura, Arial"
     shift_x: [0, 0, 10, 10, 10, 10, 10, 10, 10, 15], // xのオフセット値配列
     IsOffset_x_Abs: false
};
};
insertTextToSVG(options);
insertTextToSVG(PercText_options);


var note13_2_0_option = {
var note13_2_0_option = {
1,796行目: 1,811行目:
                         -5,      -60,      -5,      -60,      -5,      -60,      -5,      -60],
                         -5,      -60,      -5,      -60,      -5,      -60,      -5,      -60],
     fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
     fontFamily: "YonetMuFL, Arial", // オプション、デフォルトは"Bravura, Arial"
     shift_x: shift13, // xのオフセット値配列
     shift_x: shiftDrum1, // xのオフセット値配列
     IsOffset_x_Abs: true
     IsOffset_x_Abs: true
};
};
insertTextToSVG(note13_2_0_option);
insertTextToSVG(note13_2_0_option);


var note17_1_0_Shaker_option = {
var Perc_notes1_1_0_Shaker_option = {
     textContent: ["< Shaker >"], // 必須文字列
     textContent: ["< Shaker >"], // 必須文字列
     strID: "note17_1_0", // 必須
     strID: "Perc_notes1_1_0_shaker", // 必須
     Stave_x: note17_1_0.x,
     Stave_x: Perc_note1_1_0.x,
     Stave_y: note17_1_0.y,
     Stave_y: Perc_note1_1_0.y,
     Stave_x_Offset: -20,
     Stave_x_Offset: -20,
     Stave_y_Offset: 0,
     Stave_y_Offset: 0,
1,812行目: 1,827行目:
     shift_x: [0] // xのオフセット値配列
     shift_x: [0] // xのオフセット値配列
};
};
insertTextToSVG(note17_1_0_Shaker_option);
insertTextToSVG(Perc_notes1_1_0_Shaker_option);


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


// 透明にするIDの配列
// 透明にするIDの配列
1,843行目: 1,858行目:


})();
})();
</script>
</script>
</syntaxhighlight>
</syntaxhighlight>




 
 タブ譜を描いただけですが、ここではVexFlowのタブ譜の技術は使わず、通常の五線譜を二つ重ねているだけです。線が重なると少し汚くなるので、必要最小限になるよう。重ねる五線譜の一つは、10ピクセル上にずらした上で、一番上の線だけを描いています。小節線の長さは調節できないので、一部重なっています。これで6線50ピクセルの幅のタブ譜になります。TAB記号は自作のフォントを前の記事でもやった方法で追加しています。359~385行目でGuitar1のタブ譜の第一弦を追加するために5線譜の10ピクセル上に五線譜の一番上の線だけを描いたものを追記しています。
 
 
 440~470行目では、Guitar2でも同じことをやっています。
 
 
 489~536行目のベースのタブ譜は逆に4線譜にしないといけないので、ひとつ削っています。ただし、このままだと小節線が飛び出してしまうので、VexFlowの機能の小節線は描かないようにしました。そして、あらたに作った関数で、30ピクセルの小節線を描くようにしています。なので、この先、二重線にしたり、リピート記号を描いたりする必要が出てきたら、また関数はちょこっと変えていかないといけないのだと思います。繰り返し記号など全部の小節線の種類を網羅しないといけないですね。ベースタブ譜は公式でも対応できないので、これくらいの苦労はしかたないですね。
 
 
 小節線を描くために、準グローバル変数にベースタブ譜小節の位置を格納して記憶しています。即時実行関数が入れ子になっていて、VexFlowの描画は入れ子になっている部分で処理して、管理人が思いつきで描画している奥の手の処理は外側の即時実行関数内で動いています。この外側を準グローバル変数と呼んでいます。これはもうひとつ楽譜を同じhtml内で描くときに変数名が同じになってしまっても問題ないようにするための工夫です。この描画全体に関わる変数という意味で準グローバル変数と呼んでいます。
 
 
*insertBaseEndBarPathToSVG(Stave)
 
 
 引数のStaveオブジェクトが示す小節に対して30ピクセルの縦線をひくという関数です。
 
 
'''第一引数:'''ベース用のタブ譜向けの短い小節線をひきたい小節のオブジェクトをVexFlowの描画が終わったあとのグローバルな領域でも参照できるようにしたStave型のオブジェクトを引数に設定します。
 
 
 
 次の記事からタブ譜の中身を描くことに挑戦していかないといけないので、まだまだ創造力をはたからせないとタブ譜は完成しなさそうです。


 
 


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

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

VexFlow 使い方に戻る。

概要

 まともにVexFlowを使う気がないので、VexFlowを実直に学びたいという人向けの記事ではなくなる予定です。VexFlow応用しかやりません。覚えてもしょうがないことはやらないのがここの管理人の方針なのです。まずはタブ譜を表示するだけのことをやってみましょう。応用技をつかえば、ベースのタブ譜も描けるようになる優れた技術です。自称ですけど。


 変数名を一旦リセットして、タブ譜スコアを描こうとしている感じの名前に変えてみました。わかりにくい感じになりましたが、Vocalの1小節目ならVocal_St1みたいな名前です。A5サイズの1ページあたりにはだいたい3小節か4小節しか配置できないので、これであとは3小節バージョンをつくったりもしないといけないかもしれませんし、今回はGutar1とGuitar2というGuitarを重ねどりするようなタイプの4ピースバンド向けの構成を作りました。KeyboardやPianoを使うバンドもあるのでもうちょっといろんなひな形を作る必要もありそうです。A5サイズを2段組にしたA4サイズやもうちょっと小さいサイズのスコアもありますよね。手書きするのに小さいサイズのは使いにくいかもだけどね。自分で書いた楽譜を製本したい場合は、InDesignにsvgを埋め込むことも考えないとだめかもしれませんね。もし流行り始めたら、楽譜革命到来だな。自分で製本とか夢みたいだわ。まぁメンドクサくてやってらんねってなるでしょうけど、楽譜フォントを自作できる人も増えたら、個性的な楽譜本とかもつくれちゃうわけで、夢あるな。AIとかいっている時代にようやく自主出版のスコア譜とか描けるようになるっていう時代錯誤。いいね。なんでこんなに楽譜出版業界の個人製作は出遅れるんだろうな。やっぱ楽譜を描くって、まだまだ敷居が高いんだな。バンド譜作成アプリの決定版がいまだに存在しないというね。AdobeやRolandやYAMAHAや各種音楽製品の会社や出版関係の会社やソフトウェア屋さんは、はやく事業化するべきだよね。投資対回収効果があるといいんだけどクラシック用の楽譜作りで満足してる場合じゃないよね。ドレミ出版やシンコーミュージックが手の内を明かさないだろうから難しいのかな。スコアがデジタルで出回り始めたら、耳コピして自分で作ったモノなのかスコア出版社のコピーなのかとかいろいろ権利がわかりづらくなるという問題が発生しそうだし、さすがに作曲者・作詞者・オリジナル演奏者とレーベルも完璧なスコアが知らぬ間に出回ったら、困るだろうね。権利関係を解決してから出まわせってね。お金が4者5者に還元される状況でデジタルスコア時代を迎えないといけない。


 まぁいろいろ気にしてもしょうがないので、学習記事が出来上がったら、手書きで作曲する人向けの印刷して使うひな型を提供しようと思います。ひな形には方眼紙模様はいらないよね。そういえば、そういったひな形を配布してくれてる便利なサイトってあるのかな。あとで調べてみよう。

 

タブ譜


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


<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 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 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 = [];
(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;
}

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.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.draw();

const Guitar1St2 = new Stave(Guitar1St1.width + Guitar1St1.x, Guitar1St1.y, nStaveWidth).setContext(ctx);
Guitar1St2.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);
Guitar1St4.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_Tab2 = new Stave(Guitar1_Tab1.width + Guitar1_Tab1.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
Guitar1_Tab2.draw();

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

const Guitar1_Tab4 = new Stave(Guitar1_Tab3.width + Guitar1_Tab3.x, Guitar1_Tab1.y, nStaveWidth).setContext(ctx);
Guitar1_Tab4.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.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("treble").setContext(ctx);
Base_St1.addTimeSignature('4/4').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);

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);

// 透明にする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 => {
            path.setAttribute("fill", "none");
            path.setAttribute("stroke", "none");
        });
    }
});

})();

</script>


 タブ譜を描いただけですが、ここではVexFlowのタブ譜の技術は使わず、通常の五線譜を二つ重ねているだけです。線が重なると少し汚くなるので、必要最小限になるよう。重ねる五線譜の一つは、10ピクセル上にずらした上で、一番上の線だけを描いています。小節線の長さは調節できないので、一部重なっています。これで6線50ピクセルの幅のタブ譜になります。TAB記号は自作のフォントを前の記事でもやった方法で追加しています。359~385行目でGuitar1のタブ譜の第一弦を追加するために5線譜の10ピクセル上に五線譜の一番上の線だけを描いたものを追記しています。


 440~470行目では、Guitar2でも同じことをやっています。


 489~536行目のベースのタブ譜は逆に4線譜にしないといけないので、ひとつ削っています。ただし、このままだと小節線が飛び出してしまうので、VexFlowの機能の小節線は描かないようにしました。そして、あらたに作った関数で、30ピクセルの小節線を描くようにしています。なので、この先、二重線にしたり、リピート記号を描いたりする必要が出てきたら、また関数はちょこっと変えていかないといけないのだと思います。繰り返し記号など全部の小節線の種類を網羅しないといけないですね。ベースタブ譜は公式でも対応できないので、これくらいの苦労はしかたないですね。


 小節線を描くために、準グローバル変数にベースタブ譜小節の位置を格納して記憶しています。即時実行関数が入れ子になっていて、VexFlowの描画は入れ子になっている部分で処理して、管理人が思いつきで描画している奥の手の処理は外側の即時実行関数内で動いています。この外側を準グローバル変数と呼んでいます。これはもうひとつ楽譜を同じhtml内で描くときに変数名が同じになってしまっても問題ないようにするための工夫です。この描画全体に関わる変数という意味で準グローバル変数と呼んでいます。


  • insertBaseEndBarPathToSVG(Stave)


 引数のStaveオブジェクトが示す小節に対して30ピクセルの縦線をひくという関数です。


第一引数:ベース用のタブ譜向けの短い小節線をひきたい小節のオブジェクトをVexFlowの描画が終わったあとのグローバルな領域でも参照できるようにしたStave型のオブジェクトを引数に設定します。


 次の記事からタブ譜の中身を描くことに挑戦していかないといけないので、まだまだ創造力をはたからせないとタブ譜は完成しなさそうです。

 

VexFlow 使い方に戻る。