/**
* Write the contents of the byte array to this buffer, overwriting existing
* data. If the byte array has fewer channels than this float buffer, only
* the first channels are written. Vice versa, if the byte buffer has more
* channels than this float buffer, only the first channels of the byte
* buffer are written to this buffer.
* <p>
* The format and the number of samples of this float buffer are not
* changed, so if the byte array has more samples than fit into this float
* buffer, it is not expanded.
*
* @param buffer the byte buffer to write to this float buffer
* @param srcByteOffset the offset in bytes in buffer where to start reading
* @param format the audio format of the bytes in buffer
* @param dstSampleOffset the offset in samples where to start writing the
* converted float data into this float buffer
* @param aSampleCount the number of samples to write
* @return the number of samples actually written
*/
public int writeByteBuffer(byte[] buffer, int srcByteOffset,
AudioFormat format, int dstSampleOffset, int aSampleCount) {
if (dstSampleOffset + aSampleCount > getSampleCount()) {
aSampleCount = getSampleCount() - dstSampleOffset;
}
int lChannels = format.getChannels();
if (lChannels > getChannelCount()) {
lChannels = getChannelCount();
}
if (lChannels > format.getChannels()) {
lChannels = format.getChannels();
}
for (int channel = 0; channel < lChannels; channel++) {
float[] data = getChannel(channel);
FloatSampleTools.byte2floatGeneric(buffer, srcByteOffset,
format.getFrameSize(), data, dstSampleOffset, aSampleCount,
format);
srcByteOffset += format.getFrameSize() / format.getChannels();
}
return aSampleCount;
}
FloatSampleBuffer.java 文件源码
java
阅读 20
收藏 0
点赞 0
评论 0
项目:romanov
作者:
评论列表
文章目录