Combining samples results in downsampling

Feb 28, 2013 at 11:31am

Combining samples results in downsampling

I’m trying to fill a buffer with chunks of another buffer. It seems to work well but I get a downsampling effect.
The problem must be in my java code, can someone verify please?

public void combine(final String frombuf, final long recTimeInSamples) {

		final int channel = 1;
		float[] recordBuffer = MSPBuffer.peek(frombuf, channel);
		float[] playBuffer = MSPBuffer.peek(buffer, channel);
		float[] result = new float[playBuffer.length];
		long length = MSPBuffer.getSize(buffer);

		int iters = (int) length / (int) recTimeInSamples;

		for (int y = 1; y < iters + 1; y++) {
			for (int i = 0; i < (int) recTimeInSamples; i++) {
				result[i * y] = (recordBuffer[i]) + (playBuffer[i * y]);
			}
		}

		MSPBuffer.poke(buffer, channel, result);
	}
#66760

You must be logged in to reply to this topic.