Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

Playing real-time sound

I'm working on a project, where I have to create sound in
real-time. The waveform is 8 bit PCM. I have tried to use
low level audio functions as described in DirectSound.

I'm using VC5.0++

When I'm playing a sound-sample I can hear some weak
noise as long as spesified.

I have used this functions:

DirectSoundCreate
SetCooperativeLevel
CreateSoundBuffer
Lock
memcpy
Unlock
SetCurrentPosition
Play

all of are returning "DS_OK", but the sound are not playing.

Please help.
0
hakon
Asked:
hakon
1 Solution
 
anichiniCommented:
You might want to check to make sure the waveform data you are copying into the direct sound buffer is in the correct format and at the correct sampling rate. For example, 8 bit PCM is unsigned, so 128 is "zero". (So for example if you had a 22 khz, 8 bit buffer, a 11 khz square wave would be [255, 0, 255, 0, 255, ...])

0
 
AlFaCommented:
Have you checked the DSCAPS (with GetCaps) of your device?

0
 
hakonAuthor Commented:
Yes, I have checked the DSCAPS. Everything seems OK.

Now I'm using waveOut-functions. They are working, but I
hear a short silence between blocks of waveform data. I can
probably use this solution.
0
 
chensuCommented:
Look into two samples that come with DirectX SDK: DSSHOW and DSSTREAM. And, you can use the functions in samples\misc\dsutil.c directly. Since you create the sound samples in real-time, you may use BOOL DSFillSoundBuffer(IDirectSoundBuffer *pDSB, BYTE *pbWaveData, DWORD cbWaveSize) function in dsutil.c.
0
 
hakonAuthor Commented:
Thanks !
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now