new Renderer(s, div, where)
Renderer is a function that takes a stream, an
optional existing canvas or SVG element and a DOM
element where the canvas or SVG element should be placed
and renders the stream as Vexflow on the
canvas or svg element, placing it then in the where
DOM.
"s" can be any type of Stream.
"div" and "where" can be either a DOM
element or a jQuery object.
Parameters:
| Name | Type | Argument | Default | Description |
|---|---|---|---|---|
s |
music21.stream.Stream | main stream to render |
||
div |
div |
<optional> |
existing canvas or div-surroundingSVG element |
|
where |
DOMObject | jQueryDOMObject |
<optional> |
document.body | where to render the stream |
- Source:
Properties:
| Name | Type | Description |
|---|---|---|
vfRenderer |
Vex.Flow.Renderer | a Vex.Flow.Renderer to use |
rendererType |
string | canvas or svg |
ctx |
Vex.Flow.Context | a Vex.Flow.Context (Canvas or SVG) to use. |
div |
div | div-with-svg-or-canvas element |
$div |
jQueryDOMObject | jQuery div or canvas element |
$where |
jQueryDOMObject | jQuery element to render onto |
activeFormatter |
Vex.Flow.Formatter | formatter |
beamGroups |
Array.<Vex.Flow.Beam> | beamGroups |
vfTies |
Array.<Vex.Flow.StaveTie> | ties as instances of Vex.Flow.StaveTie |
systemBreakOffsets |
Array.<number> | where to break the systems |
vfTuplets |
Array.<Vex.Flow.Tuplet> | tuplets represented in Vexflow |
stacks |
Array.<music21.vfShow.RenderStack> | array of RenderStack objects |
Methods
-
<static> Renderer#addStaffConnectors(s)
-
If a stream has parts (NOT CHECKED HERE) create and
draw an appropriate Vex.Flow.StaveConnectorParameters:
Name Type Description smusic21.stream.Score - Source:
-
<static> Renderer#applyFormatterInformationToNotes(stave, s, formatter)
-
Adds the following pieces of information to each Note
- el.x -- x location in pixels
- el.y -- y location in pixels
- el.width - width of element in pixels.
- el.systemIndex -- which system is it on
- el.activeVexflowNote - which Vex.Flow.StaveNote is it connected with.
mad props to our friend Vladimir Viro for figuring this out! Visit http://peachnote.com/
Also sets s.storedVexflowStave to stave.
Parameters:
Name Type Argument Default Description staveVex.Flow.Stave smusic21.stream.Stream <optional>
this.stream formatterVex.Flow.Formatter - Source:
-
<static> Renderer#drawBeamGroups()
-
Draws the beam groups.
- Source:
-
<static> Renderer#drawMeasureStacks()
-
Draws the Voices (music and text) from
this.stacks- Source:
-
<static> Renderer#drawTies()
-
draws the vfTies
- Source:
-
<static> Renderer#drawTuplets()
-
draws the tuplets.
- Source:
-
<static> Renderer#formatMeasureStacks()
-
Aligns all of
this.stacks(after they've been prepared) so they align properly.- Source:
-
<static> Renderer#formatVoiceGroup(stack, autoBeam) → {Vex.Flow.Formatter}
-
Formats a single voice group from a stack.
Parameters:
Name Type Argument Default Description stackmusic21.vfShow.RenderStack autoBeamBoolean <optional>
measures[0].autoBeam - Source:
Returns:
- Type
- Vex.Flow.Formatter
-
<static> Renderer#getLyricVoice(s, stave) → {Vex.Flow.Voice}
-
Returns a Vex.Flow.Voice with the lyrics set to render in the proper place.
Parameters:
Name Type Description smusic21.stream.Stream - usually a Measure or Voice
staveVex.Flow.Stave - Source:
Returns:
- Type
- Vex.Flow.Voice
-
<static> Renderer#getVoice(s, stave) → {Vex.Flow.Voice}
-
Returns a Vex.Flow.Voice object with all the tickables (i.e., Notes, Voices, etc.)
Does not draw it...
Parameters:
Name Type Argument Default Description smusic21.stream.Stream <optional>
this.stream - usually a Measure or Voice
staveVex.Flow.Stave not optional (would never fly in Python...)
- Source:
Returns:
- Type
- Vex.Flow.Voice
-
<static> Renderer#newStave(s) → {Vex.Flow.Stave}
-
Return a new Vex.Flow.Stave object, which represents
a single MEASURE of notation in m21jParameters:
Name Type Description smusic21.stream.Stream - Source:
Returns:
- Type
- Vex.Flow.Stave
-
<static> Renderer#prepareArrivedFlat(m)
-
Prepares a score that arrived flat... sets up
stacks and vfTies after calling prepareFlatParameters:
Name Type Description mmusic21.stream.Stream a flat stream (maybe a measure or voice)
- Source:
-
<static> Renderer#prepareFlat(s, stack, optionalStave, optional_renderOp) → {Vex.Flow.Stave}
-
Main internal routine to prepare a flat stream
Parameters:
Name Type Argument Description smusic21.stream.Stream a flat stream object
stackmusic21.vfShow.RenderStack a RenderStack object to prepare into.
optionalStaveVex.Flow.Stave <optional>
an optional existing stave.
optional_renderOpobject <optional>
render options.
Passed tomusic21.vfShow.Renderer#renderStave- Source:
Returns:
staff to return too
(also changes thestackparameter and runsmakeAccidentalson s)- Type
- Vex.Flow.Stave
-
<static> Renderer#prepareMeasure(m, stack)
-
Prepares a measure (w/ or w/o voices) or generic Stream -- makes accidentals,
associates a Vex.Flow.Stave with the stream and
returns a vexflow Voice objectParameters:
Name Type Description mmusic21.stream.Measure a measure object (w or w/o voices)
stackmusic21.vfShow.RenderStack a RenderStack object to prepare into.
- Source:
-
<static> Renderer#preparePartlike(p)
-
Prepares a Partlike stream (that is one with Measures
or substreams that should be considered like Measures)
for rendering.Parameters:
Name Type Description pmusic21.stream.Part - Source:
-
<static> Renderer#prepareScorelike(s)
-
Prepares a scorelike stream (i.e., one with parts or
Streams that should be rendered vertically like parts)
for rendering and adds Staff ConnectorsParameters:
Name Type Description smusic21.stream.Score prepare a stream of parts (i.e., Score)
- Source:
-
<static> Renderer#prepareTies(p)
-
Finds all tied notes and creates the proper Vex.Flow.StaveTie objects in
this.vfTies.Parameters:
Name Type Description pmusic21.stream.Part a Part or similar object
- Source:
-
<static> Renderer#removeFormatterInformation(s, recursive)
-
The process of putting a Stream onto a div affects each of the
elements in the Stream by adding pieces of information to
eachmusic21.base.Music21Object-- seeapplyFormatterInformationToNotesYou might want to remove this information; this routine does that.
Parameters:
Name Type Argument Default Description smusic21.stream.Stream can have parts, measures, etc.
recursiveboolean <optional>
false - Source:
-
<static> Renderer#render(s)
-
main function to render a Stream.
if s is undefined, uses the stored Stream from
the constructor object.Parameters:
Name Type Argument Default Description smusic21.stream.Stream <optional>
this.stream - Source:
-
<static> Renderer#renderStave(m, optional_rendOp) → {Vex.Flow.Stave}
-
Render the Vex.Flow.Stave from a flat stream and draws it.
Just draws the stave, not the notes, etc.
Parameters:
Name Type Argument Default Description mmusic21.stream.Stream <optional>
this.stream a flat stream
optional_rendOpobject <optional>
render options, passed
tomusic21.vfShow.Renderer#newStaveandmusic21.vfShow.Renderer#setClefEtc- Source:
Returns:
stave
- Type
- Vex.Flow.Stave
-
<static> Renderer#setClefEtc(s, stave, rendOp)
-
Sets the number of stafflines, puts the clef on the Stave,
adds keySignature, timeSignature, and rightBarlineParameters:
Name Type Argument Default Description smusic21.stream.Stream staveVex.Flow.Stave rendOpobject <optional>
s.renderOptions a
music21.renderOptions.RenderOptions
object that might have{showMeasureNumber: boolean, rightBarLine: string<{'single', 'double', 'end'}>}- Source:
-
<static> Renderer#setStafflines(s, vexflowStave)
-
Sets the number of stafflines properly for the Stave object.
This method does not just set Vex.Flow.Stave#setNumLines() except
if the number of lines is 0 or >=4, because the default in VexFlow is
to show the bottom(top?), not middle, lines and that looks bad.Parameters:
Name Type Description smusic21.stream.Stream stream to get the
.staffLines
froms.renderOptionsfrom -- should allow for overriding.vexflowStaveVex.Flow.Stave stave to set the staff lines for.
- Source:
-
<static> Renderer#vexflowLyrics(s, stave) → {Array.<Vex.Flow.TextNote>}
-
Gets an Array of
Vex.Flow.TextNoteobjects from any lyrics found in sParameters:
Name Type Description smusic21.stream.Stream flat stream to search.
staveVex.Flow.Stave - Source:
Returns:
- Type
- Array.<Vex.Flow.TextNote>
-
<static> Renderer#vexflowNotes(s, stave) → {Array.<Vex.Flow.StaveNote>}
-
Gets the Vex.Flow.StaveNote objects from a Stream.
Also changes
this.vfTuplets.Parameters:
Name Type Argument Default Description smusic21.stream.Stream <optional>
this.stream flat stream to find notes in
staveVex.Flow.Stave Vex.Flow.Stave to render notes on to.
- Source:
Returns:
notes to return
- Type
- Array.<Vex.Flow.StaveNote>
-
<static> Renderer#vexflowVoice(s) → {Vex.Flow.Voice}
-
Creates a Vex.Flow.Voice of the appropriate length given a Stream.
Parameters:
Name Type Description smusic21.stream.Stream - Source:
Returns:
- Type
- Vex.Flow.Voice