Skip to content

Latest commit

 

History

History
96 lines (70 loc) · 8.2 KB

p5.md

File metadata and controls

96 lines (70 loc) · 8.2 KB

Visualizing Music with p5.js

Our perception of music defies technology. Music triggers our emotions, and evokes the full range of our senses. Take the artist Kandinsky, who associated musical qualities with particular colors and shapes. Meanwhile, a computer processes music as numbers and data which can be incredibly powerful. How can we map this data onto meaningful visuals that enhance our experience of music?

This session is for anyone who would like to explore music, visuals and creative coding for the web. We'll demonstrate types of data we can get from digital signal processing using interactive sketches in p5.js and the p5.sound library that builds upon the Web Audio API. We'll focus on Amplitude, Frequency Spectrum, and maybe some DIY Beat Detection. We'll share ideas and collaborate in the creation of online music visualizations.

Libraries

Participants may use whatever tools they wish, but the demos in this repo use the following libraries:

p5.js is a JavaScript library that starts with the original goal of Processing, to make coding accessible for artists, designers, educators, and beginners, and reinterprets this for today’s web.

p5.sound.js is an addon library that brings the Processing approach to the Web Audio API.

Setup

A few more complex p5 examples:


p5.sound Classes That We'll Use For Music Visualizations:

p5.AudioIn - microphone! documentation | source code

p5.SoundFile - load and play .mp3 / .ogg files. documentation | source code

  • loadsound() creates a SoundFile. Use during preload(), or with a callback.
  • To ensure browser compatability, you can provide both mp3 and ogg options.
  • .getPeaks() - an array of peak amplitudes over the course of the entire sound file. demo | source

p5.Amplitude - Analyze volume. documentation | source code

  • .getLevel() returns a Root Mean Square (RMS) amplitude reading, between 0.0 and 1.0, usually peaking at 0.5
  • .smooth()

p5.FFT - Analyze amplitude over time or frequency. documentation | source code

  • .analyze() returns amplitude readings from 0-255 across the frequency spectrum
  • .waveform() returns amplitude readings from 0-255 across a brief snapshot of time. demo | source

Demos:

Music included in the demos/repo:

Dig Deeper into Web Audio Music Visualization...

Music Visualization Inspiration...