Loading...
Copy code
Close
Permalink
Close
Please tell us why you want to mark the subject as inappropriate.
(Maximum 200 characters)
Report Inappropriate
Cancel
Private Message
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Cancel
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Update
Cancel
Feedback
Email ID
Subject :
Comments :
Send
Cancel
Private Message
Type the characters you see in the picture below.
Type the characters you see in the picture below.
Attach files
Desktop
Zoho Docs
Google Docs
Each Attachment size should not exceed 1MB.
Max no of attachments : 0
Loading User Profile...
guest
Response title
This is preview!
Attachments
Publish
Back to edit
Cancel
(
)
Sign In
You can also use the below options to login
Login with Facebook
Login with Google
Login with Yahoo
New to this Portal?
Click on Join Now to Sign Up
Join Now
Help
Feedback
Sign In
Processing Forum
Recent Topics
All Forums
Search All
Tags
Author
Advanced Search
Search
New Topic
Screen name:
berthalaban
berthalaban's Profile
3
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
"Next" sound button, minim - I get an error - help!
[0Replies]
16-May-2012 09:57 AM
Forum:
Core Library Questions
Hi, I'm working on a sound visualization and I'm trying add a button
that play the next song in the data folder.
I tried creating a separate array playlist but I found that the sound visualization stops
because the visualization is relying on "track.left.get(i)" of the sound waveform and
it's not included in the array playlist.
So I tried to make an array playlist using the original "track", but now I'm getting an error saying
"track.left cannot be resolved or is not a valid field".
Where am I doing wrong?
How should I write the codes so that both the button and the visualization works?
I'm really new to processing, so kind explanation would help a bunch.
Help me out please :(
The visualization looks roughly like this..
import processing.serial.*;
import cc.arduino.*;
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
Minim minim;
AudioPlayer[] track; //audio file array
//AudioPlayer track;
WaveformRenderer waveform;
float bpm = 50.2;
float mspb = 60000/bpm;
float x = 0;
float y = 0;
float x1 =0;
float x2 =0;
float y2 =0;
float y1 =0;
int a=1;
float line_height = 1;
int time = 0;
PImage blackbutton;
Arduino arduino;
void setup() {
size(1440, 700);
arduino = new Arduino(this, Arduino.list()[0], 57600);
for (int i = 0; i <= 13; i++)
arduino.pinMode(i, Arduino.INPUT);
colorMode(RGB);
background(255);
stroke(255);
strokeWeight(0);
frameRate(20);
smooth();
track = new AudioPlayer[3];
minim = new Minim(this);
track[0] = minim.loadFile("doublecherry.mp3", 2560);
track[1] = minim.loadFile("springbreaks.mp3",2560);
track[2] = minim.loadFile("robot.mp3",2560);
//track.loop();
//song = new AudioPlayer[3];
blackbutton = loadImage("blackbutton.png");
waveform = new WaveformRenderer();
track.addListener(waveform);
}
void draw() {
image(blackbutton,100,550,48,100);
int lapse = millis();
for (int i = 0; i <= 10; i++) {
x1 = x;
x2 = x;
y1 = track.left.get(i);
y2 = track.left.get(i+1);
fill(1, map( abs(track.left.get(i)), 0, 1, 0, 255), 2,random(80));
//fill(arduino.analogRead(i), map(abs(track.left.get(i)), 0,1,0,255),2, random(80));
println(track.left.get(i));
println(arduino.analogRead(i)/5);
}{
for (int i = 0; i < track.left.size()-1; i++) {
x1 = x;
x2 = x;
y1 = track.left.get(i);
y2 = track.left.get(i+1);
noStroke();
ellipseMode(CENTER);
ellipse(x, y,abs(track.left.get(i))*13,abs(track.left.get(i))*13);
x+=abs(track.left.get(i))*20;
x+=5;
}
}
if (lapse > mspb || x > width ) {
time = millis();
y += 6;
x = 0;
if (y > height){
y = 0;
background(255);
}
}
waveform.draw();
}
void mousePressed() {
if(mouseX>100 && mouseX<148)
if(mouseY>550 && mouseY<650)
if(track[0].isPlaying()){
track[0].pause();
}
else{
track[1].play();
}
if(mouseX>100 && mouseX<148)
if(mouseY>550 && mouseY<650)
if(track[1].isPlaying()){
track[1].pause();
}
else{
track[2].play();
}
if(mouseX>100 && mouseX<148)
if(mouseY>550 && mouseY<650)
if(track[2].isPlaying()){
track[2].pause();
}
else{
track[0].play();
}
}
class WaveformRenderer implements AudioListener
{
private float[] left;
private float[] right;
WaveformRenderer(){
left = null;
right = null;
}
synchronized void samples(float[] samp){
left = samp;
}
synchronized void samples(float[] sampL, float[] sampR){
left = sampL;
right = sampR;
}
synchronized void draw(){
beginShape();
for ( int i = 0; i < left.length; i++ ){
ellipse(i, height/2 + left[i]*80, abs(track.left.get(i))*100, abs(track.left.get(i))*100);
i+=80 ;
}
endShape();
}
}
void stop(){
track.close();
minim.stop();
super.stop();
}
How to make the sound waveform move to one direction?
[0Replies]
02-May-2012 09:29 AM
Forum:
Core Library Questions
Hi,
I'm a novice with processing
and I'm currently exploring different things I can do with processing...
Right now, my waveform in my example is static.
I want to know how I could make the waveform look as if it's 'flying' to the right side of the canvas.
Moving like a flock of birds I mean...
Is it even possible with my codes below?
What do I need to do with the code to make that effect?
Help me out!
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
Minim minim;
AudioPlayer track;
WaveformRenderer waveform;
float bpm = 50.2;
float mspb = 60000/bpm;
float x = 0;
float y = 0;
float x1 =0;
float x2 =0;
float y2 =0;
float y1 =0;
float line_height = 1;
int time = 0;
void setup()
{
size(800, 200,P3D);
background(255);
stroke(255);
strokeWeight(0);
frameRate(20);
smooth();
minim = new Minim(this);
track = minim.loadFile("rude.mp3", 2048);
track.loop();
waveform = new WaveformRenderer();
track.addListener(waveform);
}
void draw() {
int lapse = millis();
for (int i = 0; i < track.left.size()-1; i++) {
x1 = x;
x2 = x;
y1 = track.left.get(i);
y2 = track.left.get(i+1);
fill(random(255), map( abs(track.left.get(i)), 0, .2, 0, 255), 2);
noStroke();
ellipseMode(CENTER);
ellipse(x, y,abs(track.left.get(i))*10,abs(track.left.get(i))*10);
x+=abs(track.left.get(i))*20;
x+=5;
}
if (lapse > mspb || x > width ) {
// start a new line on the left
time = millis();
y += 6;
x = 0;
if (y > height){
y = 0;
background(255);
}
}
waveform.draw();
}
class WaveformRenderer implements AudioListener
{
private float[] left;
private float[] right;
WaveformRenderer(){
left = null;
right = null;
}
synchronized void samples(float[] samp){
left = samp;
}
synchronized void samples(float[] sampL, float[] sampR){
left = sampL;
right = sampR;
}
synchronized void draw(){
beginShape();
for ( int i = 0; i < left.length; i++ ){
ellipse(i, height/2 + left[i]*50, 1, 1);
ellipse(i, height/2 + left[i]*50, abs(track.left.get(i))*50, abs(track.left.get(i))*50);
i+=20;
}
endShape();
}
}
void stop(){
track.close();
minim.stop();
super.stop();
}
How should I edit the codes to make my codes respond to sound?
[3Replies]
25-Apr-2012 08:43 AM
Forum:
Core Library Questions
I already have the code here..
Right now, the particles are responding to mouseX, mouseY positions and speed.
I want the particles to respond to the music,
But I have no idea which codes to use or modify.
I am totally lost..
I was thinking something like..
The faster the beat, faster the movement of the circle..
or...the higher the wavelength's height, the more vibrant the color...
Can someone help me out?
D;
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
Minim minim;
AudioPlayer groove;
ParticleSystem ps;
void setup() {
size(700, 700);
//colorMode(RGB, 255, 255, 255, 100);
background(240);
ps = new ParticleSystem(1, new PVector(width/2,height/2,0));
smooth();
minim = new Minim(this);
groove = minim.loadFile("takuya.wav",0400);
groove.loop();
}
void draw() {
ps.run();
ps.addParticle(mouseX,mouseY);
//how can I change the framerate so that the background
//is covered less often?
frameRate(40);
fill(0,0,0,10);
ellipseMode(CENTER);
ellipse(mouseX,mouseY,20,20);
strokeWeight(2);
noStroke();
rect(0,0,700,700);
fill(255,10);
}
class Particle {
PVector loc;
PVector vel;
PVector acc;
float r;
float timer;
Particle(PVector l) {
acc = new PVector(0,0.05,0);
vel = new PVector(random(-1,5),random(-8,0),3);
loc = l.get();
r = random(3);
timer = 30.0;
}
void run() {
update();
render();
}
void update() {
vel.add(acc);
loc.sub(vel);
timer += 0.5;
}
void render() {
ellipseMode(CENTER);
stroke(255,50);
//later, I could change the colors to change according to the sound
fill(abs(mouseX-pmouseX), abs(mouseY-pmouseY), abs(mouseX-pmouseY),20);
ellipse(loc.x,loc.y,abs(mouseY-pmouseY), abs(mouseY-pmouseY));
displayVector(vel,loc.x,loc.y,5);
}
boolean dead() {
if (timer <= .01) {
return true;
}
else {
return false;
}
}
void displayVector(PVector v, float x, float y, float scayl) {
pushMatrix();
float arrowsize = random(30);
translate(x,y);
stroke(255,200);
//direction
rotate(v.heading2D());
//len means length
float len = v.mag()/scayl;
line(0,0,5,0);
popMatrix();
}
}
class ParticleSystem {
ArrayList particles;
PVector origin;
ParticleSystem(int num, PVector v) {
particles = new ArrayList();
origin = v.get();
for (int i = 0; i < num; i++) {
particles.add(new Particle(origin));
}
}
void run() {
for (int i = particles.size()-4; i >= 0; i--) {
Particle p = (Particle) particles.get(i);
p.run();
if (p.dead()) {
particles.remove(i);
}
}
}
void addParticle() {
particles.add(new Particle(origin));
}
void addParticle(float x, float y) {
particles.add(new Particle(new PVector(mouseX,mouseY)));
}
void addParticle(Particle p) {
particles.add(p);
}
boolean dead() {
if (particles.isEmpty()) {
return true;
}
else {
return false;
}
}
void stop() {
groove.close();
minim.stop();
// super.stop();
println(groove);
}
}
«Prev
Next »
Moderate user : berthalaban
Forum