且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从byte []数组播放声音

更新时间:2023-09-28 09:19:10

我没有看到你从你的声音字节数组读取的时间循环。他们的方式你设置,应该可能有这样的东西:

I don't see where you are reading from your sound byte array in your while loop. They way you are set up, there should probably be something along these lines:

while (nBytesRead = soundDataArray.read(bytes) != 1)

...假设你设置了读方法,字节从读取命令接收数据。然后write()方法将重复填充'bytes'来发送。

...assuming you have the read method set up so that the buffer called 'bytes' receives the data from the read command. Then the write() method will have 'bytes' repeatedly populated to send.

当然,'bytes'只是一个在while循环中使用的缓冲区,字节数组与源声音。

Of course, 'bytes' is just a buffer only used in the while loop, NOT the byte array with the source sound.

有时,read方法有两个输入,如: .read(bufferArray,bytesToRead);
,其中在ak或几个k的范围内的值是公共的。 (bufferArray.length == bytesToRead)

Sometimes the read method has two inputs, as in: .read(bufferArray, bytesToRead); where values in the range of a k or several k are common. (bufferArray.length == bytesToRead)