Skip to content

Instantly share code, notes, and snippets.

Vitaliy Bobrov vitaliy-bobrov

Block or report user

Report or block vitaliy-bobrov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View cabinet.js
guitarInput
.connect(convolver)
.connect(makeUpGain)
.connect(bassNode)
.connect(midNode)
.connect(trebleNode)
.connect(context.destination);
View smoosh-gain.js
const level = 5;
const duration = 0.01;
midNode.gain.setTargetAtTime(level, context.currentTime, duration);
View equalizer.js
const bassNode = new BiquadFilterNode(context, {
type: 'lowshelf',
frequency: 500
});
const midNode = new BiquadFilterNode(context, {
type: 'peaking',
Q: Math.SQRT1_2,
frequency: 1500
});
View make-up-gain.js
const makeUpGain = new GainNode(context, {
// Need to be adjusted to a particular IR.
gain: 5
});
guitarInput
.connect(convolver)
.connect(makeUpGain)
.connect(context.destination);
View connect-convolver.js
guitarInput.connect(convolver).connect(context.destination);
View fetch-convolver.js
const convolver = new ConvolverNode(context);
fetch('impulse.wav')
.then(response => response.arrayBuffer())
.then(buffer => {
context.decodeAudioData(buffer, decoded => {
convolver.buffer = decoded;
})
.catch((err) => console.error(err));
});
View format.js
const audio = document.createElement('audio');
console.log(audio.canPlayType('audio/wav')); // "maybe"
if (!audio.canPlayType('audio/wav')) {
console.log('The format is not supported!');
}
View convolver.js
const context = new AudioContext();
const convolver = new ConvolverNode(context);
View range-control.js
const control = document.querySelector('.gain-control');
control.addEventListener('change', (event) => {
const parsed = parseFloat(event.target.value);
const value = Number.isNaN(parsed) ? 1 : parsed;
const clamped = clamp(value);
gainNode.gain.setTargetAtTime(clamped, context.currentTime, 0.01);
});
View range.html
<input
class="gain-control"
type="range"
min="0"
max="1"
step="0.01"
value="0.5">
You can’t perform that action at this time.