The read method returns the number of bytes that were actually read into your array. In this example, the third argument is simply the length of your byte array. The read method of TargetDataLine takes three arguments: a byte array, an offset into the array, and the number of bytes of input data that you would like to read. By using some fraction of the line's buffer size, as shown here, your application will be more successful in sharing access to the line's buffer with the mixer. If you instead make it as big as the line's buffer and try to read the entire buffer, you need to be very exact in your timing, because data will be dumped if the mixer needs to deliver data to the line while you are reading from it. Notice that in this example, the size of the byte array into which the data is read is set to be one-fifth the size of the line's buffer. NumBytesRead = line.read(data, 0, data.length) Read the next chunk of data from the TargetDataLine. Here, stopped is a global boolean set by another thread. Assume that the TargetDataLine, line, has alreadyīyteArrayOutputStream out = new ByteArrayOutputStream() īyte data = new byte The process of obtaining a target data line was described inĪccessing Audio System Resources but we repeat it here for convenience: An available method to determine how much data can be read from the buffer without blocking.A read method to get audio from the mixer.An available method to determine how much data can be written to the buffer without blocking.A write method to send audio to the mixer.Recall that the SourceDataLine interface consists of: TargetDataLine is directly analogous to the SourceDataLine interface, which was discussed extensively in The TargetDataLine interface was introduced briefly under Another scenario consists of a mixer that has no ports but instead gets its audio input over a network.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |