Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > AudioInputStream -- 'skip()' method seems not to work

Reply
Thread Tools

AudioInputStream -- 'skip()' method seems not to work

 
 
tom arnall
Guest
Posts: n/a
 
      02-10-2007
I am using AudioInputStream and I find that the 'skip()' method seems not to
work. The thing 'executes' without a murmur, returning a value as if doing
the skip, but in fact nothing gets skipped. Code is:

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.Line2D;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.util.Vector;
import java.util.Enumeration;
import java.io.*;
import javax.sound.sampled.*;
import java.awt.font.*;
import java.text.*;

..
..
..
..

AudioFormat format = getFormat();
AudioInputStream playbackInputStream =
AudioSystem.getAudioInputStream(format, audioInputStream);

DataLine.Info info = new DataLine.Info(SourceDataLine.class,
format);
if (!AudioSystem.isLineSupported(info)) {
System.out.println("Line matching " + info + " not supported.");
return;
}

try {
line = (SourceDataLine) AudioSystem.getLine(info);
line.open(format, bufSize);
}

catch (LineUnavailableException ex) {
System.out.println("Unable to open the line: " + ex);
return;
}

int frameSizeInBytes = format.getFrameSize();
int bufferLengthInFrames = line.getBufferSize() / 8;
int bufferLengthInBytes = bufferLengthInFrames * frameSizeInBytes;
byte[] data = new byte[bufferLengthInBytes];
int numBytesRead = 0;

// start the source data line
line.start();

int j = 0;
try {
!!!!!!HERE IS
SKIP!!!!!!!!System.out.println(""+playbackInputStr eam.skip(1000));
}
catch (Exception e) {
System.out.println(e);
}
while (j<1000) {
j++;
try {

if ((numBytesRead = playbackInputStream.read(data)) == -1) {
break;
}
int numBytesRemaining = numBytesRead;
while (numBytesRemaining > 0 ) {
numBytesRemaining -= line.write(data, 0, numBytesRemaining);
}
} catch (Exception e) {
System.out.println("Error during playback: " + e);
break;
}
}

thanks,

tom arnall
north spit, ca


--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      02-11-2007
On Feb 11, 8:13 am, tom arnall <kloro2...@gmail.com> wrote:
> I am using AudioInputStream and I find that the 'skip()' method seems not to
> work. The thing 'executes' without a murmur, returning a value as if doing
> the skip, but in fact nothing gets skipped.


...and what?

Without compilable code, or a question, I
cannot see this thread going very well.

Andrew T.

 
Reply With Quote
 
 
 
 
tom arnall
Guest
Posts: n/a
 
      02-11-2007
Andrew Thompson wrote:

> On Feb 11, 8:13 am, tom arnall <kloro2...@gmail.com> wrote:
>> I am using AudioInputStream and I find that the 'skip()' method seems not
>> to work. The thing 'executes' without a murmur, returning a value as if
>> doing the skip, but in fact nothing gets skipped.

>
> ..and what?
>
> Without compilable code, or a question, I
> cannot see this thread going very well.
>


how about, 'why's it f'g up?'. anyway forget the post -- i found the
problem. i was not feeding a big enough number to the skip() method to make
its effect apparent. good point about the compilable code.

tom arnall
north spit, ca
usa

--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      02-11-2007
On Feb 12, 4:46 am, tom arnall <kloro2...@gmail.com> wrote:
> Andrew Thompson wrote:
> > On Feb 11, 8:13 am, tom arnall <kloro2...@gmail.com> wrote:
> >> I am using AudioInputStream and I find that the 'skip()' method seems not
> >> to work. The thing 'executes' without a murmur, returning a value as if
> >> doing the skip, but in fact nothing gets skipped.

...
> > Without compilable code, or a question, I
> > cannot see this thread going very well.

>
> how about, 'why's it f'g up?'.


Now that's more like it! But
avoiding swearwords, or swearword
abbreviations, is generally a good
idea for this technical group.

( Except when talking to multi-posting
spammers, then all bets are off!

>..anyway forget the post -- i found the
> problem. i was not feeding a big enough number to the skip() method to make
> its effect apparent.


Glad you sorted it.

>..good point about the compilable code.


If looking to post code for any future
problem, I recommend* you have a look
over the article on the SSCCE first.
<http://www.physci.org/codes/sscce>

* Not that surprising, given I wrote it.

Andrew T.

 
Reply With Quote
 
tom arnall
Guest
Posts: n/a
 
      02-11-2007
Andrew Thompson wrote:

> On Feb 12, 4:46 am, tom arnall <kloro2...@gmail.com> wrote:
>> Andrew Thompson wrote:
>> > On Feb 11, 8:13 am, tom arnall <kloro2...@gmail.com> wrote:
>> >> I am using AudioInputStream and I find that the 'skip()' method seems
>> >> not to work. The thing 'executes' without a murmur, returning a value
>> >> as if doing the skip, but in fact nothing gets skipped.

> ..
>> > Without compilable code, or a question, I
>> > cannot see this thread going very well.

>>
>> how about, 'why's it f'g up?'.

>
> Now that's more like it! But
> avoiding swearwords, or swearword
> abbreviations, is generally a good
> idea for this technical group.
>
> ( Except when talking to multi-posting
> spammers, then all bets are off!
>
>>..anyway forget the post -- i found the
>> problem. i was not feeding a big enough number to the skip() method to
>> make its effect apparent.

>
> Glad you sorted it.
>
>>..good point about the compilable code.

>
> If looking to post code for any future
> problem, I recommend* you have a look
> over the article on the SSCCE first.
> <http://www.physci.org/codes/sscce>
>
> * Not that surprising, given I wrote it.
>
> Andrew T.


great stuff, the ssccee piece. i actually do this usually and more often
than not find that the preparation of the example makes the solution
obvious. totally forgot myself with the skip() thing.



--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping AudioInputStream of music Ed Chen Java 1 05-27-2004 09:04 AM
Responise.Write() seems not to work in codebind. Wootaek Choi ASP .Net 1 02-10-2004 04:45 AM
synchronize seems not work lonelyplanet999 Java 6 11-16-2003 02:01 PM
AudioInputStream byte data persistence Mosiuoa Tsietsi Java 0 09-15-2003 11:00 AM
Expiration date seems not to work Frederic Gignac ASP .Net 2 07-08-2003 01:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57