Solved

Playing real-time sound

Posted on 1997-11-26
5
221 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
5 Comments
 
LVL 2

Expert Comment

by:anichini
Comment Utility
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
Comment Utility
Have you checked the DSCAPS (with GetCaps) of your device?

0
 

Author Comment

by:hakon
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks !
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

744 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

12 Experts available now in Live!

Get 1:1 Help Now