[speex-dev] Please Help, Lost ogg sync using jspeex

sreddy sreddy at csnet.cs.odu.edu
Mon May 17 05:46:23 PDT 2004


<HTML dir=ltr><HEAD></HEAD>
<BODY>
<DIV id=idOWAReplyText8852 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2><FONT face=Arial color=#000000 size=2>Hi</FONT></DIV></DIV>
<DIV dir=ltr>
<DIV dir=ltr>
<DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I am getting lost ogg sync exception when I tried to decompress a speex stream. I am using the following program for both compressing as well as decomressing. I am just planning to test how jspeex works.</FONT></DIV>
<DIV> </DIV>
<DIV>// File AudioCapture.java</DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>import javax.sound.sampled.spi.*;import javax.sound.sampled.*;<BR>import org.xiph.speex.spi.*;<BR>import java.util.*;<BR>import java.net.*;<BR>import java.io.*;</FONT></DIV>
<DIV><FONT face=Arial size=2>public class AudioCapture{<BR> public static void main(String args[])<BR> {<BR>  int bufferlength=44100;<BR>  int framelength=1280;<BR>  int frameduration=1000;<BR>  Vector recordBuffer=new Vector();<BR>  try<BR>  {<BR>   AudioFormat audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 8000, 16, 1, 2, 8000, true);<BR>   System.out.println("AudioFormat Created");<BR>   DataLine.Info dataLineInfo = new DataLine.Info(TargetDataLine.class,audioFormat,8000);<BR>   System.out.println("Dataline.Info Created");<BR>   //DataLine.Info outputDataLineInfo = new DataLine.Info(SourceDataLine.class,audioFormat,44100);<BR>   TargetDataLine targetDataLine = (TargetDataLine) AudioSystem.getLine(dataLineInfo);<BR>   System.out.println("TargetDataLine Created");<BR>   //SourceDataLine sourceDataLine = (SourceDataLine) AudioSystem.getLine(outputDataLineInfo);<BR>   AudioInputStream auin=new AudioInputStream(targetDataLine);<BR>   PipedOutputStream pout=new PipedOutputStream();<BR>   //PipedInputStream pin=new PipedInputStream(pout);<BR>   //ServerSocket serverSocket = new ServerSocket(5555);<BR>   Pcm2SpeexAudioInputStream pcm2speex=new Pcm2SpeexAudioInputStream(auin, audioFormat, AudioSystem.NOT_SPECIFIED);<BR>   SpeexPlayer speexPlayer = new SpeexPlayer(pout);<BR>   //Speex2PcmAudioInputStream speex2pcm=new Speex2PcmAudioInputStream(pin, audioFormat,AudioSystem.NOT_SPECIFIED);<BR>   <BR>   //Socket clientSocket = serverSocket.accept();<BR>   //ObjectOutputStream toClient = new ObjectOutputStream(clientSocket.getOutputStream());<BR>   //BufferedReader fromClient = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));<BR>   targetDataLine.open(audioFormat,8000);<BR>   targetDataLine.start();<BR>   //sourceDataLine.open(audioFormat,44100);<BR>   //sourceDataLine.start();<BR>   double ratio=bufferlength/framelength;    <BR>   byte[] frame=new byte[framelength];<BR>   System.out.println("Entering While...");<BR>   System.out.println("Writing into piped output stream done...");<BR>    System.out.println("Constructing speex encoder.");<BR>       <BR>     System.out.println("Speex encoder constructed.");<BR>     System.out.println("Speex info: ");<BR>     System.out.println("Bitrate: "+pcm2speex.getEncoder().getBitRate());<BR>     System.out.println("Frame size: "+pcm2speex.getEncoder().getFrameSize());<BR>     System.out.println("Complexity: "+pcm2speex.getEncoder().getComplexity());<BR>     System.out.println("Mode: "+pcm2speex.getEncoder().getMode());<BR>     System.out.println("Sampling rate: "+pcm2speex.getEncoder().getSamplingRate());          <BR>     System.out.println("relative quality: "+pcm2speex.getEncoder().getRelativeQuality());<BR>     System.out.println("*** end of speex info");<BR>     <BR>     System.out.println("everything ok in writer");<BR>     //int count = 0;<BR>   speexPlayer.start();  <BR>   while(true)<BR>   {<BR>    /*count++;<BR>    if(count == 11)<BR>    {<BR>     System.exit(0);<BR>    }*/<BR>    frame=new byte[framelength];<BR>    //System.out.println("Reading from Audio Input Stream...");<BR>    //int n=auin.read(frame, 0, frame.length);<BR>    //System.out.println("Reading Done by Audio InputStream...");<BR>    //System.out.println("Writing into Piped Output Stream...");<BR>    //System.out.println(frame.length);<BR>    <BR>    <BR>    //int m=pcm2speex.read();<BR>    pcm2speex.read(frame);<BR>    System.out.println("Frame buffer Successfully Read");<BR>    for(int i = 0;i<framelength;i++)<BR>    {<BR>     System.out.print(frame[i]);<BR>    }<BR>    System.out.println("End of Frame Contents...");<BR>    pout.write(frame,0,framelength);<BR>    System.out.println("Wrote into Pout");<BR>    <BR>    //System.out.println("Read by Spx.."+m);<BR>    //recordBuffer.addElement(frame);<BR>    //byte[] buffer=(byte[]) recordBuffer.elementAt(0);<BR>    //toClient.write(buffer);<BR>    //toClient.flush();<BR>    //recordBuffer.removeElementAt(0); <BR>    <BR>   }<BR>   <BR>  }<BR>  catch(LineUnavailableException e)<BR>  {<BR>   System.out.println("LineUnavailableException...."+e.getMessage());<BR>  }<BR>  catch(IOException e)<BR>  {<BR>   System.out.println("IOException ....."+e.getMessage());<BR>  }<BR>    }<BR>}</FONT></DIV>
<DIV><FONT face=Arial size=2>class SpeexPlayer extends Thread{<BR> PipedOutputStream pout;<BR> PipedInputStream pin;<BR> AudioFormat audioFormat;<BR> int bufferlength;<BR> DataLine.Info outputDataLineInfo;<BR> SourceDataLine sourceDataLine;<BR> Speex2PcmAudioInputStream speex2pcm;<BR> byte[] tempBuffer;<BR> int framelength;<BR> int count;<BR> double ratio;<BR> <BR> public SpeexPlayer(PipedOutputStream pout)<BR> {<BR>  try<BR>  {<BR>   this.pout = pout;<BR>   pin = new PipedInputStream(pout);<BR>  <BR>   count = 0;<BR>   framelength = 1280;<BR>   bufferlength = 1280;<BR>   tempBuffer = new byte[bufferlength];<BR>   //ratio = bufferlength / framelength;<BR>   audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 44100, 16, 2, 4, 44100, false);<BR>   outputDataLineInfo = new DataLine.Info(SourceDataLine.class,audioFormat,44100);<BR>   sourceDataLine = (SourceDataLine) AudioSystem.getLine(outputDataLineInfo);<BR>   speex2pcm=new Speex2PcmAudioInputStream(pin, audioFormat,AudioSystem.NOT_SPECIFIED);<BR>   sourceDataLine.open(audioFormat);<BR>   sourceDataLine.start();<BR>  }<BR>  catch(IOException e)<BR>  {<BR>   System.out.println("Exception raised in SpeexPlayer..."+e.getMessage());<BR>  }<BR>  catch(LineUnavailableException e)<BR>  {<BR>   System.out.println("Exception raised in SpeexPlayer..."+e.getMessage());<BR>  }<BR> }<BR> <BR> public void run()<BR> {<BR>  while(true)<BR>  {<BR>   count++;<BR>   try<BR>   {<BR>    speex2pcm.read(tempBuffer);<BR>    System.out.println("Successfully decoded..."+count);<BR>    <BR>    <BR>    <BR>   }<BR>   catch(IOException e)<BR>   {<BR>    System.out.println("Exception raised in thread of SpeexPlayer..."+e.getMessage());<BR>    System.out.println("Count is...."+count);<BR>   }<BR>   //try<BR>   //{<BR>    sourceDataLine.write(tempBuffer,0,framelength);<BR>    tempBuffer = new byte[bufferlength];<BR>    /*try<BR>    {<BR>     sleep(5000);<BR>    }<BR>    catch(InterruptedException e)<BR>    {<BR>    }*/<BR>   /*}<BR>   catch(IOException e)<BR>   {<BR>    System.out.println("Exception raised in thread of SpeexPlayer..."+e.getMessage());<BR>   }*/<BR>  }<BR>  <BR> }<BR>}      </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Any kind of help would be very great</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks in advance...</FONT></DIV>
<DIV><FONT face=Arial size=2>S Reddy</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></FONT></DIV></DIV></DIV></BODY>
--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'speex-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Speex-dev mailing list