sux

A wrapper around sox

sux

A wrapper around SoX

What is SoX?

SoX is the Swiss Army knife of sound processing programs.

And what is sux?

sux is a NodeJS wrapper around SoX with support for streams

Installation

npm i sux

Usage

 
var Sux = require('sux'),
    fs  = require('fs'),
    sux = new Sux({
        // ouput bitdepth 
        depth:16,
        // output samplerate 
        rate: 44100,
        // amount of output channels 
        channels: 2,
        // output file type 
        type:'wav',
        // output needs to be a file path or a stream 
        output:fs.createWriteStream('./out.wav'),
        // input file (a file has higher priority then a stream) 
        // input: './test.mp3', 
        // if using a input stream define here what file type is streamed in 
        input: {
            // input source, can be a file or a stream 
            source: fs.createReadStream('./in.wav'),
            // input type 
            type:'wav',
            // amount of input channels 
            channels:1,
            // sample rate 
            rate:22050
        }
    });
// starts SoX with given options 
sux.start();
 

API

path to sox. default: Windows: suxDir + '/win_libs/sox.exe' Other: 'sox'

arguments map, translates 'type' to '-t' etc.

Sux constructor

opt = {  
    `type`: file type f.x. "mp3"
    `rate`:samplerate  
    `channels`:amount of channels  
    `depth`: bitdepth  
    `int`: signedness (needs to be "signed" or "unsigned", for RAW),  
    `bitrate`: bitrate (for MP3's)  
    `output`: filename, '-' or stream
    `input`: {  
        `type`: file type f.x. "mp3"  
        `rate`:samplerate  
        `channels`:amount of channels  
        `depth`: bitdepth  
        `int`: signedness (needs to be "signed" or "unsigned", for RAW),  
        `bitrate`: bitrate (for MP3's)  
        `source`:filename, '-' or stream  
    },filename or '-'
}  

starts the sox process and opens the streams (if there are any)

sox output stream

sox input stream

sox error stream

path to sox

emits when sox outputs an error

emits when sox outputs a warning