- Source:
Example
const dsp = require('dsp-kit')
dsp.fill(1024, dsp.white())
Methods
(static) brown(compensateopt) → {function}
Create a function that generates brown noise
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
compensate |
Number |
<optional> |
3.5 | the gain compensation value |
- Source:
Returns:
the brown noise generator function
- Type
- function
Example
var dsp = require('dsp-kit')
dsp.fill(1024, dsp.brown())
(static) pink(compensateopt) → {function}
Create a function that generates pink noise
Pink noise has an even distribution of power if the frequency is mapped in a logarithmic scale.
If 'white' consists of uniform random numbers, such as those generated by the rand() function, 'pink' will have an almost gaussian level distribution.
This is an approximation to a -10dB/decade filter using a weighted sum of first order filters. It is accurate to within +/-0.05dB above 9.2Hz (44100Hz sampling rate). Unity gain is at Nyquist, but can be adjusted by scaling the numbers at the end of each line.
It uses the Paul Kellet’s (refined) method: has smooth spectrum, but goes up slightly at the far high end
References
- https://github.com/csound/csound/blob/develop/Opcodes/pitch.c#L1338
- http://www.musicdsp.org/files/pink.txt
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
compensate |
Number |
<optional> |
0.11 | The result will be multiplied by this constant in order to compensate the gain output |
- Source:
Returns:
the pink noise generator function
- Type
- function
Example
var dsp = require('dsp-kit')
dsp.fill(1024, dsp.pink())
(static) white(compensateopt) → {function}
Create a function that generates white noise
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
compensate |
Number |
<optional> |
1 | the gain compensation |
- Source:
Returns:
the white noise generator function
- Type
- function
Example
var dsp = require('dsp-kit')
dsp.fill(1024, dsp.white())