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 & HelpSound,  Music Libraries › minim controlling 6 or more sounds...
Page Index Toggle Pages: 1
minim controlling 6 or more sounds... (Read 735 times)
minim controlling 6 or more sounds...
Dec 18th, 2007, 7:55pm
 
Hi, I'm quite a newbie with Processing, I'm trying to design a simple quiz, where people can click on boxes that will playback audio. So far I've been able to get Processing to display all the graphics and to playback one audio file when I click on a box. Since I've tried to use more audio files I've been getting a lot of problems, namely:

=== Minim Error ===
=== IOException: Stream Closed.

As far as I can tell the problem is somewhere in this class:

class ImagesSounds1 extends Dimensions {
 PImage p;
 PImage q;
 float b;

 ImagesSounds1(String picFile, float x, float y, float w, float h, String pickSound, float buf) {
   p = loadImage(picFile);
   q = loadImage("funnymusicnote.jpg");
   x1 = x;
   y1 = y;
   x2 = w;
   y2 = h;
   soundfile = Minim.loadFile(pickSound);
   b = buf;

 }

 void drawInst() {
   if (checkHover() && (mousePressed == true)) {
     image(q, x1, y1, x2, y2);
     soundfile.play();
     soundfile.loop();
   }
   else {
     image(p, x1, y1, x2, y2);
     soundfile.pause();
   }
 }
}

Can anyone help me resolve this? I can post the rest of the code if you need me to.
Re: minim controlling 6 or more sounds...
Reply #1 - Dec 18th, 2007, 10:20pm
 
Hey there,

I believe you get that error when Processing can't load the sound or that there is a problem with the AudioPlayer variable.
From what I see in your code, you didn't define an AudioPlayer.

Try adding: AudioPlayer soundfile; in your variable declaration. (right after float b;)

Cheers
Re: minim controlling 6 or more sounds...
Reply #2 - Dec 19th, 2007, 12:31am
 
@ steven, he would get NPE's then.

I'm assuming you mistyped a file-path to the file you want to play, (which results in no thrown exception, but when you try to play the file you get "Stream Closed")

so:

Before
Code:

soundfile = Minim.loadFile(pickSound);


add:

Code:

System.out.println(pickSound);


and then copy and paste the consol output into an explorer window and verify that you get a file.

(if you still have problem, it's quite possible the soundcard just can't handle so many lines at once the way minim uses it: soundcards can be pretty crappy sometimes>)
Re: minim controlling 6 or more sounds...
Reply #3 - Dec 19th, 2007, 4:35pm
 
Ok, cheers so far. The println adds this to the console:




balalaika.mp3

bodrhan.mp3

=== Minim Error ===

=== IOException: Stream closed



didgeridoo.mp3

shamisen.mp3

sitar.mp3

spanish guitar.mp3

=== Minim Error ===

=== IOException: Stream closed




And then, all this...





java.lang.NullPointerException

at Temporary_1125_8722$ImagesSounds1.drawInst(Temporary_1125_8722.java:157)

at Temporary_1125_8722.draw(Temporary_1125_8722.java:50)

at processing.core.PApplet.handleDisplay(PApplet.java:1444)

at processing.core.PGraphics.requestDisplay(PGraphics.java:680)

at processing.core.PApplet.run(PApplet.java:1539)

at java.lang.Thread.run(Unknown Source)

java.lang.NullPointerException


at Temporary_1125_8722$ImagesSounds1.drawInst(Temporary_1125_8722.java:157)


at Temporary_1125_8722.draw(Temporary_1125_8722.java:50)


at processing.core.PApplet.handleDisplay(PApplet.java:1444)


at processing.core.PGraphics.requestDisplay(PGraphics.java:680)


at processing.core.PApplet.run(PApplet.java:1539)


at java.lang.Thread.run(Unknown Source)


java.lang.NullPointerException

at Temporary_1125_8722.stop(Temporary_1125_8722.java:60)

at processing.core.PApplet.run(PApplet.java:1641)

at java.lang.Thread.run(Unknown Source)
Re: minim controlling 6 or more sounds...
Reply #4 - Dec 22nd, 2007, 12:16am
 
well, that's it then. Why didn't you say you're getting a "NullPointerException"? That's an important programming concept.

But, your problem is simply that "balalaika.mp3" is not enough for minim to find your audio! You need a full system path!

I.E.

C:\\Documents and Settings\\My Music\\Java Music\\balalaika.mp3

^ so, write your program accordingly.

BTW, the nullpointer is because when you call "loadFile", if it can't find the file it's looking for, it returns null. Therefore, when you later call "Play", you're calling a method on null: null can never do anything!
Page Index Toggle Pages: 1