Solved

playing sound using direct sound

Posted on 2001-06-18
5
242 Views
Last Modified: 2013-12-03
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.
0
Comment
Question by:stern_b
  • 2
  • 2
5 Comments
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6202060
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.


0
 
LVL 23

Expert Comment

by:chensu
ID: 6205025
>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.
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 200 total points
ID: 6248981
No reaction, I hope , my comment helps. Alex
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6697023
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
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6791205
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.
 
http://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:

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now