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

@toots/shine.js

v1.0.3

Published

Shine fixed-point mp3 encoder

Downloads

124

Readme

Shine encoder library for Javascript

This package contains a build of the shine fixed-point mp3 encoder compiled for Javascript and wasm using emscripten-core/emscripten.

Install

Using npm:

npm install @toots/shine.js

Using yarn:

yarn add @toots/shine.js

Using pnpm:

pnpm install @toots/shine.js

In a HTML page:

When using webpack, the package should point to the correct libshine_browser.js file automatically.

When using directly as a script, you can load the libshine_node.js file as:

<script src="libshine_node.js"></script>

See: test/browser for an example.

How to use?

The encoding API should be quite straight forward:

import { Shine } from "@toots/shine.js";

const exec = async () => {
  await Shine.initialized;

  shine = new Shine({
    samplerate: 44100,
    bitrate: 128,
    channels: 2,
    stereoModel: Shine.stereoModel.STEREO
  });
  
  // All the magic happens here
  while (..) {
    // data here is an array of channels.
    // Channels must have the same number of samples
    // and both be either Int16Array or Float32Array.
    encoded = shine.encode(data);
    ...
  }

  // Close and get remaining data.
  flushed = shine.close();

  ...
}

exec();

How fast is it?

You can run the test suite located in test/. Encoding rate above 1X means that the browser should be suitable for real-time encoding.

Results, as of December 30, 2022:

Chrome (108.0.5359.124):

Executing encoding test
Got WAV file.
Encoding..
Done encoding.
File duration: 5.57 seconds
Encoding time: 0.08 seconds
Encoding rate: 67.96X

Executing rounds test
Encoding 50 buffers of 4096 samples
Done encoding
Total duration: 4.64
Encoding time: 0.03
Encoding rate: 160.00X

Firefox (108.0.1):

Executing encoding test
Got WAV file.
Encoding..
Done encoding.
File duration: 5.57 seconds
Encoding time: 0.06 seconds
Encoding rate: 99.52X

Executing rounds test
Encoding 50 buffers of 4096 samples
Done encoding
Total duration: 4.64
Encoding time: 0.03
Encoding rate: 178.46X

Safari (16.2):

Executing encoding test
Got WAV file.
Encoding..
Done encoding.
File duration: 5.57 seconds
Encoding time: 0.12 seconds
Encoding rate: 46.44X

Executing rounds test
Encoding 50 buffers of 4096 samples
Done encoding
Total duration: 4.64
Encoding time: 0.02
Encoding rate: 210.91X

NodeJS (v19.3.0):

Executing encoding test
Got WAV file.
Encoding..
Done encoding.
File duration: 5.57 seconds
Encoding time: 0.06 seconds
Encoding rate: 94.45X

Executing rounds test
Encoding 50 buffers of 4096 samples
Done encoding
Total duration: 4.64
Encoding time: 0.03
Encoding rate: 178.46X