All pastes #421710 Raw Edit

waveform viewer

public c v1 · immutable
·published 2007-04-03 00:12 UTC
rendered paste body
#define W 400#define H 200void waveform_viewer(Audio *a, unsigned long samples){   unsigned long samples_per_pixel;   unsigned long x;   unsigned long offset;   double min;   double max;   double v;      samples_per_pixel = samples / W;      for(x = 0; x < W; ++x) {      min = 1;      max = 0;      for(offset = 0; offset < samples_per_pixels; ++offset) {         v = a[x * samples_per_pixel + offset];         if(v > max) max = v;         if(v < min) min = v;      }      draw_line(x, min * H, x, max * H);   }}