Class: Renderer

music21.vfShow. Renderer

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

Properties:
Name Type Description
vfRenderer Vex.Flow.Renderer

a Vex.Flow.Renderer to use
(will create if not existing)

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

Source:

Methods

<static> Renderer#addStaffConnectors(s)

If a stream has parts (NOT CHECKED HERE) create and
draw an appropriate Vex.Flow.StaveConnector

Parameters:
Name Type Description
s music21.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
stave Vex.Flow.Stave
s music21.stream.Stream <optional>
this.stream
formatter Vex.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
stack music21.vfShow.RenderStack
autoBeam Boolean <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
s music21.stream.Stream
  • usually a Measure or Voice
stave Vex.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
s music21.stream.Stream <optional>
this.stream
  • usually a Measure or Voice
stave Vex.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 m21j

Parameters:
Name Type Description
s music21.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 prepareFlat

Parameters:
Name Type Description
m music21.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
s music21.stream.Stream

a flat stream object

stack music21.vfShow.RenderStack

a RenderStack object to prepare into.

optionalStave Vex.Flow.Stave <optional>

an optional existing stave.

optional_renderOp object <optional>

render options.
Passed to music21.vfShow.Renderer#renderStave

Source:
Returns:

staff to return too
(also changes the stack parameter and runs makeAccidentals on 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 object

Parameters:
Name Type Description
m music21.stream.Measure

a measure object (w or w/o voices)

stack music21.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
p music21.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 Connectors

Parameters:
Name Type Description
s music21.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
p music21.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
each music21.base.Music21Object -- see applyFormatterInformationToNotes

You might want to remove this information; this routine does that.

Parameters:
Name Type Argument Default Description
s music21.stream.Stream

can have parts, measures, etc.

recursive boolean <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
s music21.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
m music21.stream.Stream <optional>
this.stream

a flat stream

optional_rendOp object <optional>

render options, passed
to music21.vfShow.Renderer#newStave and music21.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 rightBarline

Parameters:
Name Type Argument Default Description
s music21.stream.Stream
stave Vex.Flow.Stave
rendOp object <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
s music21.stream.Stream

stream to get the .staffLines
from s.renderOptions from -- should allow for overriding.

vexflowStave Vex.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.TextNote objects from any lyrics found in s

Parameters:
Name Type Description
s music21.stream.Stream

flat stream to search.

stave Vex.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
s music21.stream.Stream <optional>
this.stream

flat stream to find notes in

stave Vex.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
s music21.stream.Stream
Source:
Returns:
Type
Vex.Flow.Voice
Music21j, Copyright © 2013-2018 Michael Scott Cuthbert and cuthbertLab.
Documentation generated by JSDoc 3.5.5 on Wed Jul 4th 2018 using the DocStrap template.