Home Propeller Head Plaza

Technical and scientific discussion of amps, cables and other topics.

Code correction

Howdy

Should anyone want to play with this stuff to recreate my examples you might want this slightly corrected code. If you don't open the file in binary you'll get weird extra bytes now and then :)


#include

#define _USE_MATH_DEFINES
#include

int main () {
const double sr = 44100;
const double sp = 1/sr;
FILE * h = fopen("out.pcm", "w+b");
for (double t = 0; t < 20; t += sp) {
double a = sin((2 * M_PI) * (t * 154350.0l/11));
short s = int(a * 32767);
fwrite(&s, 2, 1, h); }
fclose(h); }

-Ted


This post is made possible by the generous support of people like you and our sponsors:
  Western Glow Tube Service  


Follow Ups Full Thread
Follow Ups
  • Code correction - Ted Smith 19:22:23 08/23/03 (0)


You can not post to an archived thread.