However, my game seems to be crashing whenever I try to play the video. I've upgraded my memory on the preferences tab, however it does not really work when I upgrade it to 4GB(i'm using a system with 4gb of ram). So i updated its max memory to 1gb.
Any ideas why the game is crashing? Is there a particular file type or size I should be sticking to?
Im trying to create a program using processing and reactivision and i was wondering if anyone could help.
Basically the first step of the program is to display an image, (which i know how to do) and then i would like to play a sound when i show a fiducial symbol to the web camera (and i have code to that program too.)
What i don't know how to do is to make the pc only display the image until the user presses enter and then go to the program which recognises fiducial symbols and play a sound.
The Code i have is the following :
//This is the code which displays the image :
size(600,600);
PImage b;
b = loadImage("question1.jpg");
image(b, 0, 0);
//This is the code which recognises fiducial symbols and play a sound :
/**
* Sound1.pde
Shows how we can play sounds from within a processing sketch. Some AudioSamples are played using the trigger method.
Whether or not a soundplays is governed by the presence of a corresponding reactivision symbol.
The the frequency with which the sample repears is determined by the angle of the symbol.
Possible extensions:
Use the position of the reactivision symbol to control the volume of the corresponding sound.
*/
import ddf.minim.*;
import TUIO.*;
TuioProcessing tuioClient;
// Map to relate symbol IDs to the sounds they're associated with
HashMap symbolMap = new HashMap();
Minim minim;
PlayThing bd, bass, cym, snare;
class PlayThing{
AudioSample samp;
float period;
float lastTime=0;
boolean playing=false;
PlayThing(AudioSample s, float p){
samp=s;
period=p;
}
void play(){
if(playing){
// check whether it's time to play this sound
float now = millis();
if (now-lastTime>= period){
lastTime=now;
samp.trigger();
}
}
}
}
void setup()
{
size(512, 200, P3D);
minim = new Minim(this);
bd = new PlayThing(minim.loadSample("bdhh.aiff"), 1000);
snare = new PlayThing(minim.loadSample("snare.aiff"), 2000);
bass = new PlayThing(minim.loadSample("bass.aiff"), 1000);
cym = new PlayThing(minim.loadSample("cym.aiff"), 2000);
symbolMap.put(0, bd);
symbolMap.put(1, snare);
symbolMap.put(2, bass);
symbolMap.put(3, cym);
tuioClient = new TuioProcessing(this);
}
void draw()
{
background(0);
stroke(255);
bd.play();
snare.play();
bass.play();
cym.play();
}
void stop()
{
// always close Minim audio classes when you are done with them
bd.samp.close();
snare.samp.close();
cym.samp.close();
bass.samp.close();
minim.stop();
super.stop();
}
// these callback methods are called whenever a TUIO event occurs
// called when an object is added to the scene
void addTuioObject(TuioObject tobj) {
int id = tobj.getSymbolID();
if (symbolMap.containsKey(id)){
// start the plaything playing!
((PlayThing)(symbolMap.get(id))).playing=true;
}
}
// called when an object is removed from the scene
I'm completely new to processing and I've got a project due in 5 weeks time so, i'm kinda panicking.
I grasped a few basic concepts of processing and have some access to some source code. But at the moment I'm stuck with trying to make a gui. My problem at the moment is that I don't know how to create buttons and link them to a particular page (i'm creating a basic game for 3 - 5 year olds - nothing complicated).
If anyone could kindly shed some light i'd be most appreciative!!