我需要对声音进行分析,以检查声音是否受到阻碍或删除。
import java.net.URL;
import javax.swing.*;
import javax.sound.sampled.*;
public class LoopSounds {
public static void main(String[] args) throws Exception {
URL url = new URL(
"http://pscode.org/media/leftright.wav");
Clip clip = AudioSystem.getClip();
AudioInputStream ais = AudioSystem.
getAudioInputStream( url );
clip.open(ais);
URL url2 = new URL(
"http://pscode.org/media/100_2817-linear.wav");
Clip clip2 = AudioSystem.getClip();
AudioInputStream ais2 = AudioSystem.
getAudioInputStream( url2 );
clip2.open(ais2);
// loop continuously
clip.loop(Clip.LOOP_CONTINUOUSLY);
clip2.loop(Clip.LOOP_CONTINUOUSLY);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// A GUI element to prevent the Clip's daemon Thread
// from terminating at the end of the main()
JOptionPane.showMessageDialog(null, "Close to exit!");
}
});
}
}
但我会对两个声音进行比较,我需要为我的分析提取数值。
答案 0 :(得分:0)
AudioInputStream有一个read()方法。
您可以制作这样的函数:
DocId DocType Field1 Field2 Field3, etc
1234 A SB/2567 John Doe
5678 B Jane Doe 90210
3456 A ABC/5678 Bobby Lee
注意:只有当这两个.wav文件完全相同时,此功能才有效。