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

karaoke

v0.2.1

Published

CD+G Player

Downloads

22

Readme

JavaScript CD+G Player

This is a CD Graphics (CD+G) implementation that draws to an HTML5 canvas. It's based on the Brandon Jones's fork of the player by Luke Tucker.

There are two main pieces that make this thing work:

  • CDGPlayer library that decodes CD+G files draws the instructions to an HTML5 canvas
  • Demo app that creates a CDGPlayer instance and an <audio> tag and keeps them synced

Usage as a Module

If all you wanna do is download this and see it in action, skip down to Running the Demo.

Otherwise, you're building some kind of Karaoke thing with this library. That's great!

  1. Install this module yarn add karaoke / npm install karaoke

  2. Import the library: import CDGKaraokePlayer from 'karaoke';

  3. Create an instance of the player:

    const karaoke = new CDGKaraokePlayer();
  4. Append the canvas and audio elements from the player instance:

    document.body.appendChild(karaoke.canvas);
    document.body.appendChild(karaoke.audio);
  5. Load and play your audio/CDG:

    karaoke.loadAndPlay('YOUR_AUDIO.mp3', 'YOUR_CDG.cdg');

Running the Demo

  1. Check out this repo.
  2. yarn install / npm install
  3. Add test.mp3 and test.cdg to the build folder alongside index.html
  4. Run yarn start / npm start
  5. Open http://localhost:8069/ in your browser.

Implementation Notes

  • Drawing uses requestAnimationFrame instead of a fixed timer. When syncing with the audio, it will process as many instructions as necessary based on the time since the last frame was drawn.
  • The player maintains its own Canvas and draws some imageData to it rather than using fillRect for each pixel. As it turns out, this made drawing really fast!
  • As a result of the change above, scaled display requires copying the player's canvas to another canvas. Well, maybe it's not totally required, but that's how it's working right now.

Future Improvements

  • Isomorphic rendering. There is still a teeny bit of refactoring necessary to allow CDGContext to create a non-HTMLCanvasElement canvas in a node.js environment, but it's already pretty close, I think.
  • CD+G authoring utils, like converting images to instructions, instruction timelines, etc.

Resources

License

ISC