ampler/draw.c

27 lines
797 B
C
Raw Normal View History

2021-12-19 22:44:48 +00:00
// draw.c
void draw_frame(SDL_Window *w, SDL_Renderer *r, Ampler_state *state) {
SDL_SetRenderDrawColor(r, 0x1D, 0x2B, 0x53, 255);
//SDL_SetRenderDrawColor(r, 10, 10, 10, 100);
SDL_RenderClear(r);
// TODO: ACTUALLY DRAW ALL SOUNDS, BUT SMOLER
SDL_SetRenderDrawColor(r, 0xFF, 0x00, 0x4D, 255);
const space = (44100 * 8) / 512;
const int t = 0;
for int x = 0; x < 512; x += 1 do {
const int y = 128 + 256 * t;
const int val = state -> sounds[0].tracks[t][x * space];
SDL_RenderDrawLine(r, x, y + val / 8, x, y + val);
//SDL_RenderDrawPoint(r, x, y + val);
}
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].pos / space;
SDL_RenderDrawLine(r, x, 0, x, 512);
2021-12-20 02:06:02 +00:00
}
SDL_RenderPresent(r);
2021-12-19 22:44:48 +00:00
}