New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

waveform-thumbnail

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

waveform-thumbnail

![Node waveform image generator](/docs/example.png)

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

Waveform

Node waveform image generator

A simple audio waveform image generator with no hard dependencies outside npm.

Just convert your audio to 32 bit little endian raw before converting. How you accomplish this depends on your platform, but here's how to do it with sox:

sox foo.mp3 --bits 32 --encoding signed-integer --endian little foo.raw remix 1,2

Currently I can't find and modules in NPM that will do this conversion for us without installing / compiling tools outside npm first. So I built this to work well in conjunction with sox, which is pretty well supported everywhere.

Basic usage

var Waveform = require('waveform');
var waveform = new Waveform( './someAudio.raw' );
waveform.renderAndSave( './prettyImage.png', function(err){
  console.log( "neato!" )
});

If you want more control, you can set color options.

//...
var waveform = new Waveform( './someAudio.raw', {
  w: 500,
  h: 100,
  backgroundColor: '#333',
  waveColor: '#fff'
});
//...

You can also define your own gradient. This is the default one:

//...
var waveform = new Waveform( './someAudio.raw', {
  w: 500,
  h: 100,
  backgroundColor: '#333',
  waveColor: [
    {stop: 0,   color: "#333"},
    {stop: 0.5, color: "#333"},
    {stop: 0.5, color: "#444"},
    {stop: 1,   color: "#eee"}
  ]
});
//...

This tool is built on top of node canvas, and that canvas object is exposed if you want to do stuff with it before saving.

//...
waveform.render( function(err, ctx){
  ctx.fillStyle = 'red';
  ctx.fillRect( 0,0,10,10 );
  // etc

  waveform.save( './myWaveformAndRedBox.png', function(err){
    console.log( "yay" );
  })
});

If you have trouble node-canvas running on OSX: [https://github.com/Automattic/node-canvas/wiki/Installation---OSX]

Pull requests and bug reports are very welcome. Thanks!

FAQs

Package last updated on 21 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts