int smooth_sample(int current, int previous) { if (current > previous) return (current + previous) / 2; return current; }