Hello
Thank you so much for responding - really appreciate your time!
The output you shared is similar but I’m getting triangles (so I must be getting two values at a time).
I basically want to create a line to show the amplitude of the entire song - with one point representing one frame (i.e. one value for each frame) . I’ve attached a bit of code that is similar to the last but I’ve replaced the last bit with circles - essentially I’m wanting to create a line that links up all those circles.
My problem seems to be how I’m using the arrays but I don’t fully understand what I should be doing. I essentially want to play the entire song and store the individual amp values per frame for the entire song into an array AND THEN do my drawing. However, this is the bit I must be doing wrong but I’m not sure if it’s my logic (and I’m not even on the right track) or the logic is ok but my code is wrong…
Do you know if it’s to do with audio samples vs audio files?
Thanks again
Becky
import processing.sound.*;
// Declare the processing sound variables
SoundFile sample;
Amplitude rms;
float sum;
float[] ampHistory;
int i;
void setup() {
//noLoop();
size(640, 360);
background(255);
//Load and play a soundfile and loop it
sample = new SoundFile(this, "pigeon_01.wav");
sample.play();
// Create and patch the rms tracker
rms = new Amplitude(this);
rms.input(sample);
}
void draw() {
stroke(0);
strokeWeight(5);
int numberSteps = 150;
if (i < numberSteps) {
i += ceil(rms.analyze());
sample.frames();
// smooth the rms data by smoothing factor
sum += (rms.analyze() - sum) * 0.25;
float rms_scaled = sum * (height/2) * 5;
println(rms_scaled, i);
ampHistory = new float[numberSteps+1];
ampHistory[i] = rms_scaled;
circle(i*2,100 - ampHistory[i],20);
}
stroke(0);
strokeWeight(5);
}