Performs resampling of the given signal.

@param buffer the buffer containing the signal.
@param len the length of the signal in bytes.
@return resampled signal
328455
public double[] perform(double[] buffer, int len) {
        int size = (int)((double)F/f * len);
        double signal[] = new double[size];

        double dx = 1./(double)f;
        double dX = 1./(double)F;

        signal[0] = buffer[0];

        double k = 0;
        for (int i = 1; i < size - 1; i++) {
            double X = i * dX;

            int p = (int)(X/dx);
            int q = p + 1;

            k = (buffer[q] - buffer[p])/dx;
            double x = p * dx;

            signal[i] = buffer[p] + (X - x) * k;
        }

        signal[size - 1] = buffer[len - 1] + ((size - 1) *dX - (len -1)*dx) *k;
        return signal;
    }
1067078
def read_into_buffer(buffer, size)
      tmp = read_all(size)
      i = 0
      tmp.each_byte do |byte|
        Bytes.set_string_byte(buffer, i, byte)
        i += 1
      end
      i
    end
407760
def set_data(self, data_buffer):
        
        if len(data_buffer) % (self.sample_width * self.channels) != 0:
            raise ValueError("length of data_buffer must be a multiple of (sample_width * channels)")
        self._buffer = data_buffer
        self._index = 0
        self._left = 0 if self._buffer is None else len(self._buffer)
913791
public ByteArrayQueue remove(int len) {
		offset += len;
		length -= len;
		// Release buffer if empty
		if (length == 0 && array.length > 1024) {
			array = new byte[32];
			offset = 0;
			shared = false;
		}
		return this;
	}
1128613
protected ByteBuffer getByteBuffer(int bufferLength) {
        if(_buffer == null) {
            _buffer = ByteBuffer.wrap(new byte[bufferLength]);
            _log.info("ByteBuffer allocated for buffering");
        }
        
        return _buffer;
    }
497976
public static boolean compact(ByteBuffer buffer) {
        if (buffer.position() == 0)
            return false;
        boolean full = buffer.limit() == buffer.capacity();
        buffer.compact().flip();
        return full && buffer.limit() < buffer.capacity();
    }
1298329
@Override
    public int decode ( byte[] buffer, int bufferIndex, int len ) throws SMBProtocolDecodingException {
        int start = bufferIndex;
        this.chunksWritten = SMBUtil.readInt4(buffer, bufferIndex);
        bufferIndex += 4;
        this.chunkBytesWritten = SMBUtil.readInt4(buffer, bufferIndex);
        bufferIndex += 4;
        this.totalBytesWritten = SMBUtil.readInt4(buffer, bufferIndex);
        bufferIndex += 4;
        return bufferIndex - start;
    }
341101
public byte []
readByteArray(int len) throws WireParseException {
	require(len);
	byte [] out = new byte[len];
	byteBuffer.get(out, 0, len);
	return out;
}
446947
public void setBuffer(final String buffer) {
        initRandomBuffer();
        byteBufferAry = Arrays.copyOf(buffer.getBytes(), MAX_PACKETBUFFER_LENGTH);
    }
1358877
def append_data(self, data_buffer):
        

        if len(data_buffer) % (self.sample_width * self.channels) != 0:
            raise ValueError("length of data_buffer must be a multiple of (sample_width * channels)")

        self._buffer += data_buffer
        self._left += len(data_buffer)
1130770
public void write(byte[] arr, int off, int len) throws IOException {
    if (len > buf.length - pos) {
      if (buf.length != getMaxPacketLength()) {
        growBuffer(len);
      }

      //max buffer size
      if (len > buf.length - pos) {

        if (mark != -1) {
          growBuffer(len);
          if (mark != -1) {
            flushBufferStopAtMark();
          }

        } else {
          //not enough space in buffer, will stream :
          // fill buffer and flush until all data are snd
          int remainingLen = len;
          do {
            int lenToFillBuffer = Math.min(getMaxPacketLength() - pos, remainingLen);
            System.arraycopy(arr, off, buf, pos, lenToFillBuffer);
            remainingLen -= lenToFillBuffer;
            off += lenToFillBuffer;
            pos += lenToFillBuffer;
            if (remainingLen > 0) {
              flushBuffer(false);
            } else {
              break;
            }
          } while (true);
          return;
        }
      }
    }

    System.arraycopy(arr, off, buf, pos, len);
    pos += len;
  }
265546
public long resample(final long samples, final Timebase oldRate)
	{
		try
		{
			return resample(samples, oldRate, false);
		}
		catch (ResamplingException e)
		{
			// should never happen
			throw new RuntimeException(e);
		}
	}
1255955
function consume (len) {
		count -= len
		if (count < 0) {
			count = 0;
			console.warn('Not enough samples fed for the next data frame. Expected frame is ' + samplesPerFrame + ' samples ' + channels + ' channels')
		}

		if (!callbackMarks.length) return

		for (let i = 0, l = callbackMarks.length; i < l; i++) {
			callbackMarks[i] = Math.max(callbackMarks[i] - len, 0)
		}

		while (callbackMarks[0] <= 0) {
			callbackMarks.shift()
			let cb = callbackQueue.shift()
			cb()
		}
	}
768893
def process_buffer(buffer, n_channels):
    
    samples = np.concatenate(buffer)

    if n_channels > 1:
        samples = samples.reshape((-1, n_channels)).T
        samples = librosa.to_mono(samples)

    return samples
787549
static final byte[] deflate(final byte[] in, final int len) {
		byte[] defBuf = new byte[len << 1];
		int payloadLength;
		synchronized (deflater) {
			deflater.reset();
			deflater.setInput(in, 0, len);
			deflater.finish();
			payloadLength = deflater.deflate(defBuf);
		}
		return resizeBuffer(defBuf, payloadLength);
	}
139795
public static byte[] fromHexByteArray(final byte[] buffer)
    {
        final byte[] outputBuffer = new byte[buffer.length >> 1];

        for (int i = 0; i < buffer.length; i += 2)
        {
            final int hi = FROM_HEX_DIGIT_TABLE[buffer[i]] << 4;
            final int lo = FROM_HEX_DIGIT_TABLE[buffer[i + 1]]; // lgtm [java/index-out-of-bounds]
            outputBuffer[i >> 1] = (byte)(hi | lo);
        }

        return outputBuffer;
    }
873760
public JcString subLength(int len) {
		JcNumber sub = new JcNumber(len, this.getPredecessor(), OPERATOR.Common.COMMA_SEPARATOR); 
		JcString ret = new JcString(null, sub,
				new FunctionInstance(FUNCTION.String.SUBSTRING, 3));
		QueryRecorder.recordInvocationConditional(this, "subLength", ret, QueryRecorder.literal(len));
		return ret;
	}