java - Methods of custom-implementation of TargetDataLine aren't invoked -


i tried work javax.sound.sampled-package.

i tried implementing own version of targetdataline (for test purposes @ point). dismay, however, when done , tried "play" it, neither 1 of it's methods invoked (nor exceptions raised), instead, program froze.

the code segment in question looks this:

try {   // create stream.   assembleddataline line = new assembleddataline();   audioinputstream stream = new audioinputstream(line);    // create content.   int size = 65536;   byte[] array = new byte[size];   byte inc = 1;   byte pos = (byte) 0;   (int = 0; < size; ++i) {     array[i] = (pos += inc);     if (pos == 127) {       inc = -1;     } else if (pos == -128) {       inc = 1;     }   }   line.writearray(array);    // play.   system.out.println("starting play.");   clip clip = audiosystem.getclip();   clip.loop(clip.loop_continuously);   system.out.println("got clip");   clip.open(stream);   system.out.println("opened");   clip.start();   thread.sleep(5000);   system.out.println("started");   clip.close();   system.out.println("end."); } catch (exception e) {   e.printstacktrace();   system.out.println("error"); } 

the above mentioned code never reach "opened" statement, or throw exception. tried inserting printout every single method implemented in assembleddataline, neither of them ever invoked (with exception of writearray, called before opening stream).

so @ point think clip.open(stream) method freezes before reaching point of gaining input stream.

i tried open file same way , worked, figure related way instantiate audioinputstream.

the answer was, clip, whilst not directly invoking method of assembleddataline, ask wrapping audioinputstream format being used. therein mistake. had swapped values frame_rate , frame_size when creating audio-format. meant audio-format invalid , clip freeze on allocating enough memory play input data.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -