add basic spectrum function
This commit is contained in:
parent
ae335ac40c
commit
648fbf99fa
4 changed files with 61 additions and 2 deletions
|
|
@ -270,11 +270,12 @@ function getReverb(orbit, duration, fade, lp, dim, ir) {
|
|||
export let analysers = {},
|
||||
analysersData = {};
|
||||
|
||||
export function getAnalyserById(id, fftSize = 1024) {
|
||||
export function getAnalyserById(id, fftSize = 1024, smoothingTimeConstant = 0.5) {
|
||||
if (!analysers[id]) {
|
||||
// make sure this doesn't happen too often as it piles up garbage
|
||||
const analyserNode = getAudioContext().createAnalyser();
|
||||
analyserNode.fftSize = fftSize;
|
||||
analyserNode.smoothingTimeConstant = smoothingTimeConstant;
|
||||
// getDestination().connect(analyserNode);
|
||||
analysers[id] = analyserNode;
|
||||
analysersData[id] = new Float32Array(analysers[id].frequencyBinCount);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue