Initial commit

This commit is contained in:
Cristian Gora
2026-02-13 17:51:10 +01:00
commit 5d5ab53801
4 changed files with 311 additions and 0 deletions

25
gen.c Normal file
View File

@@ -0,0 +1,25 @@
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#define SAMPLE_RATE 44100
#define DURATION 5
#define FREQUENCY 440
#define VOLUME 0.3f
int main() {
for (size_t i = 0; i < DURATION * SAMPLE_RATE; ++i) {
float t = (float)i / SAMPLE_RATE;
float volume = (float)INT16_MAX * VOLUME;
int16_t sample = 0;
sample = (int16_t)
(
(sinf(2*M_PI * FREQUENCY * t) * volume) +
(sinf(2*M_PI * 2*FREQUENCY * t) * volume)
);
fwrite(&sample, sizeof(sample), 1, stdout);
}
return 0;
}