Link to home
Start Free TrialLog in
Avatar of hakon
hakon

asked on

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.
Avatar of anichini
anichini

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, ...])

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

Avatar of hakon

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

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
Avatar of hakon

ASKER

Thanks !