dynamic meter

master
Matt Huntington 5 years ago
parent 27d8aa6d7d
commit 5b674384d2

@ -1,5 +1,6 @@
const VF = Vex.Flow; const VF = Vex.Flow;
const numBeats = 7; const numBeats = 7;
const clave = [3,2,2];
const beatValue = 8; const beatValue = 8;
const widthPerBeat = 40; const widthPerBeat = 40;
let numBars = 0; let numBars = 0;
@ -53,30 +54,25 @@ const createBar = () => {
// Connect it to the rendering context and draw! // Connect it to the rendering context and draw!
stave.setContext(context).draw(); stave.setContext(context).draw();
const notes = [ const allNotes = [];
returnNewNote(), for(let i = 0; i < numBeats; i++){
returnNewNote(), allNotes.push(returnNewNote());
]; }
const notes2 = [ const beams = [];
returnNewNote(), let allNotesIndex = 0;
returnNewNote(), for(let i = 0; i < clave.length; i++){
]; const beat = []
const notes3 = [ for(let j = 0; j < clave[i]; j++){
returnNewNote(), beat.push(allNotes[allNotesIndex]);
returnNewNote(), allNotesIndex++;
returnNewNote(), }
]; beams.push(new VF.Beam(beat))
const allNotes = notes.concat(notes2).concat(notes3); }
console.log(beams);
const beams = [
new VF.Beam(notes),
new VF.Beam(notes2),
new VF.Beam(notes3)
]
// Create a voice in 4/4 and add the notes from above // Create a voice in 4/4 and add the notes from above
const voice = new VF.Voice({num_beats: numBeats, beatValue: 8}); const voice = new VF.Voice({num_beats: numBeats, beatValue: 8});
voice.addTickables(notes); voice.addTickables(allNotes);
// Format and justify the notes to 400 pixels. // Format and justify the notes to 400 pixels.
Vex.Flow.Formatter.FormatAndDraw(context, stave, allNotes); Vex.Flow.Formatter.FormatAndDraw(context, stave, allNotes);
@ -89,6 +85,6 @@ const createBar = () => {
} }
} }
for(let i = 0; i < 13; i++){ for(let i = 0; i < 7; i++){
createBar(); createBar();
} }

Loading…
Cancel
Save