lib/minim/src/ddf/minim/javasound/FloatSampleBuffer.java
/**
	 * Writes this sample buffer's audio data to <code>buffer</code> as an
	 * interleaved byte array. <code>buffer</code> must be large enough to
	 * hold all data.
	 * 
	 * @param readOffset the sample offset from where samples are read from this
	 *            FloatSampleBuffer
	 * @param lenInSamples how many samples are converted
	 * @param buffer the byte buffer written to
	 * @param writeOffset the byte offset in buffer
	 * @throws IllegalArgumentException when buffer is too small or
	 *             <code>format</code> doesn't match
	 * @return number of bytes written to <code>buffer</code>
	 */
Writes this sample buffer's audio data to buffer as an
interleaved byte array. buffer must be large enough to
hold all data.


Writes this sample buffer ' s audio data to buffer as an interleaved byte array . buffer must be large enough to hold all data .
public int convertToByteArray(int readOffset, int lenInSamples,
			byte[] buffer, int writeOffset, AudioFormat format) {
		int byteCount = format.getFrameSize() * lenInSamples;
		if (writeOffset + byteCount > buffer.length) {
			throw new IllegalArgumentException(
					"FloatSampleBuffer.convertToByteArray: buffer too small.");
		}
		if (format != lastConvertToByteArrayFormat) {
			if (format.getSampleRate() != getSampleRate()) {
				throw new IllegalArgumentException(
						"FloatSampleBuffer.convertToByteArray: different samplerates.");
			}
			if (format.getChannels() != getChannelCount()) {
				throw new IllegalArgumentException(
						"FloatSampleBuffer.convertToByteArray: different channel count.");
			}
			lastConvertToByteArrayFormat = format;
			lastConvertToByteArrayFormatCode = FloatSampleTools.getFormatType(format);
		}
		FloatSampleTools.float2byte(channels, readOffset, buffer, writeOffset,
				lenInSamples, lastConvertToByteArrayFormatCode,
				format.getChannels(), format.getFrameSize(),
				getConvertDitherBits(lastConvertToByteArrayFormatCode));
		return byteCount;
	}
public int convertToByteArray ( int readOffset , int lenInSamples , byte [ ] buffer , int writeOffset , AudioFormat format ) { int byteCount = format . getFrameSize ( ) * lenInSamples ; if ( writeOffset + byteCount > buffer . length ) { throw new IllegalArgumentException ( "FloatSampleBuffer.convertToByteArray: buffer too small." ) ; } if ( format != lastConvertToByteArrayFormat ) { if ( format . getSampleRate ( ) != getSampleRate ( ) ) { throw new IllegalArgumentException ( "FloatSampleBuffer.convertToByteArray: different samplerates." ) ; } if ( format . getChannels ( ) != getChannelCount ( ) ) { throw new IllegalArgumentException ( "FloatSampleBuffer.convertToByteArray: different channel count." ) ; } lastConvertToByteArrayFormat = format ; lastConvertToByteArrayFormatCode = FloatSampleTools . getFormatType ( format ) ; } FloatSampleTools . float2byte ( channels , readOffset , buffer , writeOffset , lenInSamples , lastConvertToByteArrayFormatCode , format . getChannels ( ) , format . getFrameSize ( ) , getConvertDitherBits ( lastConvertToByteArrayFormatCode ) ) ; return byteCount ; }
Writes this sample buffer's audio data to <code>buffer</code> as an
 interleaved byte array.
Writes this sample buffer ' s audio data to <code > buffer< / code > as an interleaved byte array .