I'm working on a sequencer based on a 2D cellular automata in processing which uses max msp for audio playback. I've set the processing code up so that it should send a message to max each time a cell on the CA is on. How ever I only get a message in max from "/pt1" in processing. If some one could have a look at my code and point me in the right direction I would be very grateful.
import peasy.*;
import toxi.geom.*;
import oscP5.*;
import netP5.*;
//PeasyCam cam;
OscP5 oscP5 = new OscP5(this, 7474);
NetAddress myRemoteLocation = new NetAddress("127.0.0.1", 7475);
I'm trying to change the color of a box on screen when a circle at mousex and mousey passes over it. my code runs but doesn't work. can anyone see where I'm going wrong?
boolean isTouching = false;
int blobRad = 80;
color col;
sonicBlock[] sonicBlocks = new sonicBlock[0];
Blob blob = new Blob();
int count = 100;
int numSamples = 0;
int grab = -1;
float time =0.0;
void setup() {
size(900, 600);
smooth();
float x = 30;
while (x < width) {
float y = 30;
while (y < height) {
makeNewsonicBlock(x, y, 25);
y = y + 60;
}
x = x + 60;
}
}
void draw() {
background(74, 147, 177);
if (mousePressed == true) {
selectsonicBlock();
if (grab>=0) {
sonicBlocks[grab].mouseMove();
//sonicBlocks[grab].ring();
}
}
for (int i = 0; i < count; i = i+1) {
sonicBlocks[i].display();
sonicBlocks[i].drag(.90);
//sonicBlocks[i].changeColor();
}
time+=.02;
blob.display();
if (isTouching = true){
col = color(31,52,75);
}
else{
col = color(44,149,171);
}
}
void mousePressed() {
}
void mouseReleased() {
grab = -1;
}
void selectsonicBlock() {
for (int i = 0; i < sonicBlocks.length; i ++) {
if (dist(sonicBlocks[i].posX, sonicBlocks[i].posY, mouseX, mouseY) < sonicBlocks[i].rad/2 ) {
grab = sonicBlocks[i].ID;
}
}
}
void touching(){
for (int i = 0; i < sonicBlocks.length; i ++){
if (dist(sonicBlocks[i].posX, sonicBlocks[i].posY, mouseX, mouseY) < blobRad + sonicBlocks[i].rad){
isTouching = true;
}
}
}
void makeNewsonicBlock(float x, float y, float rad) {
sonicBlock newsonicBlock = new sonicBlock(sonicBlocks.length, x, y, rad);
I'm writing a program that triggers a different sound every time a box on screen is clicked. I've managed to load the sounds into an array and draw a box to the screen for each sound in the array. Does anyone one know how I might assign an individual sound to each box so that when the box is clicked a sound is played? The boxes can be dragged around the screen, so the sound must play no matter where on screen the box is located.
import java.io.File;
import beads.*;
// Beads variables
AudioContext ac;
int numSamples = 0;
int sampleWith = 0;
String [] sourceFile;
Gain [] gain;
Glide [] gainAmt;
SamplePlayer [] samplePlayer;
// Interface variables
SonicB [] sonicB = new SonicB[0];
int grab = -1;
float time = 0;
int blobRad = 60;
Blob blob = new Blob();
void setup (){
size(800, 600);
smooth();
float x = 30;
while(x < width){
float y = 30;
while (y < height){
makeSonicB(x, y, 20);
y = y + 60;
}
x = x + 60;
}
ac = new AudioContext();
File folder = new File(sketchPath("") + "samples");
File [] fileList = folder.listFiles();
for (int i = 0; i < fileList.length; i ++) {
if (fileList[i].isFile()) {
if (fileList[i].getName().endsWith(".wav")) {
numSamples ++;
}
}
}
if (numSamples <= 0) {
println("No samples found in " + sketchPath("") + "samples/");