SV: [speex-dev] C++ wrapper for speex
Jonas Tärnström
njt at home.se
Wed May 26 11:48:23 PDT 2004
Hi,
Think I might have found a problem.
AFAIK, lpHdr->dwBufferLength stores the length of the buffer in octets
(bytes).
It should be 320 if you are expecting 160 PCM 16-bit samples.
//JT
<p>> -----Ursprungligt meddelande-----
> Från: owner-speex-dev at xiph.org [mailto:owner-speex-dev at xiph.org] För
> Ronald Madrid
> Skickat: den 26 maj 2004 12:39
> Till: speex-dev at xiph.org
> Kopia: tgrand at canvaslink.com
> Ämne: Re: [speex-dev] C++ wrapper for speex
>
>
> hi Tom,
>
> i downloaded your speex wrappers and they're really
> what i'm looking for! i really cannot worry about
> container support at the moment because i'm working
> with real-time audio, and hopefully toward VoIP when
> everything else is in order.
>
> im using waveform to capture data from the microphone.
> the raw PCM sample is stored in the WAVEHDR
> structure's member lpData, and this variable is of
> LPSTR type.
>
> if you have the time, can you please check on my test
> code below and see where i could be having problems
> with. (this is the handler that processes captured
> audio)
>
> LRESULT CRecordSound::OnSoundData(WPARAM wParam,
> LPARAM lParam)
> {
> LPWAVEHDR lpHdr = (LPWAVEHDR) lParam;
>
> int buflen = lpHdr->dwBufferLength; //160
> float * buf = toFloat(lpHdr->lpData, buflen);
>
> // Encode some audio
> int nRet = enc.encode(buf, buflen);
> unsigned char *compressed = enc.getOutput();
> int clen = enc.getOutputLength();
> int speechDetected = enc.getSpeechDetected();
>
> // delete temporary float buffer
> delete []buf;
>
> // Decode it
> int decodedSamples = dec.decode(compressed, clen);
>
> // Prepare decoded data for WAV
> BYTE pSound = new BYTE[decodedSamples *
> sizeof(short)];
> memcpy(pSound, (BYTE*)dec.getOutput(), decodedSamples
> * sizeof(short));
>
> // Create and initialise the WAVEHDR structure
> WAVEHDR* pSpeexHdr = new WAVEHDR;
>
> pSpeexHdr->lpData = (char*)pSound;
> pSpeexHdr->dwBufferLength = decodedSamples *
> sizeof(short);
> pSpeexHdr->dwFlags = 0L;
> pSpeexHdr->dwLoops = 0L;
>
> // output audio to speaker
> m_Player->PostThreadMessage(WM_PLAYSOUND_PLAYBLOCK,
> GetCurrentThreadId(),(LPARAM) pSpeexHdr);
>
> // clean up
> // delete pSeexHdr;
> // delete [] pSound;
>
> return 1;
> }
>
> this produces unintelligible audio. may be you can
> give me an opinion on how i can properly reconstruct
> my PCM sample ( into WAVHDR) after the decode. this
> would really mean a lot to me.
>
> many of thanks!!!
>
> best regards,
> ronald
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Friends. Fun. Try the all-new Yahoo! Messenger.
> http://messenger.yahoo.com/
> --- >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.
<p><p><p>--- >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