Link to home
Start Free TrialLog in
Avatar of stern_b
stern_b

asked on

playing sound using direct sound

hi,
im try to play wave file
in this format:
8 khz,16 bit (sampled at),mono.

in the lpDirectSound->CreateSoundBuffer() func
i supply WAVEFORMATEX structure with this parmeters:
    wf.wFormatTag = ; //i dont know
    wf.nChannels = 1;
    wf.nSamplesPerSec = 8000;
    wf.nBlockAlign = 2;
    wf.nAvgBytesPerSec =wf.nSamplesPerSec*wf.nBlockAlign;
    wf.wBitsPerSample = 16;

the sound that i receive is very slow
and with lot of noise.
(in very slow i mean that the voice
 is spread on long time)

the format of the sound file that i try to play,
is as codec output, before any manipulations (include pcm).

i dont know the correct parameter for field wf.wFormatTag in the WAVEFORMATEX structure.

is the direct sound is the good way for this task?
 
TIA.

///////////
19-6-01

the original file is not  pcm format, but now i convert it to pcm format, for using WAVE_FORMAT_PCM.
(Also, my code already based on Microsoft sample in direct sound documentation).
But the problem persists. (The sound spread on long time)

Its lock likes frequency mismatch,
May the hardware or driver translate the data as lowest sample rate so all sample take more time when playing it.
Avatar of AlexVirochovsky
AlexVirochovsky

check out example in
http://msdn.microsoft.com/library/wcedoc/wcegmm/dsover_25.htm
About WAVEFORMATEX
see
http://msdn.microsoft.com/library/psdk/directx/DX8_VB/hh/directx8_vb/_dx_waveformatex_dxaudio_vb.htm
1-st parameter of WAVEFORMATEX
must be set to WAVE_FORMAT_PCM or WAVE_FORMAT_DRM.


>i dont know the correct parameter for field wf.wFormatTag in the WAVEFORMATEX structure.

Use WAVE_FORMAT_PCM if it is in PCM format.

>is the direct sound is the good way for this task?

If you just want to simply play a wave file, using the PlaySound API function is much easier.
ASKER CERTIFIED SOLUTION
Avatar of AlexVirochovsky
AlexVirochovsky

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If this proposed answer has helped you, please accept it, grade it and close this question.  If it is not, reject it and add comments as to your progress and what else is needed.

Thanks,
Moondancer
Community Support Moderator @ Experts Exchange
Zero response from Asker or expert(s) since my last follow up request, therefore can only assume that the Proposed Answer served the need.  Closing today.

I am sorry to see that Asker has not returned to update and finalize this question.  I am, therefore, force accepting this question.  In the event the Asker returns with additional needs related to this question, please respond and continue the collaboration process.
 
If there are questions in this regard, please comment and I'll return when I can.
 
The HELP DESK link on the left is informative, and includes this site's Guidelines and Member Agreement as well as assistance related to Questions and Answers.  Here is the QA link, as a reference.
 
https://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp

--->  While I'm here anyway, letting all know that we have added quite a number of new Topic Areas, as you'll see from the link below:

https://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Community Support Moderator @ Experts Exchange