Solved

playing sound using direct sound

Posted on 2001-06-18
5
250 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

792 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