diff options
author | EliteTK <tomasz.kramkowski@gmail.com> | 2015-06-19 19:11:37 +0100 |
---|---|---|
committer | EliteTK <tomasz.kramkowski@gmail.com> | 2015-06-19 19:11:37 +0100 |
commit | 75d2e00662416224f4b745e0004f48f1fc1d9665 (patch) | |
tree | b08b0bd4d9edaf7cb59abb0efe12800ce166cae6 | |
parent | 35e4f1939645be6673cad3b49290c91946cad599 (diff) | |
download | c-stuff-75d2e00662416224f4b745e0004f48f1fc1d9665.tar.gz c-stuff-75d2e00662416224f4b745e0004f48f1fc1d9665.tar.xz c-stuff-75d2e00662416224f4b745e0004f48f1fc1d9665.zip |
tunes.c
-rw-r--r-- | tunes.c | 56 |
1 files changed, 56 insertions, 0 deletions
@@ -0,0 +1,56 @@ +#include <math.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> + +#define TICKS 8000 + +int main(int argc, char **argv) +{ + uint64_t divs[] = {1, 2, 4, 5, 8, 10, 16, 20, 25, 32, 40, 50, 64, 80, 100, 125, 160, 200, 250, 320, 400, 500, 800, 1000, 1600, 2000, 4000, 8000}; + + /*putchar('\n');*/ + + /*for (uint64_t div = 0; div < 28; div++) {*/ + /*float frequency = 8000.0 / (float)divs[div];*/ + /*fprintf(stderr, "\r ");*/ + /*fprintf(stderr, "\rFrequency: %f, Divs: %ld", frequency, divs[div]);*/ + /*fflush(stderr);*/ + /*for (uint64_t i = 0; i < 8000; i++)*/ + /*putchar(255 * !!((i / divs[div]) & 1));*/ + /*}*/ + +/*#define CYCLES 10*/ +/*#define UNDER 10*/ + + /*for (unsigned cycle = 0; cycle < 10000; cycle++) {*/ + /*float duty = (sinf((float)cycle / UNDER * M_PI) + 1) / (float)2;*/ + /*unsigned on_amount = duty * CYCLES;*/ + /*unsigned off_amount = CYCLES - on_amount;*/ + + /*fprintf(stderr, "Cycle: %d, Duty: %f, On: %d, Off: %d\n", cycle, duty, on_amount, off_amount);*/ + + /*for (unsigned i = 0; i < on_amount; i++)*/ + /*putchar(255);*/ + + /*for (unsigned i = 0; i < off_amount; i++)*/ + /*putchar(0);*/ + /*}*/ + + if (argc != 3) + exit(EXIT_FAILURE); + + unsigned halfwidth = strtol(argv[1], NULL, 10); + unsigned cycles = strtol(argv[2], NULL, 10); + + for (unsigned cycle = 0; cycle < cycles; cycle++) { + for (unsigned i = 0; i < halfwidth; i++) + putchar(255); + for (unsigned i = 0; i < halfwidth; i++) + putchar(0); + } + + return 0; +} + +/* link:-lm: */ |