Solved

Describe buffer format for waveOut()

Posted on 1997-10-14
1
249 Views
Last Modified: 2013-12-03
I successfully used the Win32 API waveOut() call to output some sound to my sound blaster.
waveOutWrite() requires the passing of a pointer to a structure that contains information about the sound to be played. One of the members of this structure is the "buffer":

WAVEHDR WaveHeader;
WaveHeader.lpData = buffer;

I tried specifying something like

WaveHeader.lpData = "balljljsdfljweriwoejrasdafafsff";

and as I expected I received random garbage sound.

I'd like someone to explain how the format of the buffer is interpreted exactly (in 8 bit mode). What does the content of the buffer do to the sound that is output? Please point me to a very specific site that explains the format or explain it yourself. Thanks.
0
Comment
Question by:jawed
[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
1 Comment
 
LVL 5

Accepted Solution

by:
y96andha earned 100 total points
ID: 1407575
Every byte in the buffer is a sample that is output to the speaker. 0x00 is the lowest possible value, 0x80 is the midpoint value and 0xff is highest value.

A buffer containing {0x00, 0xff, 0x00, 0xff ...} will produce a square wave with maximum amplitude.

A buffer containing {0x80, 0x80, 0x80 ...} will produce no output at all.

A buffer containing {0x70, 0x70, 0x70 ...} would optimally produce a weak negative DC.

For a nicer sound than a square wave, try for example to fill the buffer with sine values, like
 buf[i] = 0x80 + 0x40 * sin(i / 16.0 * 2*3.14159)
Playing back this buffer at 8kHz would yield a 500 Hz sine wave with an amplitude of 50% maximum amplitude.

0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

705 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