标题基本上讲述了我的故事,我想从 java 程序直接将音频发送到扬声器系统,我想尝试使用从音频文件中获得的字节直接写入 linux 中 /dev/ 中的扬声器,我' 不确定会起作用,但在 Windows 中,我很难过。我在想这样的事情:
public void play(byte[] audio){
if(OS.isWindows){//This is where i have no idea, maybe write to javasound with jmf?
}
if(OS.isLinux){
BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream("/dev/blahblah");
bout.write(audio)
bout.flush();
bout.close();
}
我的代码对我来说似乎很简单,不是我想要复杂的代码,而是我想要工作代码。我实际上没有尝试过上面的代码,因为担心我不知道我在做什么,并且可能会伤害或中断我的电脑中的某些东西。