ampler/draw.c

34 lines
1.1 KiB
C

// 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: DRAW WITH X SCALE FACTOR
// TODO: DRAW SMOLER
SDL_SetRenderDrawColor(r, 0xFF, 0x00, 0x4D, 255);
const space = (44100 * 8) / 512;
// TODO: DRAW L / R OVERLAPPED IN DIFF COLORS ?
const int t = 0;
foreach_ptr(Sound_src, snd, state -> sounds)
if snd -> state != SND_FREE do
for int x = 0; x < 512; x += 1 do {
const int y = 128 + 256 * snd_i;
const int val = snd -> tracks[t][x * space];
SDL_RenderDrawLine(r, x, y + val / 8, x, y + val);
//SDL_RenderDrawPoint(r, x, y + val);
}
if state -> played_audio_last_frame do
foreach_ptr(Sound_src, snd, state -> sounds)
if snd->state == SND_PLAYING or snd->state == SND_LOOPING do {
const int x = snd -> pos / space;
SDL_RenderDrawLine(r, x, 0, x, 512);
SDL_RenderDrawLine(r, snd->start / space, 0, snd->start / space, 512);
SDL_RenderDrawLine(r, snd->end / space, 0, snd->end / space, 512);
}
SDL_RenderPresent(r);
}