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

sox-element

v1.9.21

Published

The gtkiostream sox class as a webcompoenent

Downloads

38

Readme

<sox-audio>

Web component for loading and saving audio files of various formats in nodejs or the browser.

This element allows you to bypass the webaudioAPI which resamples the audio to the browser's chosen sample rate. This effects you if you simply want the binary audio data at the original sample rate.

This element also allows you to save raw audio data to an audio file, such as wav, mp3, aiff, etc.

If you don't want to do this in the browser, but want to do it in nodejs, you can look at the gtkiostream npm dependency test/SoxTest.js OR you can look at the same file in the original git repo .

Example instantiation of this element (from demo/index.html) :

<sox-audio></sox-audio>

Example to load the audio :

function setURL(){
  var soxAudio = document.querySelector('sox-audio');
  soxAudio.url="11.Neutral.44k.wav";
}

Example to save audio data to a memory file :

var soxAudio = this.shadowRoot.querySelector('sox-audio');
soxAudio.openWrite(sampleRate, channels, maxAbsVal, 'mp3'); // open the memory file for writing in mp3 format with a maximum possble sample magnitude of maxAbsVal
while (continue){ // this is your main audio process/write loop
  // get your audio data to write to file
  soxAudio.write(audio); // write some audio to the mp3 file
}

Event indicating that the WASM module is compiled and ready for use :

The 'sox-audio-ready' event is emitted once the WASM code is compiled and is ready for use.

<sox-audio @sox-audio-ready=${this.myFuncWhenReady}></sox-audio>

Where is the read audio data stored ?

The audio data is stored in the element's variable audio like so :

var soxAudio = document.querySelector('sox-audio');
console.log(soxAudio.audio);

How can I find the audio's sample rate ?

The sample rate of the input file can be found by querying sox :

var soxAudio = document.querySelector('sox-audio');
console.log(soxAudio.sox.getFSIn()+' Hz'); // once audio data has been loaded
console.log(soxAudio.sox.getFSOut()+' Hz'); // once the file is open with openWrite

To run the Demo

Install modules

npm i

Viewing Your Element

npm start