Playback Control
Control playback, volume, speed, and metronome settings
Methods
play()
Start playback Begins playing the score from the current cursor position. If playback was previously paused, it resumes from the pause position. If stopped, it starts from the beginning or the current cursor position.
play(): Promise<void>
Returns: Promise<void>
Throws:
Error
- If no score is loaded or playback cannot start
Examples:
// Start playback
await embed.play();
See also:
pause()
Pause playback Pauses the score playback at the current position. The playback position is maintained, allowing you to resume from the same point using play()
.
pause(): Promise<void>
Returns: Promise<void>
Throws:
Error
- If no score is loaded or playback cannot be paused
Examples:
// Pause playback
await embed.pause();
See also:
stop()
Stop playback Stops the score playback and resets the playback position to the beginning of the score. Unlike pause()
, the playback position is not maintained.
stop(): Promise<void>
Returns: Promise<void>
Throws:
Error
- If no score is loaded or playback cannot be stopped
Examples:
// Stop playback
await embed.stop();
See also:
mute()
Mute playback Mutes all audio output from the score playback. The playback continues but without sound. This is equivalent to setting the master volume to 0 but preserves the previous volume setting.
mute(): Promise<void>
Returns: Promise<void>
Throws:
Error
- If muting fails
Examples:
// Mute audio
await embed.mute();
Note: There is no unmute method; use setMasterVolume to restore audio
See also:
setMasterVolume()
- Set master volume level
getMasterVolume()
Get the current master volume Retrieves the current master volume level for score playback.
getMasterVolume(): Promise<number>
Returns: Promise<number>
Throws:
Error
- If the volume cannot be retrieved
Example:
const embed = new Embed('container', config);
const masterVolume = await embed.getMasterVolume();
console.log(masterVolume);
See also:
setMasterVolume()
- Set the master volume
setMasterVolume()
Set the master volume Sets the master volume level for score playback. This affects all parts proportionally based on their individual volume settings.
setMasterVolume(parameters: { volume: number; }): Promise<void>
Parameters:
parameters.volume
-number
Returns: Promise<void>
Throws:
Error
- If the volume value is invalid or cannot be set
Examples:
// Set volume to 50%
await embed.setMasterVolume({ volume: 50 });
// Mute audio
await embed.setMasterVolume({ volume: 0 });
See also:
getMasterVolume()
- Get the current master volume
getMetronomeMode()
Get the metronome mode Retrieves the current metronome setting, which controls when the metronome clicks are played during playback.
getMetronomeMode(): Promise<MetronomeMode>
Returns: Promise<MetronomeMode>
View MetronomeMode
type definition
MetronomeMode
Possible values: 0
, 1
, 2
Throws:
Error
- If metronome mode cannot be retrieved
Example:
const embed = new Embed('container', config);
const metronomeMode = await embed.getMetronomeMode();
console.log(metronomeMode);
See also:
setMetronomeMode()
- Change metronome mode
setMetronomeMode()
Set the metronome mode Controls when metronome clicks are played during score playback.
setMetronomeMode(mode: MetronomeMode): Promise<void>
Parameters:
mode
-MetronomeMode
View MetronomeMode
type definition
MetronomeMode
Possible values: 0
, 1
, 2
Returns: Promise<void>
Throws:
Error
- If the mode value is invalid
Examples:
// Enable continuous metronome
await embed.setMetronomeMode(1);
// Use count-in only
await embed.setMetronomeMode(0);
See also:
getMetronomeMode()
- Get current mode
getPlaybackSpeed()
Get the playback speed Retrieves the current playback speed multiplier. Normal speed is 1.0.
getPlaybackSpeed(): Promise<number>
Returns: Promise<number>
Throws:
Error
- If speed cannot be retrieved
Example:
const embed = new Embed('container', config);
const playbackSpeed = await embed.getPlaybackSpeed();
console.log(playbackSpeed);
See also:
setPlaybackSpeed()
- Change playback speed
setPlaybackSpeed()
Set the playback speed Adjusts the playback speed without affecting pitch. Useful for practice at slower or faster tempos.
setPlaybackSpeed(speed: number): Promise<void>
Parameters:
speed
-number
Returns: Promise<void>
Throws:
Error
- If speed is outside valid range
Examples:
// Slow down for practice
await embed.setPlaybackSpeed(0.5);
// Return to normal speed
await embed.setPlaybackSpeed(1.0);
See also:
getPlaybackSpeed()
- Get current speed