npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

liricle

v4.0.5

Published

javascript lyric synchronizer library

Downloads

97

Readme

Liricle

Liricle is javascript library for syncing timed lyrics or commonly called LRC file format with song.

Live Demo →

Liricle now support enhanced LRC format 🎉
thanks to @itaibh for the feature request and contributions 🤘

Installation 📦

using npm:

npm install liricle

in browser:

<script src="https://cdn.jsdelivr.net/npm/liricle"></script>

Usage 🚀

Setup

create the Liricle instance

const liricle = new Liricle();

Load lyrics

from url:

liricle.load({
    url: "your-lrc-file.lrc"
});

from text:

liricle.load({
    text: `
      [01:02.03] lyric line 1
      [04:05.06] lyric line 2
      ...
    `;
});

you can call .load() method many times if you want to update the lyrics.

Sync lyrics

liricle.sync(time, continuous);

.sync() method has 2 parameters:

  • time: current time from audio player or something else in seconds

    • required: yes

    • type: number

  • continuous: always emit sync event. by default Liricle only emit sync event if the lyric index changes

    • required: no

    • type: boolean

    • default: false

Adjust lyrics offset

to adjust lyrics offset or speed, you can set .offset property value. the value is number in milliseconds

// positive value = speed up
liricle.offset = 200;

// negative value = slow down
liricle.offset = -200;

Listen to event

on load event

liricle.on("load", (data) => {
  // ...
});

callback function will receive an object of parsed LRC file

{

  // LRC tags or metadata
  tags: {
    ar: "Liricle",
    ti: "Javascript lyric synchronizer library",
    offset: 200
  },

  // lyric lines
  lines: [
    {
      time: 39.98,
      text: "Hello world",

      // if LRC format is not enhanced
      // words value will be null.
      words: [
        {
          time: 40.10,
          text: "Hello"
        },
        ......
      ]
    },
    ......
  ],

  // indicates whether the lrc format is enhanced or not.
  enhanced: true

}

on sync event

liricle.on("sync", (line, word) => {
  // ...
});

🚧 If LRC format is not enhanced the word value will be null

callback function will receive 2 arguments which represents the current lyric.
both can be object or null if none of the lyrics match the time so always check the value.

// both line and word objects have the same properties

{
  index: 1,
  time: 39.98,
  text: "Hello world"
}

Example

for a complete example you can see here →

Contributing

want to contribute? Let's go 🚀

Licence

distributed under the MIT License. see LICENSE for more information.