private void fillbuf(byte[] buf, int off, int len) {
            double[] val = new double[nch];
            double[] sm = new double[nch];
            while (len > 0) {
                for (int i = 0; i < nch; i++)
                    val[i] = 0;
                for (Iterator<CS> i = clips.iterator(); i.hasNext(); ) {
                    CS cs = i.next();
                    if (!cs.get(sm)) {
                        i.remove();
                        continue;
                    }
                    for (int ch = 0; ch < nch; ch++)
                        val[ch] += sm[ch];
                }
                for (int i = 0; i < nch; i++) {
                    int iv = (int) (val[i] * 32767.0);
                    if (iv < 0) {
                        if (iv < -32768)
                            iv = -32768;
                        iv += 65536;
                    } else {
                        if (iv > 32767)
                            iv = 32767;
                    }
                    buf[off++] = (byte) (iv & 0xff);
                    buf[off++] = (byte) ((iv & 0xff00) >> 8);
                    len -= 2;
                }
            }
        }