Namespace: common

music21. common

functions that are useful everywhere...

Source:

Methods

<static> makeSVGright(tag, attrs) → {DOMObject}

Creates a DOMObject of an SVG figure using the correct document.createElementNS call.

Parameters:
Name Type Argument Default Description
tag string <optional>
'svg'

a tag, such as 'rect', 'circle', 'text', or 'svg'

attrs object <optional>

attributes to pass to the tag.

Source:
Returns:
Type
DOMObject

<static> merge(destination, source) → {object}

concept borrowed from Vex.Flow.Merge, though here the source can be undefined;
http://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically
recursive parts used in .clone()

Parameters:
Name Type Description
destination object

object to have attributes placed into

source object

object to take attributes from.

Source:
Returns:

destination

Type
object

<static> ordinalAbbreviation(value, plural) → {string}

Take a number such as 32 and return a string such as "nd"
(for "32nd") etc.

Parameters:
Name Type Argument Default Description
value Int
plural Boolean <optional>
false

make plural (note that "21st" plural is "21st")

Source:
Returns:
Type
string

<static> rationalize(ql, epsilon, maxDenominator) → {object|undefined}

Find a rational number approximation of this floating point.

Parameters:
Name Type Argument Default Description
ql number

number to rationalize

epsilon number <optional>
0.001

how close to get

maxDenominator Int <optional>
50

maximum denominator

Source:
Returns:

{'numerator: numerator, 'denominator': denominator}

Type
object | undefined

<static> setWindowVisibilityWatcher(callback)

runs a callback with either "visible" or "hidden" as the argument anytime the
window or document state changes.

Depending on the browser, may be called multiple times with the same argument
for a single event. For instance, Safari calls once on losing focus completely
but twice for a tab change.

Parameters:
Name Type Description
callback function
Source:

<static> statisticalMode(a) → {object}

Returns the statistical mode (most commonly appearing element)
in a.

In case of tie, returns the first element to reach the maximum
number of occurrences.

Parameters:
Name Type Description
a Array

an array to analyze

Source:
Returns:

element with the highest frequency in a

Type
object

<static> stripPx(str) → {Int}

Change something that could be a string or number and might
end with "px" to a number.

"400px" -> 400

Parameters:
Name Type Description
str Int | string
  • string that might have 'px' at the end or not
Source:
Returns:

a number to use

Type
Int

<static> urlParam(name) → {string}

Find name in the query string (?name=value) and return value.

Parameters:
Name Type Description
name string

url parameter to find

Source:
Returns:

may be "" if empty.

Type
string
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.