variable srate
This commit is contained in:
parent
7691403fd0
commit
4d13b981f1
1 changed files with 2 additions and 4 deletions
|
|
@ -42,11 +42,9 @@ const waveformAliases = [
|
||||||
];
|
];
|
||||||
const noises = ['pink', 'white', 'brown', 'crackle'];
|
const noises = ['pink', 'white', 'brown', 'crackle'];
|
||||||
|
|
||||||
function makeDistortionCurve(amount) {
|
function makeSaturationCurve(amount, n_samples) {
|
||||||
const k = typeof amount === 'number' ? amount : 50;
|
const k = typeof amount === 'number' ? amount : 50;
|
||||||
const n_samples = 44100;
|
|
||||||
const curve = new Float32Array(n_samples);
|
const curve = new Float32Array(n_samples);
|
||||||
const deg = Math.PI / 180;
|
|
||||||
|
|
||||||
for (let i = 0; i < n_samples; i++) {
|
for (let i = 0; i < n_samples; i++) {
|
||||||
const x = (i * 2) / n_samples - 1;
|
const x = (i * 2) / n_samples - 1;
|
||||||
|
|
@ -126,7 +124,7 @@ export function registerSynthSounds() {
|
||||||
|
|
||||||
const sat = new WaveShaperNode(ctx);
|
const sat = new WaveShaperNode(ctx);
|
||||||
// tri to sine diode shaper emulation
|
// tri to sine diode shaper emulation
|
||||||
sat.curve = makeDistortionCurve(2);
|
sat.curve = makeSaturationCurve(2, ctx.sampleRate);
|
||||||
|
|
||||||
const mix = gainNode(mixGain);
|
const mix = gainNode(mixGain);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue