We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Please Help I don't no why its not working
Page Index Toggle Pages: 1
Please Help I don't no why its not working (Read 440 times)
Please Help I don't no why its not working
Mar 10th, 2006, 5:16pm
 
Hi again

well i fixed the last problem but no i dont no why it wont play the sound.

Here is the code if any one could help that would be brill.

Cheers

XxX

import pitaru.sonia_v2_9.*;

public Sample mySample;
public Sample mySample2;
public int tStamp = -1;
public int tStamp2;
public int count;
public int canFlip=1;
public int canStart=1;
public String mode ="";

float[] tempBuffer;
float[] tempBuffer2;

int sampleLength = 60;  
int sampleRate = 44100;  
int numFrames = sampleRate*sampleLength;


void setup(){
size (640,480);
Sonia.start(this);
LiveInput.start();
tStamp=minute();
tStamp2=minute();
mySample = new Sample (numFrames);
mySample2 = new Sample (numFrames);

tempBuffer = new float [numFrames];
tempBuffer2 = new float [numFrames];
 
}



void draw(){

float meterData = LiveInput.getLevel(0);
//println("hello"+meterData);

//meterData>0.07812835
//if(random(3)<1){
//println(minute()+" "+(tStamp));
//}
if(meterData>0.07812835 && ((minute()<tStamp+5)||tStamp==-1)){
 if(canStart==1){
   canStart=0;
 println("Door Bell Ringing");
 startRecording();
 tStamp=minute();
 }
 }  
 if(minute()>=tStamp2+5 && mode.equals("recording")){
flippingSound();
mode="";
 }
}

void startRecording(){
 mode="recording";
 tStamp2=minute();
println("recording");
LiveInput.startRec(mySample);
}

void flippingSound(){
 if (canFlip ==1){
   canFlip = 0;
 println("flipping");
 mySample.write(tempBuffer);
   
   for(int i=0; i<tempBuffer.length; i++){
     //flip round the sound
     tempBuffer2[i]=(tempBuffer.length-i);
   }
   mySample2.read(tempBuffer2);
   println("playing");
   mySample2.play();
 }
 }
Page Index Toggle Pages: 1