Soundrive
A simple but flexible audio oscillator for ECMAScript.
Preface
The need for Soundrive came from wanting an oscillator that can smoothly sweep between frequencies while still being easy to use in Node.js and browsers.
To use in the browser, you will probably have to compile it using Babel and/or a tool like Browserify.
Installation
npm install --save soundrive
Yay! No dependencies!
Use
Simplest example:
const Soundrive = oscillator = SoundriveOscillator frameSize = 4096 frame = frameSize; let i = 0; while i < frameSize framei = oscillator; i++;
The following creates a sweep(i.e. chirp) between two frequencies:
const oscillator = SoundriveOscillator frameSize = 44100 // one second if that's the sample rateframe = frameSize; let i = 0; oscillator; while i < frameSize framei = oscillator; i++;
The resulting frame of samples will be 1 second with a 0.5 second transition between 1234hz and 2345hz.
Mix
You can "mix" oscillators together to produce multiple tones.
const oscillator1 = SoundriveOscillator oscillator2 = SoundriveOscillator frameSize = 4096 frame = frameSize mix = oscillator1; let i = 0; while i < frameSize framei = mix i++;
Testing
Tests use Mocha. Use npm run test
to perform them.