How to use the p5.FFT function in p5

To help you get started, we’ve selected a few p5 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zero-to-mastery / visual-music / src / vendor / sketch.js View on Github external
p.setup = function() {
        // Canvas setup
        p.background(7, 11, 21);
        canvas = p.createCanvas(width, height);
        fft = new p5.FFT(0.9, 256); // for the waves
        amplitude = new p5.Amplitude(); // for the ellipses
        p.noFill();
        p.stroke(0, 100);
        initAudioStream();
    };
github ccorcos / circle / src / sketch.js View on Github external
p.setup = () => {
      this.canvas = p.createCanvas(window.innerWidth, window.innerHeight);

      if (this.state.mode === "mic") {
        this.mic = new p5.AudioIn();
        this.mic.start();
        this.fft = new p5.FFT();
        this.fft.setInput(this.mic);
      } else {
        // using a song file
        this.song.setVolume(1.0);
        this.song.playMode("restart");
        this.song.play();
        this.fft = new p5.FFT();
        this.fft.setInput(this.song);
      }
    };
github ccorcos / circle / src / blah.js View on Github external
p.setup = () => {
      this.canvas = p.createCanvas(this.width, this.height);
      p.noFill();

      // using microphone
      // this.mic = new p5.AudioIn();
      // this.mic.start();
      // this.fft = new p5.FFT();
      // this.fft.setInput(this.mic);

      // using a song file
      this.song.setVolume(1.0);
      this.song.playMode("restart");
      this.song.play();
      this.fft = new p5.FFT();
      this.fft.setInput(this.song);
    };
github LiamPKenna / js-drumz / src / js / synth.js View on Github external
p5.noFill();

    carrier = new P5.Oscillator('sine');
    carrier.amp(0);
    carrier.freq(100);
    carrier.start();


    modulator = new P5.Oscillator('triangle');
    modulator.disconnect();
    modulator.freq(5);
    modulator.amp(1);
    modulator.start();
    carrier.freq(modulator);

    analyzer = new P5.FFT();


    const toggleAudio = (cnv) => {

      p5.waveform = analyzer.waveform();
      cnv.mouseClicked(function() {
        modFreq = p5.map(p5.mouseY, p5.height, 0, modMinFreq, modMaxFreq);
        modulator.freq(modFreq);


        modDepth = p5.map(p5.mouseX, 0, p5.width, modMinDepth, modMaxDepth);
        modulator.amp(modDepth);
        carrier.amp(1,1);
      });

    };

p5

[![npm version](https://badge.fury.io/js/p5.svg)](https://www.npmjs.com/package/p5)

LGPL-2.1
Latest version published 24 days ago

Package Health Score

95 / 100
Full package analysis