Class: PixelMapper

music21.streamInteraction. PixelMapper

new PixelMapper(s)

A PixelMapper is an object that knows how to map offsets to pixels on a flat Stream.

Helper for ScrollPlayer and soon other places...

Parameters:
Name Type Description
s music21.stream.Stream

stream object

Properties:
Name Type Description
allMaps Array.<music21.streamInteraction.PixelMap>

a PixelMap object for each offset in the Stream and one additional one for the end of the Stream.

s music21.stream.Stream

stream object

notesAndRests music21.stream.Stream

this.stream.flat.notesAndRests

pixelScaling number

this.stream.renderOptions.scaleFactor.x

startX number

(readonly) starting x

maxX number

(readonly) ending x

maxSystemIndex Int

the index of the last system.

Source:

Methods

<static> PixelMapper#addNoteToMap(n) → {music21.streamInteraction.PixelMap}

Adds a music21.base.Music21Object, usually a music21.note.Note object,
to the maps for the PixelMapper if a music21.streamInteraction.PixelMap object
already exists at that location, or creates a new PixelMap if one does not exist.

Parameters:
Name Type Description
n music21.base.Music21Object

note or other object

Source:
Returns:

PixelMap added to.

Type
music21.streamInteraction.PixelMap

<static> PixelMapper#findMapForExactOffset(o) → {music21.streamInteraction.PixelMap|undefined}

Finds a PixelMap object if one matches this exact offset. Otherwise returns undefined

Parameters:
Name Type Description
o number

offset

Source:
Returns:
Type
music21.streamInteraction.PixelMap | undefined

<static> PixelMapper#getPixelMapsAroundOffset(offset) → {Array.<(music21.streamInteraction.PixelMap|undefined)>}

returns an array of two pixel maps: the previous/current one and the
next/current one (i.e., if the offset is exactly the offset of a pixel map
the prevNoteMap and nextNoteMap will be the same; similarly if the offset is
beyond the end of the score)

Parameters:
Name Type Description
offset number
Source:
Returns:

returns two PixelMaps; or either (but not both) can be undefined

Type
Array.<(music21.streamInteraction.PixelMap|undefined)>
Example
var s = new music21.tinyNotation.TinyNotation('3/4 c4 d8 e f4 g4 a4 b4');
var can = s.appendNewCanvas();
var pm = new music21.streamInteraction.PixelMapper(s);
var pmaps = pm.getPixelMapsAropundOffset(1.25);
var prev = pmaps[0];
var next = pmaps[1];
prev.offset
// 1
next.offset
// 1.5
prev.x
// 97...
next.x
// 123...

<static> PixelMapper#getSystemIndexAtOffset(offset) → {number}

Uses the stored offsetToPixelMaps to get the systemIndex active at the current time.

Parameters:
Name Type Description
offset number
Source:
Returns:

systemIndex of the offset

Type
number

<static> PixelMapper#getXAtOffset(offset, offsetToPixelMaps) → {number}

Uses the stored offsetToPixelMaps to get the pixel X for the offset.

Parameters:
Name Type Description
offset number
offsetToPixelMaps Array.<music21.streamInteraction.PixelMap>
Source:
Returns:
Type
number
Example
var s = new music21.tinyNotation.TinyNotation('3/4 c4 d8 e f4 g4 a4 b4');
var can = s.appendNewCanvas();
var pm = new music21.streamInteraction.PixelMapper(s);
pm.getXAtOffset(0.0); // exact placement of a note
// 89.94...
pm.getXAtOffset(0.5); // between two notes
// 138.63...

<static> PixelMapper#processStream() → {Array.<music21.streamInteraction.PixelMap>}

Creates PixelMap objects for every note in the stream, and an extra
one mapping the end of the final offset.

Source:
Returns:
Type
Array.<music21.streamInteraction.PixelMap>
Music21j, Copyright © 2013-2016 Michael Scott Cuthbert and cuthbertLab.
Documentation generated by JSDoc 3.4.3 on Wed Jul 26th 2017 using the DocStrap template.