Skip to content

Commit

Permalink
Rename bpm to playbackBpm
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredjj3 committed Jan 15, 2025
1 parent 96e9744 commit 00aacf8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ export const CONFIG = {
help: 'INPUT_TYPE specifies the type of input to use.',
choices: ['auto', 'mouse', 'touch', 'hybrid', 'none'] as const,
}),
DEFAULT_BPM: t.number({
DEFAULT_PLAYBACK_BPM: t.number({
defaultValue: 100,
help: 'DEFAULT_BPM is the default beats per minute value. It can get overridden by metronome marks.',
help:
'DEFAULT_PLAYBACK_BPM is the default beats per minute value used for playback. ' +
'It can get overridden by metronomes specified in the original document.',
}),
SCORE_PADDING_TOP: t.number({
defaultValue: 40,
Expand Down
2 changes: 1 addition & 1 deletion src/data/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export type Metronome = {
/**
* The BPM used for playback. It should match `displayBpm` if provided.
*/
bpm: number;
playbackBpm: number;
name?: string;
parenthesis?: boolean;
duration?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/elements/fragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class Fragment {

/** Returns the bpm of the fragment. */
getBpm(): number {
return this.document.getFragment(this.fragmentRender.key).signature.metronome.bpm || 1; // disallow 0;
return this.document.getFragment(this.fragmentRender.key).signature.metronome.playbackBpm || 1; // disallow 0;
}

/** Returns the max number of parts in this score. */
Expand Down
14 changes: 10 additions & 4 deletions src/parsing/musicxml/metronome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class Metronome {
constructor(
private config: Config,
private log: Logger,
private bpm: number,
private playbackBpm: number,
private opts: {
name?: string;
parenthesis?: boolean;
Expand All @@ -21,7 +21,7 @@ export class Metronome {
) {}

static default(config: Config, log: Logger): Metronome {
return new Metronome(config, log, config.DEFAULT_BPM, {});
return new Metronome(config, log, config.DEFAULT_PLAYBACK_BPM, {});
}

static create(
Expand All @@ -37,7 +37,13 @@ export class Metronome {
case 'note':
const duration2 = conversions.fromNoteTypeToDurationType(musicXML.mark.right.unit) ?? undefined;
const dots2 = musicXML.mark.right.dotCount;
return new Metronome(config, log, config.DEFAULT_BPM, { parenthesis, duration, dots, duration2, dots2 });
return new Metronome(config, log, config.DEFAULT_PLAYBACK_BPM, {
parenthesis,
duration,
dots,
duration2,
dots2,
});
case 'bpm':
const displayBpm = musicXML.mark.right.bpm;
return new Metronome(config, log, displayBpm, { parenthesis, duration, dots, displayBpm });
Expand All @@ -47,7 +53,7 @@ export class Metronome {
parse(): data.Metronome {
return {
type: 'metronome',
bpm: this.bpm,
playbackBpm: this.playbackBpm,
...this.opts,
};
}
Expand Down

0 comments on commit 00aacf8

Please sign in to comment.