loadSound('mySound.mp3')
Text
via http://www.npr.org/2014/04/09/300563606/what-does-sound-look-like
i.e. 44.1kHz
44100 samples per second
256
512
1024
samples
Oscilloscope: A buffer of samples over time
1.0
-1.0
0
for (var i = 0; i < bufLength; i++) {
x = inputBuffer[i];
total += Math.max(Math.min(x/this.volMax, 1), -1);
// SQUARE
sum += Math.max(Math.min(x/this.volMax, 1), -1), 2) * Math.max(Math.min(x/this.volMax, 1), -1);
}
// MEAN
var average = total/ bufLength;
// ROOT ... then take the square root of the sum.
var rms = Math.sqrt(sum / bufLength);
Root Mean Square a buffer of samples
gainToDB: 20 * (Math.log(value) / Math.LN10);
Array
threshold, cutoff, decayRate
Spectrum
FFT - Fast Fourier Transform
Human Hearing: 20Hz to 20,000Hz (20 kHz)
/ 2 = Nyquist
22,500
more about sampling rates and Neil Young (ht @infomuotoilu)
Sub Bass: 20-60Hz
Bass: 60-250 Hz
Low Midrange: 250-500 Hz
Midrange: 500Hz-2kHz
Upper Midrange: 2-4khz
Presence: 4-6khz
Brilliance: 6kHz - 20kHz
example:
- thumb piano vs violin
- square wave vs sine wave
compression (jpeg, mp3)
Crick & Watson used it to decode DNA
via wikipedia
Amplitude + Phase
http://bl.ocks.org/jinroh/raw/7524988/
Short buffer - detect onsets
Long buffer - better for frequency precision
44100/1024 ~= 43Hz
Tmema (Golan Levin + Zach Lieberman), Jaap Blonk, Joan La Barbara
More info @ tmema
Compare the signal with itself shifted by x samples. If a lag of x samples correlates, then sampleRate / x may be the fundamental frequency.
image via cnx.org pitch detection algorithms
pitch detection with lowpass filter
raw autocorrelation
.addCue(time, callback, value)
p5.Font()
Examples w/ LRC to JSON parser by @justan
curl -F "api_key=[YOURAPIKEY]" -F "filetype=mp3" -F
"track=@[PATH]" "http://developer.echonest.com/api/v4/track/upload"
// Paste the ID and your API key into this GET request:
http://developer.echonest.com/api/v4/track/profile?api_key=[YOURAPIKEY]
&format=json&id=[YOURTRACKID]&bucket=audio_summary
// click thru to analysis and save
thank you!
bit.ly/p5jsmusicviz
@therewasaguy