Skip to content

Commit 8ec544e

Browse files
authored
Merge pull request #275 from cuthbertLab/tempo_notes
add info about tempo
2 parents 8e5c400 + b7e4b13 commit 8ec544e

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/stream.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ interface MakeAccidentalsParams {
109109
* to just get the parts (NON-recursive)
110110
* @property {StreamIterator} measures - (readonly) a filter on the
111111
* Stream to just get the measures (NON-recursive)
112-
* @property {number} tempo - tempo in beats per minute (will become more
113-
* sophisticated later, but for now the whole stream has one tempo
112+
* @property {number} tempo - tempo in QuarterLengths per minute -- this is a legacy behavior
113+
* and eventually only MetronomeMarks measured in Beats per minute should be used.
114+
* This property will always remain in QL per minute for backwards compatibility.
114115
* @property {boolean} autoBeam - whether the notes should be beamed automatically
115116
* or not (will be moved to `renderOptions` soon)
116117
* @property {int} [staffLines=5] - number of staff lines
@@ -2377,7 +2378,7 @@ export class Stream<ElementType extends base.Music21Object = base.Music21Object>
23772378
*
23782379
* `options` can be an object containing:
23792380
* - instrument: {@link `music`21.instrument.Instrument} object (default, `this.instrument`)
2380-
* - tempo: number (default, `this.tempo`)
2381+
* - tempo: number (default, `this.tempo`) -- should be in BPM but apparently in QL per minute!
23812382
*/
23822383
playStream(options: PlayStreamParams = {}): this {
23832384
const params: PlayStreamParams = {
@@ -2404,7 +2405,7 @@ export class Stream<ElementType extends base.Music21Object = base.Music21Object>
24042405
if (currentNoteIndex <= lastNoteIndex && !this._stopPlaying) {
24052406
const el = elements[currentNoteIndex];
24062407
let nextNote: ElementType;
2407-
let playDuration: number;
2408+
let playDuration: number; // this is in QLs not BPM
24082409
if (currentNoteIndex < lastNoteIndex) {
24092410
nextNote = elements[currentNoteIndex + 1];
24102411
playDuration = thisFlat.elementOffset(nextNote) - thisFlat.elementOffset(el);
@@ -2784,10 +2785,15 @@ export class Stream<ElementType extends base.Music21Object = base.Music21Object>
27842785
// TODO: on music21p percussion clef defines no lowest line, but does in music21j...
27852786
const lowestLine: number = (thisClef !== undefined) ? thisClef.lowestLine : 31;
27862787

2788+
// TODO: in Vexflow 5 (also fix numLines below)
2789+
// const lineSpacing: number = storedVexflowStave.options.spacingBetweenLinesPx;
2790+
// const linesAboveStaff: number = storedVexflowStave.options.spaceAboveStaffLn;
27872791
const lineSpacing: number = storedVexflowStave.options.spacing_between_lines_px;
27882792
const linesAboveStaff: number = storedVexflowStave.options.space_above_staff_ln;
2789-
2793+
27902794
const notesFromTop = yPxScaled * 2 / lineSpacing;
2795+
2796+
// TODO: in VexFlow 5...it's .options.numLines
27912797
const notesAboveLowestLine
27922798
= (storedVexflowStave.options.num_lines - 1 + linesAboveStaff) * 2
27932799
- notesFromTop;

src/tempo.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,15 @@ interface MetronomeMarkOptions {
286286
parentheses?: boolean;
287287
}
288288

289+
290+
/**
291+
* Note -- currently just the simple `Stream.tempo` is used for all playbacks
292+
* within music21. Some other systems use wrapers around it.
293+
*
294+
* @example:
295+
*
296+
* mm = new music21.tempo.MetronomeMark({text: 'Allegro', number: 132, referent: 'half'})
297+
*/
289298
export class MetronomeMark extends base.Music21Object {
290299
static get className() { return 'music21.tempo.MetronomeMark'; }
291300

0 commit comments

Comments
 (0)