Re : please help with serial and point
serial.list() limitations on mac?
All MIDI Devices Unavailable?
I hope I've picked the right location for this post.
I am a beginner with processing and with Java in general. I'm trying to figure out how to simply construct a midi note on message and send it to an internal midi port application, that can then route it to a software synthesizer.
I'm using javax.sound.midi for this, and processing 2.0b6.
This is some code I have written to check what devices exist:
However, every single one of those devices, if it is not in the try, catch block that discards MidiUnavailableException, will throw just that exception. Yet none of my devices should be in use for anything, so I'm not sure why all of them throw this error. Any thoughts?
How to log sensor arduino data into a file.
import processing.serial.*;
Serial mySerial;
PrintWriter output;
void setup() {
mySerial = new Serial( this, Serial.list()[0], 9600 );
output = createWriter( "timedg.csv" );
}
void draw() {
if (mySerial.available() > 0 ) {
String value = mySerial.readString();
if ( value != null ) {
output.println( value );
}
}
}
Re : Split only returning first index
Re : How to log sensor arduino data into a file.
Re : PImage Memory Leak Example
http://code.google.com/p/processing/issues/detail?can=2&start=0&num=100&q=PIMage&colspec=Stars%20ID%20Type%20Status%20Priority%20Owner%20Summary&groupby=&sort=&id=1353
-- Paul
----- |(*,+,#,=)(#,=,*,+)(=,#,+,*)(+,*,=,#)| ---
Re : How to log sensor arduino data into a file.
import processing.serial.*;
Serial mySerial;
PrintWriter output;
void setup() {
mySerial = new Serial( this, Serial.list()[0], 9600 );
output = createWriter( "newp.txt" );
//print(Serial.list());
}
void draw() {
if (mySerial.available() > 0 ) {
String value = mySerial.readString();
if ( value != null ) {
output.println( value );
output.close();
}
}
}
Scaling text
Re : Scaling text
I'd thought that
- textAlign(CENTER,CENTER);
You can use textwidth and textheight (does it exist??) and say
- text("a", width/2 - textwidth ("a") / 2 , height/2 - textheight ("a") / 2 );
(not tested)
textwidth and textheight (does it exist??) should know the current size of your "a"
Re : Scaling text
textAscent(). http://processing.org/reference/textAscent_.html
Here is my suggestion to start fixing this:
- void draw(){
- calculateFFT();
- background(0);
- smooth(8);
- textFont(Header, Channel[4]);
- fill(255);
- textAlign(CENTER,CENTER);
- float yStartPos = calculateAscent(Channel[4]);
- text("H", (width/2), yStartPos);
- }
- float calculateAscent(float value) {
- float base = height / 2;
- float scalar = 0.1; // Different for each font, change this until you get the result you want
- float a = textAscent() * scalar; // Calc ascent
- stroke(100); // for the reference line
- line(0,base-a,width,base-a); // ref purposes
- return base-a;
- }
Re : Scaling text
Re : PImage Memory Leak Example
Re : How to log sensor arduino data into a file.
PVector functions and CPU vector processing? (SSE functions)
using timer
Re : using timer
Re : using timer
Movie movie;
PImage helpimg;
PImage baseimg;
Timer time;
//int time1 = 3000;
int time2 = 4000;
float a = 0;
void setup() {
size(1000, 600);
background(0);
movie = new Movie(this, "intro.mov");
movie.play();
}
void draw() {
background(0);
image(movie, 0, 0);
int currentTimer = millis();
if (currentTimer < time2)
{
helpimg = loadImage("help.png");
}
}
void movieEvent(Movie m)
{
m.read();
}
video input with elements
I am trying to create a sort of photoBooth In Processing
Here are the Files for everything in my program:
Main
Button
Background Picture
-
import processing.video.*;//opens up processing libraries
int s;// saved time
int t = 5000;// 5 seconds
//class
Capture video;//class for cideo
Button[] button = new Button[4];//class will be called button
PImage img;//class img
boolean state; // keyPressed
//===================================
void setup() {
size(1500, 1098);
background(0);
img = loadImage("Octoton Background Big.jpg"); //image file name
frameRate(30);
imageMode(CENTER);
//Inititialize class
for (int i = 0; i< button.length; i++) {
button[i] = new Button(250+(i*75), 250);
}
button[0].setColor(0, 255, 0);//green
button[1].setColor(0, 0, 255);//blue
button[2].setColor(255, 255, 0);//yellow
button[3].setColor(142, 56, 142);//purple
video = new Capture (this, 640, 480, 30);//(video, width, height, frameRate)
video.start();
s = millis(); //sets s to millis
ellipseMode(CENTER);
}
//======================END SETUP===================
void draw () {
if (keyPressed) {
if (keyCode == UP) {
image(img, width/2, height/2);// background drawn
//for (int i = 0; i< button.length; i++) {
button[0].display(true);
state = true;
}
}
else {
image(img, width/2, height/2); // background drawn
//for (int i = 0; i< button.length; i++) {
button[0].display(false);//button deafault displayed
}
if (video.available()) {// if there is something to see it will be available
video.read();// read what is available
}
image(video, width/2, height/2+100);
if (keyPressed) {
if (keyCode == DOWN) {
image(img, width/2, height/2);// background drawn
//for (int i = 0; i< button.length; i++) {
button[1].display(true);
state = true;
}
}
else {
image(img, width/2, height/2); // background drawn
//for (int i = 0; i< button.length; i++) {
button[1].display(false);//button deafault displayed
}
if (video.available()) {// if there is something to see it will be available
video.read();// read what is available
}
image(video, width/2, height/2+100);
if (keyPressed) {
if (keyCode == LEFT) {
image(img, width/2, height/2);// background drawn
//for (int i = 0; i< button.length; i++) {
button[2].display(true);
state = true;
}
}
else {
image(img, width/2, height/2); // background drawn
//for (int i = 0; i< button.length; i++) {
button[2].display(false);//button deafault displayed
}
if (video.available()) {// if there is something to see it will be available
video.read();// read what is available
}
image(video, width/2, height/2+100);
if (keyPressed) {
if (keyCode == RIGHT) {
image(img, width/2, height/2);// background drawn
//for (int i = 0; i< button.length; i++) {
button[3].display(true);
state = true;
}
}
else {
image(img, width/2, height/2); // background drawn
//for (int i = 0; i< button.length; i++) {
button[3].display(false);//button deafault displayed
}
if (video.available()) {// if there is something to see it will be available
video.read();// read what is available
}
image(video, width/2, height/2+100);
}
//=======================CLASS=================
class Button {
color col; // color variable
int x;
int y;
Button(int tempX, int tempY) { // constructor
x = tempX;
y = tempY;
}
void display(boolean tempState) {
fill(155);//gray
ellipse(x, 258, 60, 30); // Base of button
if (tempState == true) {
Pressed();
}
else {
notPressed();
}
}
//=======================notPressed=================
void notPressed () {
//Button Default
fill(col);//color set
ellipse(x, 254, 50, 20);
ellipse(x, 253, 50, 20);
ellipse(x, 252, 50, 20);
ellipse(x, 251, 50, 20);
ellipse(x, 250, 50, 20);
ellipse(x, 249, 50, 20);
ellipse(x, 248, 50, 20);
ellipse(x, 247, 50, 20);
ellipse(x, 246, 50, 20);
ellipse(x, 245, 50, 20);
}
//=======================Pressed=================
void Pressed() {
// Button Pressed
fill(col);//color set
ellipse(x, 254, 50, 20);
ellipse(x, 253, 50, 20);
ellipse(x, 252, 50, 20);
ellipse(x, 251, 50, 20);
ellipse(x, 250, 50, 20);
}
//=======================setColor=================
void setColor(int tempR, int tempG, int tempB) {
col = color(tempR, tempG, tempB);
}
}