将ByteArray转换为IntArray java [英] Convert ByteArray to IntArray java
问题描述
我有一个 ByteArrayOutputStream
与来自AudioSource的Dataline连接。我需要将Stream转换为一些有意义的值,这些值很可能是从源获取的声音值?
那么我怎样才能在intArray中收敛byteArray(来自 ByteArrayOutStream.getByteArray()
)?我用Google搜索但没有运气。
I have an ByteArrayOutputStream
connected with a Dataline from an AudioSource. I need to convert the Stream in some significative values that probally are the sound values taken from source or not ?
Well then how can I conver the byteArray (from ByteArrayOutStream.getByteArray()
) in a intArray?. I googled it but with no luck .
ps 我使用的audioFormat是:PCM_SIGNED 192.0Hz 16Bit big endian
p.s. the audioFormat that I used is : PCM_SIGNED 192.0Hz 16Bit big endian
推荐答案
使用 ByteBuffer
。您不仅可以通过这种方式转换为不同的数组类型,还可以处理 endian 问题。
Use a ByteBuffer
. You can convert not only to different array types this way, but also deal with endian issues.
这篇关于将ByteArray转换为IntArray java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!