Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
tom arnall - 10 Feb 2007 21:13 GMT
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(""+playbackInputStream.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

Signature

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

Andrew Thompson - 11 Feb 2007 05:05 GMT
> 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.
tom arnall - 11 Feb 2007 17:46 GMT
>> 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
[quoted text clipped - 4 lines]
> 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

Signature

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

Andrew Thompson - 11 Feb 2007 18:19 GMT
> >> 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.
tom arnall - 11 Feb 2007 22:06 GMT
>> >> I am using AudioInputStream and I find that the 'skip()' method seems
>> >> not to work. The thing 'executes' without a murmur, returning a value
[quoted text clipped - 29 lines]
>
> 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.

Signature

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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.