public void select (int start, int end) {
    if (!selected || start != selectStart || end != selectEnd) {
      if (selectEnd < selectStart) {
        selectNone();
      } else {
        if (selectStart >= wave.length()) selectStart = wave.length() - 1;
        if (selectEnd >= wave.length()) selectEnd = wave.length() - 1;
        if (selectStart < 0) selectStart = 0;
        if (selectEnd < 0) selectEnd = 0;
        selectStart = start;
        selectEnd = end;
        selected = true;
        if (observer != null) observer.waveCanvasEvent (this, SELECT);
      }
    }
  }