首先,我有一个项目需要在Java中更改WAVE文件的频率。
我使用了Java中的AudioSystem来获取音频数据的字节(不包括文件头)。现在我得到了数据的字节数组,我想把它从时间域转换为频率域,并在操作频率后,将其重新转换为时间域。以下是代码:
public byte[] getWAVByte(){
ByteArrayOutputStream out = new ByteArrayOutputStream();
try{
File f = new File("audio.wav");
AudioInputStream in = AudioSystem.getAudioInputStream(f);
int read;
byte[] buff = new byte[(int)f.length()];
while ((read = in.read(buff)) > 0)
{
out.write(buff, 0, read);
}
out.flush();
byte[] audioBytes = out.toByteArray();
return audioBytes;
}catch(Exception e){
e.printStackTrace();
}
}
现在我有一个音频字节数组audioBytes,我想将它转换为另一个频域字节数组。我读到可以使用傅里叶变换来实现,但我的老师说这非常复杂,而且不在我的项目范围内。那么有没有其他方法可以实现呢?或者有没有Java库可以帮助我获得频域字节数组?