blob: 6beed2905575ef7b2949cf77d9b8d7fe83c6a3d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#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;
}
|