-
Notifications
You must be signed in to change notification settings - Fork 666
Automatic Beaming
- Forcing Stem Directions
- Maintain Stem Directions
- Beaming Over All Rests
- Beaming Over Middle Rests
- Stemlets
- Custom Beam Groups
(In progress, unedited)
For long scores, manually creating a Beam
object for each group of notes is very cumbersome. Luckily, the Beam
module provides a static method that allow us to automatically generate beams for our notes. It's appropriately named .generateBeams()
. It has two parameters, the notes
to automatically beam and a config
object. The config
object provides many options to beam your notes in different ways, but let's start simple.
var beams = Beam.generateBeams(notes);
beams.forEach(function(beam) {
beam.setContext(context).draw();
});
Notice two things:
- Stem directions were changed
- The default beam groups are per quarter note
.generateBeams()
will calculate an appropriate stem direction for the entire beam group, even if it was set to a different position earlier. There are two alternatives for dealing with stem directions with beams.
You can force a stem direction for every note, by passing a stem_direction
property to the config
object.
var beams = Beam.generateBeams(notes, {
stem_direction: -1
});
Important: Not in master yet. Pull request pending.
By setting maintain_stem_directions
to true
, the stem directions for each note will not be altered. Take a look at the initial stem directions for the following notes:
By generating the beams using maintain_stem_directions
, the beams are further split up within the beat group where the stem direction changed.
var beams = Beam.generateBeams(notes, {
maintain_stem_directions: true
});
By default, rests break up beam groups.
By setting beam_rests
to true
, the beams will extend over rests.
var beams = Beam.generateBeams(notes, {
beam_rests: true
});
You can also set the beam_middle_only
to true
so that beams only extend across rests if they are in between notes.
var beams = Beam.generateBeams(notes, {
beam_rests: true,
beam_middle_only: true
});
Additionally, you can generate beams that draw stemlets over rests.
var beams = Vex.Flow.Beam.generateBeams(notes, {
beam_rests: true,
show_stemlets: true
});
You can pass in custom beam group sequences to the groups
property of the config
object. These beam groups are represented by an array of Vex.Flow.Fractions
, where each Fraction
represents a single beam group. The following example beams in groups of 3 8th notes.
var beams = Beam.generateBeams(notes, {
groups: [new Vex.Flow.Fraction(3, 8)]
});
The following example beams notes in sequences of 3 and then 5 8th notes
var beams = Beam.generateBeams(notes, {
groups: [
new Vex.Flow.Fraction(3, 8),
new Vex.Flow.Fraction(5, 8)
]
});
[ VexFlow.com ] [ API ] [ GitHub Repo ] [ Contributors ]