music21j-port
Version:
A toolkit for computer-aided musicology, Javascript version
68 lines (64 loc) • 1.62 kB
JavaScript
import * as Vex from 'vexflow';
import { base } from './base.js';
/**
* Expressions module. See {@link music21.expressions}
*
* @exports music21/expressions
*/
/**
* Expressions can be note attached (`music21.note.Note.expressions[]`) or floating...
*
* @namespace music21.expressions
* @memberof music21
* @requires music21/expressions
*/
export const expressions = {};
/**
* Expressions can be note attached (`music21.note.Note.expressions[]`) or floating...
*
* @class Expression
* @memberof music21.expressions
* @extends music21.base.Music21Object
* @property {string} name
* @property {string} vexflowModifier
* @property {int} setPosition
*/
export class Expression extends base.Music21Object {
constructor() {
super();
this.name = 'expression';
this.vexflowModifier = '';
this.setPosition = undefined;
}
/**
* Renders this Expression as a Vex.Flow.Articulation
*
* (this is not right for all cases)
*
* @returns {Vex.Flow.Articulation}
*/
vexflow() {
const vfe = new Vex.Flow.Articulation(this.vexflowModifier);
if (this.setPosition) {
vfe.setPosition(this.setPosition);
}
return vfe;
}
}
expressions.Expression = Expression;
/**
* A fermata...
*
* @class Fermata
* @memberof music21.expressions
* @extends music21.expressions.Expression
*/
export class Fermata extends Expression {
constructor() {
super();
this.name = 'fermata';
this.vexflowModifier = 'a@a';
this.setPosition = 3;
}
}
expressions.Fermata = Fermata;