Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
cantona360
cantona360's Profile
3
Posts
5
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
Adding background music that autostarts with application
[0 Replies]
02-Feb-2013 07:35 AM
Forum:
Core Library Questions
I am trying to add background music that auto-starts when i run the processing sketch
i followed a simple instruction online and i added codes at line 6 , 26, 27,40,46 ,48, and from 75 to 82
but i keep getting the error "duplicate field name.player" at line 26 .
that said, can i use any mp3 file by specifying the file or does it have to be at a specific bitrate ?
here's my code ,what am i doing wrong
import processing.serial.*;
import processing.opengl.*;
import ddf.minim.*;
Serial serial;
int serialPort = 1; // << Set this to be the serial port of your Arduino - ie if you have 3 ports : COM1, COM2, COM3
// and your Arduino is on COM2 you should set this to '1' - since the array is 0 based
int sen = 3; // sensors
int div = 3; // board sub divisions
Normalize n[] = new Normalize[sen];
MomentumAverage cama[] = new MomentumAverage[sen];
MomentumAverage axyz[] = new MomentumAverage[sen];
float[] nxyz = new float[sen];
int[] ixyz = new int[sen];
float w = 256; // board size
boolean[] flip = {
false, true, false};
AudioPlayer player;
Minim minim;
int player = 0;
boolean moves[][][][];
PFont font;
PImage b;
void setup() {
size(1026, 770, P3D);
frameRate(25);
minim = new Minim(this);
// load a file, give the AudioPlayer buffers that are 1024 samples long
// player = minim.loadFile("groove.mp3");
// load a file, give the AudioPlayer buffers that are 2048 samples long
player = minim.loadFile("groove.mp3", 2048);
// play the file
player.play();
b = loadImage("data/3.jpg");
font = loadFont("TrebuchetMS-Italic-20.vlw");
textFont(font);
textMode(SCREEN);
println(Serial.list());
serial = new Serial(this, Serial.list()[serialPort], 115200);
for(int i = 0; i < sen; i++) {
n[i] = new Normalize();
cama[i] = new MomentumAverage(.01);
axyz[i] = new MomentumAverage(.15);
}
reset();
}
void draw() {
background(b);
updateSerial();
drawBoard();
}
void stop()
{
player.close();
minim.stop();
super.stop();
}
...........continues
any form of help would be much appreciated
Background image slows down sketch
[4 Replies]
02-Feb-2013 02:09 AM
Forum:
Programming Questions
Hello,
after inserting a background image ,the
sketch tends to run much more less smoother
I read somewhere that it's because your background image is loading with every frame rate but i am not sure about that
Any form of help would be much appreciated
void setup() {
size(1026, 770, P3D);
frameRate(40);
b = loadImage("data/2.jpg");
font = loadFont("TrebuchetMS-Italic-20.vlw");
textFont(font);
textMode(SCREEN);
println(Serial.list());
serial = new Serial(this, Serial.list()[serialPort], 115200);
for(int i = 0; i < sen; i++) {
n[i] = new Normalize();
cama[i] = new MomentumAverage(.01);
axyz[i] = new MomentumAverage(.15);
}
reset();
}
void draw() {
background(b);
updateSerial();
drawBoard();
}
Any form of help would be much appreciated
Adding background image to existing code
[8 Replies]
01-Feb-2013 07:21 AM
Forum:
Core Library Questions
Hello,
i am completely new to processing
can someone please help me with this code ,
I want to add a background image to it, the background image would be placed in the processing folder/data
import processing.serial.*;
import processing.opengl.*;
Serial serial;
int serialPort = 1;
int sen = 3;
int div = 3;
Normalize n[] = new Normalize[sen];
MomentumAverage cama[] = new MomentumAverage[sen];
MomentumAverage axyz[] = new MomentumAverage[sen];
float[] nxyz = new float[sen];
int[] ixyz = new int[sen];
float w = 256; // board size
boolean[] flip = {
false, true, false};
int player = 0;
boolean moves[][][][];
PFont font;
void setup() {
size(800, 600, P3D);
frameRate(25);
font = loadFont("TrebuchetMS-Italic-20.vlw");
textFont(font);
textMode(SCREEN);
println(Serial.list());
serial = new Serial(this, Serial.list()[serialPort], 115200);
for(int i = 0; i < sen; i++) {
n[i] = new Normalize();
cama[i] = new MomentumAverage(.01);
axyz[i] = new MomentumAverage(.15);
}
reset();
}
void draw() {
updateSerial();
drawBoard();
}
void updateSerial() {
String cur = serial.readStringUntil('\n');
if(cur != null) {
String[] parts = split(cur, " ");
if(parts.length == sen ) {
float[] xyz = new float[sen];
for(int i = 0; i < sen; i++)
xyz[i] = float(parts[i]);
if(mousePressed && mouseButton == LEFT)
for(int i = 0; i < sen; i++)
n[i].note(xyz[i]);
.......... the code continues
I check online for the syntax ,even though i found them i cant seem to incorporate it into the above code.
so can someone kindly modify the above code with the right parameters for adding a background image
any form of help would be much appreciated
«Prev
Next »
Moderate user : cantona360
Forum