2021-12-19 22:44:48 +00:00
|
|
|
// draw.c
|
|
|
|
|
|
|
|
void draw_frame(SDL_Window *w, SDL_Renderer *r, Ampler_state *state) {
|
2021-12-20 00:03:14 +00:00
|
|
|
SDL_SetRenderDrawColor(r, 0x1D, 0x2B, 0x53, 255);
|
|
|
|
SDL_RenderClear(r);
|
|
|
|
|
|
|
|
SDL_SetRenderDrawColor(r, 0xFF, 0x00, 0x4D, 255);
|
|
|
|
const space = (44100 * 8) / 512;
|
|
|
|
for int t = 0; t < arraylen(state -> tracks); t += 1 do
|
|
|
|
for int x = 0; x < 512; x += 1 do {
|
|
|
|
const int y = 128 + 256 * t;
|
|
|
|
const int val = state -> tracks[t][x * space];
|
2021-12-20 02:06:02 +00:00
|
|
|
SDL_RenderDrawLine(r, y + val / 8, x, y + val, x);
|
|
|
|
//SDL_RenderDrawPoint(r, y + val, x);
|
2021-12-20 00:03:14 +00:00
|
|
|
}
|
|
|
|
|
2021-12-20 02:06:02 +00:00
|
|
|
if state -> played_audio_last_frame do
|
|
|
|
for int i = 0; i < arraylen(state -> sounds); i += 1 do {
|
|
|
|
const int x = (state -> sounds[i].start + state -> sounds[i].pos) / space;
|
|
|
|
SDL_RenderDrawLine(r, 0, x, 512, x);
|
|
|
|
}
|
|
|
|
|
2021-12-20 00:03:14 +00:00
|
|
|
SDL_RenderPresent(r);
|
2021-12-19 22:44:48 +00:00
|
|
|
}
|