本文介绍了如何从扬声器获取TargetDataLine?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从发言人那里获得TargetDataLine?我知道如何为麦克风做到这一点,但我无法为扬声器弄清楚.有什么想法吗?

How do you get the TargetDataLine from the Speakers? I know how to do it for Microphones, but I can't figure it out for speakers. Any ideas?

推荐答案

TargetDataLine 用于读取对说话者没有意义的数据.

TargetDataLine is for reading data which does not make sense for speakers.

SourceDataLine 用于将数据发送到扬声器.您可以从 AudioSystem.getLine() Mixer 中获得.

SourceDataLine is used to send data to speakers. You can get this from AudioSystem.getLine() or a Mixer.

您需要 DataLine.Info ,如下所示:

   DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);

audioFormat 是一个AudioFormat实例-您可以从 AudioInputStream 实例 getFormat()调用中获取它,也可以仅构造一个AudioFormat的新实例

audioFormat is an AudioFormat instance - you can get this from an AudioInputStream instance getFormat() call or just construct a new instance of AudioFormat.

这篇关于如何从扬声器获取TargetDataLine?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 18:01