Basically you have to create an InputStream from your array and use that to create an AudioInputStream. There you have to specify the format of your audio data.
Then you open an output stream (SourceDataLine) and copy the bytes from the audio stream into that stream.
发布评论
评论(1)
使用 javax.sound.sampled< /a> 包非常简单,但是您必须使用一些样板文件。
这是一个很好的教程: www.wikijava.org/wiki/Play_a_wave_sound_in_Java
基本上你必须从数组创建一个
InputStream
并使用它来创建一个AudioInputStream
。 您必须在此处指定音频数据的格式。然后打开一个输出流 (
SourceDataLine
) 并将字节从音频流复制到该流中。With the javax.sound.sampled package it's pretty much straightforward, but you have to use some boilerplate.
Here's a good tutorial on that: www.wikijava.org/wiki/Play_a_wave_sound_in_Java
Basically you have to create an
InputStream
from your array and use that to create anAudioInputStream
. There you have to specify the format of your audio data.Then you open an output stream (
SourceDataLine
) and copy the bytes from the audio stream into that stream.