Hi, I'm sorry. I supposed it was a general problem.
I'm just using the simple Processing enviroment, I'm beginner. My code may let you see that. No timeline animation either.
Thanks so much for your answer.
(The code below won't compile unless you have pitaru.Sonia library and any sound file called "a.wav" in data folder. It should start with any sound directly to the mic)
mainTag
- import pitaru.sonia_v2_9.*;
ArrayList particles;
PFont fuente;
Sample aaah;
void setup() {
size(screen.width,screen.height);
smooth();
particles = new ArrayList();
fuente =loadFont ("Avian-25.vlw");
frameRate (24);
Sonia.start(this); // Start Sonia engine.
LiveInput.start(); // Start listening to the microphone
}
void draw() {
background (0);
for (int i = 0; i<particles.size(); i++) {
LimitedParticle object = (LimitedParticle) particles.get(i);
object.update();
fill(255);
object.display();
}
float vol = LiveInput.getLevel();
if (vol > 0.20) {
float velX = random(-2, 2);
LimitedParticle object = new LimitedParticle(width/2, 0,velX, 0, 2.2);
particles.add(object);
}
}
public void stop() {
Sonia.stop();
super.stop();
}
Limited Particle
- class LimitedParticle extends Particle {
float friction = 0.99999995;
int s = second();
LimitedParticle(int ix, int iy, float ivx, float ivy, float ir) {
super (ix, iy, ivx, ivy, ir);
aaah = new Sample("a.wav");
}
void update() {
vy *= friction;
vx *= friction;
super.update();
limit();
}
void limit() {
if (y > height-radius) {
vy = -vy;
y = constrain(y, -height*height, height-radius);
if (y==height-radius){
if (s > 10) {
println ("bingo");
aaah.play();
}
}
}
if ((x < radius) || (x > width-radius)) {
vx = -vx;
x = constrain(x, radius, width-radius);
}
}
}
Particle
- class Particle {
float x, y; // The x- and y-coordinates
float vx, vy; // The x- and y-velocities
float radius; // Particle radius
float gravity = 5;
int a;
char alfa[] = {
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','ñ','o','p','q','r','s','t','u','v','w','x','y','z' };
char copy[] = new char[27];
Particle (int xpos, int ypos, float velx, float vely, float r) {
x = xpos;
y = ypos;
vx = velx;
vy = vely;
radius = r;
arraycopy(alfa,0,copy,0,27);
textAlign (CENTER,BOTTOM);
if(alfa.length>0){
int index = int (random(alfa.length));
a = index;
if ( index > 0 && index < alfa.length-1 ){
alfa = concat(subset(alfa,0,index), subset(alfa,index+1,alfa.length-index-1));// takes out just picked
}
else if ( index == 0 ){
alfa = subset(alfa,1,alfa.length-1); // if 0 takes out first
}
else{
alfa = shorten(alfa);// takes last one out
}
}
else{
alfa = new char[27];
arraycopy(copy,0,alfa,0,27);
}
print (a+",");
// a = int (random(copy.length));
}
void update() {
vy = vy + gravity;
y += vy;
x += vx;
}
void display() {
for (int i = a; i==a; i++) {
textFont (fuente,int (random (10,60)));
text (copy[i],x,y);
}
}
}