我正在尝试用java录音。而质量并不好。虽然在房间里完全相当,但仍有连续的噪音。有没有机会去除/过滤噪音?
我在廉价的Android手机和一些录音应用程序上发现了同样的问题。看起来这是录音的一般问题
package test;
import javax.sound.sampled.*;
import java.io.*;
public class Tmp {
AudioFileFormat.Type fileType = AudioFileFormat.Type.WAVE;
AudioFormat getAudioFormat() {
float sampleRate = 44100;
int sampleSizeInBits = 16;
int channels = 1;
boolean signed = true;
boolean bigEndian = true;
AudioFormat format = new AudioFormat(sampleRate, sampleSizeInBits,
channels, signed, bigEndian);
return format;
}
void start(String n) {
TargetDataLine line;
File f = new File(n);
try {
AudioFormat format = getAudioFormat();
DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
line = (TargetDataLine) AudioSystem.getLine(info);
line.open(format);
line.start();
AudioInputStream ais = new AudioInputStream(line);
AudioSystem.write(ais, fileType, f);
} catch (LineUnavailableException | IOException ex) {
System.out.println(ex);
}
}
}