Created
June 13, 2017 04:44
-
-
Save zcaceres/ee4231f228c71fe47db5bd64104b929f to your computer and use it in GitHub Desktop.
JS sample one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Tuna from 'tunajs' | |
/* | |
Takes in the audio context and audio source declared by the WebAudioAPI. You'll | |
need to set get access to the user's microphone and set up an audio node. | |
Use this tutorial to start: https://www.html5rocks.com/en/tutorials/webaudio/intro/ | |
*/ | |
const processRadioTransmission = (audioContext, audioSource) => { | |
var tuna = new Tuna(audioContext) | |
// Filters out high and low freqs | |
var filter = new tuna.Filter({ | |
frequency: 440, | |
Q: 80, | |
gain: 0, | |
filterType: 'bandpass', | |
bypass: 0 | |
}) | |
// Distorts audio | |
var overdrive = new tuna.Overdrive({ | |
outputGain: 0, | |
drive: 1, | |
curveAmount: 0.65, | |
algorithmIndex: 2, | |
bypass: 0 | |
}) | |
var gainNode = audioContext.createGain() | |
gainNode.gain.value = 0.05 // Careful with volume here! | |
// Chains WebAudio nodes together to return processed audio buffer | |
filter.connect(overdrive) | |
audioSource.connect(overdrive) | |
overdrive.connect(gainNode) | |
gainNode.connect(audioContext.destination) | |
// ^ After lowering volume, pass to destination for playing | |
} | |
export default processRadioTransmission |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment