[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Describe buffer format for waveOut()

Posted on 1997-10-14
1
Medium Priority
?
255 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 400 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

649 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