[speex-dev] q about jspeex

Marc Gimpel marc at wimba.com
Fri Oct 31 04:49:12 PST 2003



    Hi,

    It would appear the the 'pcm2speex.read(frame, 0, frame.length)' is 
blocking which means that it is waiting for data from the underlying 
inputstream (i.e.AudioInputStream(t.input)). If it could read sufficient 
data it would transcode it. If it recieved an EOF, it should do some 
zero padding and then transcode it. Are you sure that you are receiving 
data from the underlying inputstream???
    One point to note though is that is you are receiving 44kHz audio, 
it will try to encode this as UWB (i.e. pretending it's 32kHz sampling 
rate), which means that to encode 1 speex packet you are going to need 
640 samples, or 1280 bytes (which should compress down to something like 
29 bytes because the quality setting should be 3 by default).
    Having said this, jspeex does provide an SPI interface so you should 
be able to ask JavaSound to give you directly a a Speex 
AudioInputStream. It's coded although I admit that I never got round to 
testing it so it might not work. It does work for the decoding, that I'm 
sure of in any case.

    Marc Gimpel
    Head of research
    Wimba

Ulrich B. Staudinger wrote:

> Ulrich B. Staudinger wrote:
>
>> Hi,
>>
>> i have:
>>
>>    public void run(){
>>              try{
>>                System.out.println("Opening 
>> mic");                                    //                
>> AudioInput ai=new AudioInput(t);
>> //                ai.start();
>>                if(t.input==null){
>>                    AudioFormat    format = new 
>> AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 44100, 16, 2, 4, 44100, 
>> false);
>>                    DataLine.Info    targetInfo = new 
>> DataLine.Info(TargetDataLine.class, format, 44100);
>>                                  t.input = (TargetDataLine) 
>> AudioSystem.getLine(targetInfo);
>>                                                      
>> t.input.open(format,44100);
>>                    System.out.println(" Mic opened");
>>
>>                    t.input.start();
>>                    System.out.println("Constructing speex encoder.");
>>                    pcm2speex=new Pcm2SpeexAudioInputStream(new 
>> AudioInputStream(t.input), format, AudioSystem.NOT_SPECIFIED);       
>>                    System.out.println("Speex encoder constructed.");
>>                    System.out.println("*** Speex info: ");
>>                    System.out.println("Bitrate: 
>> "+pcm2speex.getEncoder().getBitRate());
>>                    System.out.println("Frame size: 
>> "+pcm2speex.getEncoder().getFrameSize());
>>                    System.out.println("Complexity: 
>> "+pcm2speex.getEncoder().getComplexity());
>>                    System.out.println("Mode: 
>> "+pcm2speex.getEncoder().getMode());
>>                    System.out.println("Sampling rate: 
>> "+pcm2speex.getEncoder().getSamplingRate());                         
>> System.out.println("relative quality: 
>> "+pcm2speex.getEncoder().getRelativeQuality());
>>                    System.out.println("*** end of speex info");      
>>                    System.out.println("everything ok in writer");
>>                }                             byte[] frame=new 
>> byte[t.framelength];                   while(true){
>>                        int n=pcm2speex.read(frame, 0, frame.length);
>>                        System.out.println(""+n+" bytes read.");
>>                        
>> t.recordBuffer.addElement(frame);                
>>                                                  }
>>            }
>>            catch(Exception e){
>>                e.printStackTrace();
>>            }
>>                    }
>>
>> now all this code does, is sitting and doing nothing after 
>> 'everything ok in writer' - it simply doesn't read any data, at least 
>> that's what it looks like, or am i using the class in a wrong 
>> context? t.framelength is 160 at the moment.
>
>
> not specific enough - i mean Pcm2SpeexAudioInputStream with 'the class'
>
>
> --- >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.
>
>

--- >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