| delorie.com/archives/browse.cgi | search |
| Message-ID: | <36291470.D9FFE95A@arctic.net> |
| From: | "Benjamin R. Saylor" <bsaylor AT arctic DOT net> |
| X-Mailer: | Mozilla 4.05 [en] (Win95; I) |
| MIME-Version: | 1.0 |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | 16 bit audio files |
| Lines: | 21 |
| Date: | Sat, 17 Oct 1998 14:04:32 -0800 |
| NNTP-Posting-Host: | 198.51.13.2 |
| X-Complaints-To: | support AT newshosting DOT com |
| X-Trace: | news.siscom.net 908814395 198.51.13.2 (Mon, 19 Oct 1998 12:26:35 EDT) |
| NNTP-Posting-Date: | Mon, 19 Oct 1998 12:26:35 EDT |
| Organization: | Newshosting |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
I wrote a simple c++ program to generate a sine wave and write it to a
signed 16 bit raw audio file:
#include <fstream.h>
#include <math.h>
void main()
{
short wave[11025];
ofstream output("temp.raw", ios::binary);
for (int sample = 0; sample < 11025; sample++)
{
wave[sample] = (short) (32767*sin(.01*sample));
output << wave[sample];
}
}
..but it just produces noise. If the short (int) type is 2 bytes long,
why won't this work? It works for an 8 bit file (char, if some numbers
are changed).
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |