Solved

Playing real-time sound

Posted on 1997-11-26
5
237 Views
Last Modified: 2012-06-21
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
Comment
Question by:hakon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 2

Expert Comment

by:anichini
ID: 1174184
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
 
LVL 2

Expert Comment

by:AlFa
ID: 1174185
Have you checked the DSCAPS (with GetCaps) of your device?

0
 

Author Comment

by:hakon
ID: 1174186
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
 
LVL 23

Accepted Solution

by:
chensu earned 180 total points
ID: 1174187
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
 

Author Comment

by:hakon
ID: 1174188
Thanks !
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

626 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