Hi! I've just uploaded an edit of a bunch of sketches I made through a process of experimentation and learning.
Libraries used: Minim, Modelbuilder & Geomerative. I'll be sharing some (rather un
refined & inelegant) source code over the next couple of days. Hope you like it! :D
I'm making audio reactive visuals. I want to isolate specific frequencies and assign different animations to them. Not sure if relevant, the music for my first project is drum n bass, but I'm interested in creating visuals using various types of beat heavy electronic music, think Autechre, Apparat, Minimal Techno etc.
Process
I looked into Beads (read the great "Sonifying Processing" Tutorial) and using getFeatures() - but wasn't able to get the results I was looking for.
I looked into Minim - Beat Detect in Frequency Energy mode wasn't specific & exact enough for me. I spent the entire Easter Weekend searching for information and looking at other's sketches. I learnt about
Averages and more specifically
Logarithmic Averages. Splitting the spectrum into bands makes sense to me. Using this method I arrived at slightly more pleasing results.
I see
amnon.owed says on
this thread that accurate audio detection is pretty hard. >.<
Result
I have a sketch using ddf's suggested method as specified in the above link, and am currently using 12 bands. I am using calcAvg() and "if" statements to access the indexes of the frequencies. (I'm using 2 "ranges" at the moment for this exercise)
A: Am I going about this the right way? Just because it's kinda working, doesn't leave me convinced that my code is optimised for the best way forward. Are "if" statements on the indexes the "right" way to do this?
B: To gain access to more frequencies, I just work with more bands right? I am not blown away with the accuracy of audio - reactiveness but probably need to work on it a bit more.
C: I found on the interwebs
this sketch that is pretty damn accurate. But it looks so complicated! I don't know if I should try to pick apart & understand the code, and I don't know how to credit this guy, have no idea how I even came across this, would I just add a link to his website at the top of the sketch? Lol.
So what I'm ultimately asking is, how can I make this sketch super audio reactive. I'm looking for Trapcode Form level of accuracy. It would be awesome to create a template that I can share, because I really struggled to find a simplified #noob-level stripped down sketch that does what I want it to!
(I've removed most of my comments but left a few in, might help someone). Also I'm loading a .wav, if anyone copies this, just replace "tricky.wav" with "songname.wav" or "songname.mp3"
Thanks in advance!!!
import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
AudioPlayer song;
FFT fft;
int sampleRate = 44100;
int timeSize = 1024;
void setup() {
size(500, 500);
smooth();
minim = new Minim(this);
song = minim.loadFile("tricky.wav", 2048);
song.loop();
fft = new FFT( song.bufferSize(), song.sampleRate() ); // make a new fft
// calculate averages based on a miminum octave width of 11 Hz
// split each octave into 1 bands - this should result in 12 averages
fft.logAverages(11, 1); // results in 12 averages, each corresponding to an octave, the first spanning 0 to 11 Hz.
}
void draw() {
background(0);
noStroke();
fft.forward(song.mix); // perform forward FFT on songs mix buffer
// float bw = fft.getBandWidth(); // returns the width of each frequency band in the spectrum (in Hz).
I'm a noob learning processing with Casey Reas & Ben Fry and their amazing book.
As an exercise, I would like to scale a grid of circles from small (0px) to large (50px) to small (0px) again. I managed to do the reverse (big to small to big) using the map function and converting a value to a range of -1.0 to 1.0 and translating this into scale of -50, 0 and 50. (Sorry if my language is incorrect)
How do I "reverse" this? I got a result using
if statements but wondering if there is way to convert to a range of numbers that start at 0, increase to 50 in (for example) 10px increments, and then decrease to 0 again. I'm also unsure if the method of using map as I used it below is the "correct" way to tackle such a thing, converting to one range and then converting to another. Trying to apply some of the things I've learnt thus far.
Apologies if this has been answered, I did search the forum and couldn't find anything. I have pasted my code below.
Thanks in advance guys!
size(500, 500);
background(255);
fill(0);
noStroke();
for (int x = 0; x < 550; x+=50) {
for (int y = 0; y < 550; y+=50) {
float newX = (x*0.200)/2; // convert stage width to increments of 5 between 0 and 50
float n = map(newX, 0, 50, -1.0, 1.0); // convert to new range between -1.0 & 1.0
float s = map(n, -1.0, 1.0, -50, 50); // convert to new range between -50 & 50
//float sPos = lerp(0, 50, n); // does same as above
ellipse(x, y, s, s);
println(s);
// I achieve what I want with the below, but feels like there could be more elegant solution