Lyrics
ClassRepresents the full set of Lyrics data for tracked music.
- Available on all platforms
Represents the full set of Lyrics data for tracked music. Can be accessed through LyricsTracker.fullLyrics when lyrics are available.
Index
Properties
Methods
Example
const externalMusicModule = require("LensStudio:ExternalMusicModule") as ExternalMusicModule;
@component
export class LyricsExample extends BaseScriptComponent {
// Make sure an AudioTrack asset is included in the scene. It determines the track that plays.
// If you see errors, make sure that "Bundled" is unchecked (disabled) on the AudioTrack.
@input audioAsset: AudioTrackAsset;
onAwake() {
const lyricsTracker = externalMusicModule.getLyricsTracker();
lyricsTracker.onLyricsAvailable.add(() => {
const fullLyrics = lyricsTracker.fullLyrics;
// Iterate through all lines in the lyrics data
fullLyrics.lines.forEach(line => {
// Iterate through all syncs in the line
line.syncs.forEach(sync => {
// Calculate start time for this sync
const startTime = line.offset + sync.offset;
// Calculate end time for this sync
const endTime = line.offset + sync.offsetEnd;
// Note that these times can be compared to current playback time using lyricsTracker.playbackPosition.
// Get text for this sync
// Note: For RichSync lyrics data, each sync text will be a single word or whitespace between words.
// For LineSync lyrics data, each sync will be the full line of text.
const text = sync.text;
});
});
});
}
}
Extends
Properties
clipDuration
readonlyclipDuration:number
Duration (in seconds) of the tracked music.
lines
readonlylines:LyricsLine[]
Lyrics represented as a list of LyricsLine objects in the order they appear in the tracked music.
type
readonlytype:LyricsType
Type of the lyrics data available. Describes the granularity of timing data available for the lyrics.
Methods
getTypeName()
staticgetTypeName():TypeName<Lyrics>
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<Lyrics>
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean