🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.multimedia
2 messages
2 total messages Started by Mike Sat, 14 Apr 2001 15:40
Wave problem
#1251
Author: Mike
Date: Sat, 14 Apr 2001 15:40
26 lines
1473 bytes
Hi!

What is wrong with this code? It should generate raw wave data (8-bit,
48.000 Hz, unsigned) - triangular wave, but it doesn't. It generates
something
like that, but with some strange offsets.

=========================================
#include <math.h>
#include <iostream.h>
unsigned long int freq = 1;
unsigned long int i;
main() {
 FILE *output_file;
 output_file = fopen("test.raw", "wb");
 for (i = 0; i < (freq * 48000); ++i) {
  fputc(int(256.0 * fabsl(fmodl((2.0 * i * freq) / 48000.0 - 0.5, 2.0) -

1.0) - 128.0), output_file);
 }
 fclose(output_file);
}
=========================================


Mike
Re: Wave problem
#1252
Author: Mike
Date: Sat, 14 Apr 2001 18:20
6 lines
899 bytes
Hi!

It's OK now.


Mike
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads