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

ccwt.js

v1.0.5

Published

Javascript port of the CCWT library

Downloads

23

Readme

ccwt.js

Javascript port of the CCWT library

This can be used to produce high frequency / time resolution spectogram such as

spectrogram

Can be used directly in the browser by including demo/dist/ccwt.js file demo/dist/FFTW.wasm file is also needed in the same directory as ccwt.js file

Features

Complex continuous wavelet transformation

  • fast Javascript port of CCWT library
  • with a gabor wavelet
  • use fftw-js library which is extended from fftw-js library which is an Emscripten FFTW port
  • parallelization ready (by splitting height into chunks then feeding workers)
  • customizable frequency bands
  • full example with linear / exponential frequency bands

This does not have the original render modes (real, imaginary, phase, equipotential and rainbow) bundled as it focus on the CCWT part (rendering is externalized and is handled on user side via a callback) but the provided example do amplitude rendering (linear or logarithmic) and it can be extended easily to the other modes

Build

npm install npm run build

The built production file is demo/dist/ccwt.js

Run the demo in default browser (which will use http-server to avoid CORS issues) :

npm run demo

Usage

Node

npm install ccwt.js --save

const CCWT = require('ccwt.js')

CCWT.then((ccwt_lib) => {
    // ccwt_lib.frequencyBand
    // ccwt_lib.fft1d
    // ccwt_lib.numericOutput
    // see demo/index.html :)
});

Browser

See demo/index.html

Documentation

Include the library file ccwt.js, the web version define a CCWT symbol globally which is a promise (which load the FFTW .wasm file) which when resolved return the CCWT library object where all functions are defined.

Then there is only 3 functions needed :

CCWT.frequencyBand which will generate the frequency map and will be used by numericOutput

CCWT.fft1d which will produce the transformed fourier signal of input data, result will be passed to numericOutput

CCWT.numericOutput which will generate each rows complex data and call the user provided row callback which will receive the row index, raw complex data and associated padding

CCWT.numericOutput accept a start_y / end_y argument so parallelization via a worker can be easily done by splitting spectogram height

The provided example demo/index.html has everything needed to generate a linear or logarithmic audio spectogram (default) in a web browser and its row callback can be used as a basis

All usable CCWT functions in src/ccwt.js are documented using JSDoc

The original tutorial can also help (note : functions name are the same but arguments orders aren't)

fftw-js

This library use a modified fftw-js library which is a Javascript port via Emscripten of the FFTW library.

The modifications include :

  • compiled with Emscripten 1.39.17 (latest right now)
  • compiled with -s ALLOW_MEMORY_GROWTH=1 to allow arbitrary files length analysis

There is also a small modification of the glue code to silence warnings related to errno.

Note : The original Makefile.emscripten of the fftw-js library had to be modified a bit to produce a correct build, here are the options used :

OPTIONS=--memory-init-file 0 \
                                 -s FILESYSTEM=0 \
                                 -s PRECISE_F32=1 \
                                 -s MODULARIZE=1 \
                                 -s WASM=1 \
                                 -s ALLOW_MEMORY_GROWTH=1 \
                                 -s EXPORT_NAME="'FFTWModule'" \
                                 -s EXPORTED_FUNCTIONS=$(EXPORTED_FUNCTIONS) \
                                 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap']"