Skip to main content

Lyrics

Class

Represents the full set of Lyrics data for tracked music.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Represents the full set of Lyrics data for tracked music. Can be accessed through LyricsTracker.fullLyrics when lyrics are available.

Index

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

readonly clipDuration: number

Duration (in seconds) of the tracked music.


lines

readonly lines: LyricsLine[]

Lyrics represented as a list of LyricsLine objects in the order they appear in the tracked music.


type

readonly type: LyricsType

Type of the lyrics data available. Describes the granularity of timing data available for the lyrics.

Methods

getTypeName()

static getTypeName(): 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

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


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

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame