Using sound files: play, loop, spectrum analysis

Keyboard example, with different ways to play sound samples: download

Real time spectrum analysis via Fast Fourier transform download

Adding cues to the sound that trigger a function at a certain points in the reproduction download

Sounds work almost like images. To make this example work download an mp3 file and put it in an assets folder inside your project. You can go to freesound or download mp3 from youtube.

var mySound;

function preload() {
  mySound = loadSound('assets/mySound.mp3');

function setup() {
//also try looping

function draw() {

//sound mode
function mouseClicked() {

function keyPressed() {

Posted in