Hi all,
I'm trying to get my audio player working as a library and I'm running into a fairly weird problem. I'll be as concise as I can to begin with, then elaborate if necessary...
My player is a Processing sketch in Eclipse which uses a bunch of pure Java classes to play the audio. Player.java uses javax.sound.sampled and has a while loop which does output_line.write(output_buffer,etc) to the output line for the duration of the piece of music. This works fine.
Having libraryised my code, so that I can successfully instantiate it and run it as a Processing applet (in both Eclipse and the Proc IDE), the weirdest thing happens: everything seems fine, the music files load properly, my debugging printlns are all cool...but the music doesn't play. More specifically, the aforementioned while loop only calls the buffer preparation function once, then fails to fill the buffer or advance the sample frame count.
This is all done in a 'public class Driver implements Runnable', so I felt that I wouldn't have to run my own timing mechanism through communication between my library and the end-user's sketch, since this should be running happily in its own thread (as it does normally, when not as a library!).
Can anyone think of anything glaringly obvious that I've forgotten, or simply not considered (as I'm not very experienced - still an enthusiastic beginner!)?
My buffer is being initialised properly, and there are NO errors at any point. Printing the buffer gives 0s, no null exceptions, but only once and then this Runnable thread seems to stop dead. I've done try/catches in various places, and I'm fairly sure there isn't anything I'm failing to catch. A friend mentioned mutex/sleeping/etc, but couldn't imagine why my code would work in a regular applet but not as a lib.
Any help would be gratefully appreciated, including help on how better to express my problem - I'm sure I've mangled some terminology already
Cheers,
/brendan