lib/minim/src/ddf/minim/javasound/FloatSampleBuffer.java
/**
	 * Resizes this buffer.
	 * <p>
	 * If <code>keepOldSamples</code> is true, as much as possible samples are
	 * retained. If the buffer is enlarged, silence is added at the end. If
	 * <code>keepOldSamples</code> is false, existing samples may get
	 * discarded, the buffer may then contain random samples.
	 */
Resizes this buffer.

If keepOldSamples is true, as much as possible samples are
retained. If the buffer is enlarged, silence is added at the end. If
keepOldSamples is false, existing samples may get
discarded, the buffer may then contain random samples.
Resizes this buffer . If keepOldSamples is true as much as possible samples are retained . If the buffer is enlarged silence is added at the end . If keepOldSamples is false existing samples may get discarded the buffer may then contain random samples .
public void changeSampleCount(int newSampleCount, boolean keepOldSamples) {
		int oldSampleCount = getSampleCount();
		if (oldSampleCount >= newSampleCount) {
			setSampleCountImpl(newSampleCount);
			return;
		}
		if (channelCount == 1 || channelCount == 2) {
			float[] ch = getChannel(0);
			if (ch.length < newSampleCount) {
				float[] newCh = new float[newSampleCount];
				if (keepOldSamples && oldSampleCount > 0) {
					System.arraycopy(ch, 0, newCh, 0, oldSampleCount);
				}
				channels[0] = newCh;
			} else if (keepOldSamples) {
				for (int i = oldSampleCount; i < newSampleCount; i++) {
					ch[i] = 0.0f;
				}
			}
			if (channelCount == 2) {
				ch = getChannel(1);
				if (ch.length < newSampleCount) {
					float[] newCh = new float[newSampleCount];
					if (keepOldSamples && oldSampleCount > 0) {
						System.arraycopy(ch, 0, newCh, 0, oldSampleCount);
					}
					channels[1] = newCh;
				} else if (keepOldSamples) {
					for (int i = oldSampleCount; i < newSampleCount; i++) {
						ch[i] = 0.0f;
					}
				}
			}
			setSampleCountImpl(newSampleCount);
			return;
		}
		Object[] oldChannels = null;
		if (keepOldSamples) {
			oldChannels = getAllChannels();
		}
		init(getChannelCount(), newSampleCount, getSampleRate());
		if (keepOldSamples) {
			int copyCount = newSampleCount < oldSampleCount ? newSampleCount
					: oldSampleCount;
			for (int ch = 0; ch < this.channelCount; ch++) {
				float[] oldSamples = (float[]) oldChannels[ch];
				float[] newSamples = (float[]) channels[ch];
				if (oldSamples != newSamples) {
					System.arraycopy(oldSamples, 0, newSamples, 0, copyCount);
				}
				if (oldSampleCount < newSampleCount) {
					for (int i = oldSampleCount; i < newSampleCount; i++) {
						newSamples[i] = 0.0f;
					}
				}
			}
		}
	}
public void changeSampleCount ( int newSampleCount , boolean keepOldSamples ) { int oldSampleCount = getSampleCount ( ) ; if ( oldSampleCount >= newSampleCount ) { setSampleCountImpl ( newSampleCount ) ; return ; } if ( channelCount == 1 || channelCount == 2 ) { float [ ] ch = getChannel ( 0 ) ; if ( ch . length < newSampleCount ) { float [ ] newCh = new float [ newSampleCount ] ; if ( keepOldSamples && oldSampleCount > 0 ) { System . arraycopy ( ch , 0 , newCh , 0 , oldSampleCount ) ; } channels [ 0 ] = newCh ; } else if ( keepOldSamples ) { for ( int i = oldSampleCount ; i < newSampleCount ; i ++ ) { ch [ i ] = 0.0f ; } } if ( channelCount == 2 ) { ch = getChannel ( 1 ) ; if ( ch . length < newSampleCount ) { float [ ] newCh = new float [ newSampleCount ] ; if ( keepOldSamples && oldSampleCount > 0 ) { System . arraycopy ( ch , 0 , newCh , 0 , oldSampleCount ) ; } channels [ 1 ] = newCh ; } else if ( keepOldSamples ) { for ( int i = oldSampleCount ; i < newSampleCount ; i ++ ) { ch [ i ] = 0.0f ; } } } setSampleCountImpl ( newSampleCount ) ; return ; } Object [ ] oldChannels = null ; if ( keepOldSamples ) { oldChannels = getAllChannels ( ) ; } init ( getChannelCount ( ) , newSampleCount , getSampleRate ( ) ) ; if ( keepOldSamples ) { int copyCount = newSampleCount < oldSampleCount ? newSampleCount : oldSampleCount ; for ( int ch = 0 ; ch < this . channelCount ; ch ++ ) { float [ ] oldSamples = ( float [ ] ) oldChannels [ ch ] ; float [ ] newSamples = ( float [ ] ) channels [ ch ] ; if ( oldSamples != newSamples ) { System . arraycopy ( oldSamples , 0 , newSamples , 0 , copyCount ) ; } if ( oldSampleCount < newSampleCount ) { for ( int i = oldSampleCount ; i < newSampleCount ; i ++ ) { newSamples [ i ] = 0.0f ; } } } } }
Resizes this buffer.
Resizes this buffer .
// shortcut: if we just make this buffer smaller, just set new // sampleCount // shortcut for one or 2 channels // copy old samples // silence out excess samples (according to the specification) // copy old samples // silence out excess samples (according to the // specification) // copy old channels and eventually silence out new samples // if this sample array was not object of lazy delete // silence out new samples