#if 0 /* #/ ================================================================ #/ #/ sinewave.c #/ #/ ================================================================ #/ #/ Self-compilation shell script #/ SRC=${0##*./} BIN=${SRC%.*} gcc \ -Wall -Wextra -Werror -pedantic \ -Wno-old-style-declaration \ -Wno-missing-braces \ -Wno-unused-variable \ -Wno-unused-but-set-variable \ -Wno-unused-parameter \ -Wno-overlength-strings \ -O3 \ -fsanitize=undefined,address,leak \ -lX11 -lm -lasound \ -o $BIN $SRC && \ ./$BIN $@ && rm $BIN exit $? # */ #endif #include "../reduced_system_layer.c" void update_and_render_frame(void) { // Nothing } i32 main(i32 argc, c8 **argv) { (void) argc; (void) argv; platform.graceful_exit = 1; f64 frequency = 440. * 4; f32 frames[AUDIO_SAMPLE_RATE * AUDIO_NUM_CHANNELS]; for (i64 i = 0; i < AUDIO_SAMPLE_RATE; ++i) { f64 t = ((f64) i) / AUDIO_SAMPLE_RATE; f64 x = sin(t * frequency); if (t < .1) x *= t / .1; if (t > .7) x *= (1. - t) / .3; frames[i * 2] = (f32) x * .5; frames[i * 2 + 1] = (f32) x * .5; } p_queue_sound(0, AUDIO_SAMPLE_RATE, frames); p_handle_audio(AUDIO_SAMPLE_RATE); p_cleanup(); return 0; }