1.0.0 • Published 6 years ago

audio-noise v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

audio-noise Build Status experimental

Fill array or audio-buffer with defined type of noise.

$ npm install audio-noise

let createNoise = require('audio-noise')

let noise = createNoise('pink')

//create array filled with pink noise
let arr = noise(Array(1024))

createNoise(color|options?)

Create noise generator of specific color or based on options.

options

PropertyDefaultMeaning
type, color'white'Color of noise.
sampleRate44100Output data sample rate.
channels1Output data number of channels.
samplesPerFrame1024Default length of the block.
format'float32'Output data format, eg. 'uint8 interleaved', 'float32 planar', 'array', 'audiobuffer' etc. See pcm-convert and audio-format for list of available formats.

color or options.color

ValueSpectrumDescription
'white'Flat spectrum noise. See wiki.
'pink'-3dB/octave. See wiki.
'brown'-6dB/octave. See wiki.
'blue'TODO +3dB/octave.
'violet'TODO +6dB/octave.
'grey'TODO White noise weighted by loudness curve, see a-weighting. Also see wiki
'green'TODO

noise(target|length?)

Fill passed audio-buffer or array with noise. Buffer is modified in-place.

const write = require('web-audio-write')()
const noise = require('./')({color: 'white', format: 'stereo audiobuffer'})

;(function tick(err) {
	if (err) throw err
	write(noise(), tick)
})()

Related

See also

License

© 2017 Dmitry Yvanov @ audiojs. MIT License