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
Solved

Describe buffer format for waveOut()

Posted on 1997-10-14
1
243 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Event ID 10010 3 69
Best way to accomplish this task? 3 88
Why is "packages element is not declared"? 2 325
Please explain purpose of GZIP 4 34
This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 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