Skip to content

[p5.js 2.0 Bug Report]: FFT.setInput(mic) is not a function. #8368

@Ayaan005-sudo

Description

@Ayaan005-sudo

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

v2.1.2

Web browser and version

Chrome 120/Firefox 124

Operating system

Windows11

Steps to reproduce this

In v2,the function FFT.setInput(mic) no longer exists. This differs from v1 where the same code worked correctly. The error shows that the API has changed in p5.sound v2.

STEPS TO REPRODUCE :
let mic, fft, peakDetect;

function setup() {
createCanvas(400, 400);
userStartAudio(); // IMPORTANT for browser

mic = new p5.AudioIn();
mic.start();

fft = new p5.FFT();
fft.setInput(mic);

peakDetect = new p5.PeakDetect(20, 20000, 0.15, 20);
}

function draw() {
background(30);

fft.analyze();
peakDetect.update(fft);

if (peakDetect.isDetected) {
fill(0, 255, 0);
textSize(32);
text("PEAK!", 150, 200);
}
}

->Run this in p5.js v2.1.2 with p5.sound enabled

OBSERVED BEHAVIOR
->Console:TypeError: FFT.setInput is not a function.

EXPECTED BEHAVIOR
->In v1,fft.setInpt(mic) works
->In v2 it does'nt.

This is v2 result:

Image

This is v1 result:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions