Skip to content

Instantly share code, notes, and snippets.

@ivarmedi
Created December 16, 2022 09:40
Show Gist options
  • Save ivarmedi/a525bf939493062c0cbe130cbd811ac0 to your computer and use it in GitHub Desktop.
Save ivarmedi/a525bf939493062c0cbe130cbd811ac0 to your computer and use it in GitHub Desktop.
const script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/tunajs/1.0.4/tuna-min.js';
document.head.appendChild(script);
const apply = () => {
const context = new AudioContext();
const tuna = new Tuna(context);
const filter = new tuna.Filter({
frequency: 440,
Q: 80,
gain: 0,
filterType: 'bandpass',
bypass: 0
})
const overdrive = new tuna.Overdrive({
outputGain: 0,
drive: 1,
curveAmount: 0.65,
algorithmIndex: 2,
bypass: 0
})
let source;
const gain = context.createGain();
gain.gain.value = 0.05
overdrive.connect(filter)
gain.connect(overdrive);
filter.connect(context.destination);
const audioTags = document.getElementsByClassName("m-audio")
for (i=0; i<audioTags.length; i++) {
let audio = audioTags[i].firstChild
source = context.createMediaElementSource(audio);
source.mediaElement.playbackRate = 1.3
source.connect(gain);
}
}
setTimeout(apply, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment