Document reverb controls

This commit is contained in:
Raphael Forment 2023-10-01 11:52:24 +02:00
parent 0ad0046a76
commit abff279707
3 changed files with 57 additions and 7 deletions

View File

@ -970,6 +970,41 @@ const generic_params = [
*
*/
[['room', 'size']],
/**
* Reverb lowpass starting frequency (in hertz).
*
* @name revlp
* @param {number} level between 0 and 20000hz
* @example
* s("bd sd").room(0.5).revlp(10000)
* @example
* s("bd sd").room(0.5).revlp(5000)
*/
['revlp'],
/**
* Reverb lowpass frequency at -60dB (in hertz).
*
* @name revdim
* @param {number} level between 0 and 20000hz
* @example
* s("bd sd").room(0.5).revlp(10000).revdim(8000)
* @example
* s("bd sd").room(0.5).revlp(5000).revdim(400)
*
*/
['revdim'],
/**
* Reverb fade time (in seconds).
*
* @name fade
* @param {number} seconds for the reverb to fade
* @example
* s("bd sd").room(0.5).revlp(10000).fade(0.5)
* @example
* s("bd sd").room(0.5).revlp(5000).fade(4)
*
*/
['fade'],
/**
* Sets the room size of the reverb, see {@link room}.
*
@ -1162,7 +1197,7 @@ const generic_params = [
];
// TODO: slice / splice https://www.youtube.com/watch?v=hKhPdO0RKDQ&list=PL2lW1zNIIwj3bDkh-Y3LUGDuRcoUigoDs&index=13
controls.createParam = function (names) {
controls.createParam = function(names) {
const name = Array.isArray(names) ? names[0] : names;
var withVal;
@ -1186,7 +1221,7 @@ controls.createParam = function (names) {
const func = (...pats) => sequence(...pats).withValue(withVal);
const setter = function (...pats) {
const setter = function(...pats) {
if (!pats.length) {
return this.fmap(withVal);
}

View File

@ -2,7 +2,13 @@ import reverbGen from './reverbGen.mjs';
if (typeof AudioContext !== 'undefined') {
AudioContext.prototype.generateReverb = reverbGen.generateReverb;
AudioContext.prototype.createReverb = function(duration, audioContext) {
AudioContext.prototype.createReverb = function(
duration,
audioContext,
fade,
revlp,
revdim
) {
const convolver = this.createConvolver();
convolver.setDuration = (d) => {
this.generateReverb(
@ -11,9 +17,9 @@ if (typeof AudioContext !== 'undefined') {
sampleRate: 44100,
numChannels: 2,
decayTime: d,
fadeInTime: d,
lpFreqStart: 2000,
lpFreqEnd: 15000,
fadeInTime: fade,
lpFreqStart: revlp,
lpFreqEnd: revdim,
},
(buffer) => {
convolver.buffer = buffer;

View File

@ -113,7 +113,13 @@ function getReverb(orbit, duration = 2) {
// If no reverb has been created for a given orbit, create one
if (!reverbs[orbit]) {
const ac = getAudioContext();
const reverb = ac.createReverb(duration, getAudioContext());
const reverb = ac.createReverb(
duration,
getAudioContext(),
fade,
revlp,
revdim,
);
reverb.connect(getDestination());
console.log(reverb)
reverbs[orbit] = reverb;
@ -222,6 +228,9 @@ export const superdough = async (value, deadline, hapDuration) => {
delaytime = 0.25,
orbit = 1,
room,
fade = 0.1,
revlp = 15000,
revdim = 1000,
size = 2,
velocity = 1,
analyze, // analyser wet