import echo::{Context, Cell, contain};
import echo::audio::{get_freq_ago, get_wave};
// NOTE: This example uses the microphone, which needs to be explicitly enabled
// to work properly! Click the [x](#microphone) link here or above, or you can
// press Ctrl/Cmd + Shift + M to toggle it!
fn map_cell(i: Cell, ctx: Context) -> Cell {
var p = contain(i.sp, ctx.resolution);
var o = i;
o.bg.g += get_freq_ago(abs(i.sp.y), abs(i.sp.x));
if (o.ch > 31) {
let t = get_wave(i.sp.x * 0.1);
o.bg = vec3(max(0, t), 0, max(0, -t)) * 4;
o.fg = 1 - o.bg;
}
return echo::map_cell_selection(o, i, ctx);
}