fix click
This commit is contained in:
parent
5336569c25
commit
5129fa6677
2 changed files with 10 additions and 8 deletions
|
|
@ -146,6 +146,7 @@ export class ADSR {
|
||||||
startVal = 0;
|
startVal = 0;
|
||||||
|
|
||||||
update(curTime, gate, attack, decay, susVal, release) {
|
update(curTime, gate, attack, decay, susVal, release) {
|
||||||
|
console.info('here')
|
||||||
switch (this.state) {
|
switch (this.state) {
|
||||||
case 'off': {
|
case 'off': {
|
||||||
if (gate > 0) {
|
if (gate > 0) {
|
||||||
|
|
@ -352,6 +353,7 @@ let getDefaultValue = (key) => defaultDefaultValues[key];
|
||||||
|
|
||||||
export class Dough {
|
export class Dough {
|
||||||
init(value, sampleRate) {
|
init(value, sampleRate) {
|
||||||
|
|
||||||
// params without defaults:
|
// params without defaults:
|
||||||
/*
|
/*
|
||||||
bank,
|
bank,
|
||||||
|
|
@ -447,12 +449,13 @@ export class Dough {
|
||||||
// not sure if gain is applied here
|
// not sure if gain is applied here
|
||||||
s = s * this.gain;
|
s = s * this.gain;
|
||||||
// envelope
|
// envelope
|
||||||
let gate = Number(t >= this._begin && t <= this._end);
|
let gate = Number(t >= this._begin && t <= this._holdEnd);
|
||||||
|
|
||||||
/* Math.random() > 0.99 && console.log('gate', gate); */
|
/* Math.random() > 0.99 && console.log('gate', gate); */
|
||||||
const env = this._adsr.update(t, gate, this.attack, this.decay, this.sustain, this.release);
|
const env = this._adsr.update(t, gate, this.attack, this.decay, this.sustain, this.release);
|
||||||
s = s * env;
|
s = s * env;
|
||||||
|
|
||||||
s = s * this.postgain * 0.3;
|
s = s * this.postgain * .3
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { Pattern } from '@strudel/core';
|
import { Pattern } from '@strudel/core';
|
||||||
import { connectToDestination, destroyAudioWorkletNode, getAudioContext } from 'superdough';
|
import { connectToDestination, destroyAudioWorkletNode, getAudioContext, webAudioTimeout } from 'superdough';
|
||||||
|
|
||||||
Pattern.prototype.supradough = function () {
|
Pattern.prototype.supradough = function () {
|
||||||
return this.onTrigger((_, hap, __, cps, begin) => {
|
return this.onTrigger((_, hap, __, cps, begin) => {
|
||||||
const { value } = hap;
|
const { value } = hap;
|
||||||
|
|
@ -14,10 +13,11 @@ Pattern.prototype.supradough = function () {
|
||||||
)[3];
|
)[3];
|
||||||
|
|
||||||
const duration = hap.duration / cps;
|
const duration = hap.duration / cps;
|
||||||
const holdend = begin + duration;
|
const holdEnd = begin + duration;
|
||||||
const end = holdend + release + 0.01;
|
const end = holdEnd + release + 0.01;
|
||||||
value._begin = begin; // these are needed for the gate signal
|
value._begin = begin; // these are needed for the gate signal
|
||||||
value._end = end;
|
value._end = end;
|
||||||
|
value._holdEnd = holdEnd
|
||||||
|
|
||||||
let o = getWorklet(
|
let o = getWorklet(
|
||||||
ac,
|
ac,
|
||||||
|
|
@ -29,8 +29,7 @@ Pattern.prototype.supradough = function () {
|
||||||
);
|
);
|
||||||
|
|
||||||
o.port.postMessage(value); // send value to worklet
|
o.port.postMessage(value); // send value to worklet
|
||||||
let timeoutNode = webAudioTimeout(ac, () => destroyAudioWorkletNode(o), begin, end);
|
webAudioTimeout(ac, () => destroyAudioWorkletNode(o), begin, end);
|
||||||
timeoutNode.stop(end + 0.125);
|
|
||||||
connectToDestination(o); // channels?
|
connectToDestination(o); // channels?
|
||||||
}, 1);
|
}, 1);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue