We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all !
i've been coding in processing for a few month now and i'm starting to use minim to add sound in my sketches yet i'm totally new to this library and afters hours of strugling i can't find a way to solve my problem: here is my basic code
import ddf.minim.*;
Minim minim;
AudioPlayer groove;
float x, y, a, b, c, d, z;
PFont police;
PFont polisse;
String DISASTERPEACE;
String HLD;
void setup() {
size(600, 600);
minim = new Minim(this);
groove = minim.loadFile("groove.mp3", 1024);
groove.loop();
background(0);
textAlign(CENTER);
emissive(0, 26, 51);
police=createFont("drifter.ttf", 32);
polisse=createFont("DF.ttf", 25);
textFont(police);
HLD="Hyper Light Drifter";
DISASTERPEACE="DISASTERPEACE";
smooth();
stroke(random(0, 255), random(0, 255), random(0, 255));
for (int i=0; i<40; i++)
{
fill(random(0, 255), random(0, 255), random(0, 255));
ellipse(x, y, z, z);
ellipse(a, b, z, z);
ellipse(c, d, z, z);
line(x, y, a, b);
line(x, y, c, d);
line(c, d, a, b);
x=random(0, 600);
y=x+20;
a=x-20;
b=random(0, 600);
c=b+20;
d=b-20;
z=3;
}
fill(255);
textSize(12);
text(HLD, 300, 275);
textSize(30);
text(DISASTERPEACE, 300, 313);
//save("ESSAIS10.jpg");
}
so i simply want the line to react to the playing music, i've read a ton of minim releated stuff and saw all the exemples about it and yet i can't manage to make thoose line vibrate to the music
i've tried many things but nothing worked.
thanks for your help
Answers
don't quote your code.
edit post, highlight code, press ctrl-o
tried but can't make that work too ^^
done
so i guess you've written code with both a setup() and a draw() before now. where's the draw() in this code?
thx, thats where i'm struggling, i know i need a draw to play the song, yet i've tried things such as moving the line from the setup to a draw but since i have a ton different coordinate ( all created randomly) for the ellipses and the line this is not working.
the problem is that i can't find a way to get enough lines without having to create a ton of value because i know i need the different value of each line in order to add the soundwave movement to them.
which line?
no real idea what you're talking about here. it's not obvious what you want the final thing to look like.
i meant the lines, sorry english is not my birth language
however, if you tried my code, you can see multiples lines and ellipses, well i just want the existing lines to react to the playing music using something like this ( it's the code from the minim package called DrawWaveFormAndLevel in the " basics" file )
for(int i = 0; i < groove.bufferSize() - 1; i++) { float x1 = map( i, 0, groove.bufferSize(), 0, width ); float x2 = map( i+1, 0, groove.bufferSize(), 0, width ); line( x1, 50 + groove.left.get(i)*50, x2, 50 + groove.left.get(i+1)*50 ); line( x1, 150 + groove.right.get(i)*50, x2, 150 + groove.right.get(i+1)*50 ); }
my problem is that all my lines are generated using random values and since they are generated in a setup() using for() they don't have specific locations
@Spoll=== try to create 2 arrays[] (for the x and b values, other can be found from them) and add your random values to the arrays in setup(); in draw you work with the stored values and can make the lines interact with line get in from minim.
thanks @akenaton=== so here is what i get
i'm really having a hard time with that ><
@Spoll===
something like that???- of course i have not added the minim getLineIn stuff but that is easy.
hey, thanks for your answer it helps me a lot, but now i have no idea how to make the lines react to the music ( resulting in a waveform)
sorry for bothering you
this is killing me, i don't understand anything about the library, i've made a few test with your code @akenaton=== this really helps me out, but i can't manage to get the lines to react properly to the music all i want is :
but the only reaction i get is
here is the code i modified, tell me if i do something wrong, thanks :
@Spoll=== in order to show (as i dont know what you exactly want...)
@akenaton=== sorry if i can't make myself easily understandable
well you see all the lines :
i just want them to act as the soundwave of the music
like that![](http://image.noelshack.com/fichiers/2016/52/1483024201-capture-d-ecran-2016-12-29-15-37-57.png)
as the song play, i would like them to vibrate with the music
you know, something like that![](http://img.youtube.com/vi/7oeb-OIOe-0/0.jpg)
The example that you are giving at the bottom uses a standing wave concept for visualizing harmonics -- it looks like it achieves different heights at different fixed distances by adding together each harmonic measurement (Notice also that activity in your example is symmetrical).
So that visualization is probably taking a measurement for the first, second, third, fourth harmonic etc., adding the values together, and drawing one line.
Here are some related readings to help you understand the concepts. The implementation would be to generate measures for each frequency (harmonic), then render the visualization graph as the addition of multiple curves (each harmonic function).