在Java中简单的Wav比较 [英] Simple Wav comparison in Java

查看:240
本文介绍了在Java中简单的Wav比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎有东西,似乎很琐碎一个巨大的问题。

I seem to be having a huge problem with something that seems very trivial.

目标:尝试比较两个WAV文件查看是否有(小文件)是其他(大文件)的一部分

Goal: Try to compare two Wav files and see if one(small file) is part of the other(large file).

测试:首先,我花了1分钟长一段音频,并远销它30秒到另一个文件。我第一次尝试只需在字节[]数据读取,并通过日志,看看它,但绝对没有关系,即使他们都来自同一个源文件?然后,我用库,如WavFile和MusicG尝试,但我根本无法看到两个指纹之间有任何相关性,甚至是原始字节[]数据出来的两个文件?

Test: First, I took a 1 minute long piece of audio and exported 30 seconds of it to another file. I first tried to simply read in the byte[] data and look at it via logs, and there's absolutely no correlation even though they are both from the same source file? I then tried using libraries such as WavFile, and MusicG but I simply can't see any correlation between the two "fingerprints" or even the raw byte[] data that comes out of the two files?

什么是分析的相似性这两个文件的Wav最简单的方法我看过周围,如果他们来自何处相同的源的音频文件他们应该是字节字节相同的。因此,采取每个样品,他们应该是一样的吗?这不是发生了什么事?

Question: What is the simplest way to analyze these two Wav files for similarities? I have read around that if they're from the same source audio file they should be byte-byte identical. Thus take sample of each and they should be the same? That's NOT what is happening?

现在我已经搜查了不少针对这个问题,但几乎所有的答案都只有25-50%完成,所以我觉得我缺少一个巨大的细分的地方。

Now I have already searched quite a bit for this problem but almost all answers are only 25-50% complete so I feel like I'm missing a huge segment somewhere.

感谢您为您可能提供的解决方案!

Thank you for any solutions that you may offer!

源音频文件只是一个1分钟的Wav文件......这是我从提取创建更小的文件的第一个30秒。然后,我比较短(30秒)长(1分钟)。我在1141kbps,16位,WAV出口均来自勇气。这是要尽量避免的格式问题...我想

The source audio file is just a 1 minutes Wav file... which I extracted the first 30 seconds from to create the smaller file. Then I compare the short(30 seconds) to the long(1 minute). I exported both from Audacity at 1141kbps, 16bit, Wav. This was to try to avoid formatting issues... I Thought

有关code看看这个没有答案的问题:的Wav比较,相同的文件

For code look at this UNANSWERED question: Wav comparison, same file

推荐答案

有一些奇怪的事情怎么回事。没有进入细节,我只想说,当一些程序做一个简单的操作就像你所称之为萃取,他们没有做精确副本。 Libsndfile,例如,没有透明的从int声音文件会浮动(这是什么无畏内部使用)回INT时转换。如果使用的Audacity libsndfile(我pretty肯定它),它不会使文件的透明拷贝,所以你的方法是行不通的。例如:请尝试以下操作:打开一个wav文件,使用相同的参数导出。使用diff进行比较的输入和输出。在所有的可能性,它们将是不同的。欲了解更多详情请看这里:的http:/ /blog.bjornroche.com/2009/12/int-float-int-its-jungle-out-there.html

There are some odd things going on here. Without going into detail, I will just say that when some programs do a simple operation like what you are calling "extraction", they are not making exact copies. Libsndfile, for example, does not convert transparently when going from int sound files to float (which what Audacity uses internally) back to int. If Audacity uses libsndfile (I'm pretty sure it does), it won't make transparent copies of files, so your method won't work. eg: try the following: open a wav file, export it using the same parameters. Use diff to compare the input and output. In all likelihood, they will be different. For more details see here: http://blog.bjornroche.com/2009/12/int-float-int-its-jungle-out-there.html

libsndfile的笔者在这里捍卫自己的设计决定: HTTP:// WWW。 mega-nerd.com/libsndfile/FAQ.html#Q010

The author of libsndfile defends his design decision here: http://www.mega-nerd.com/libsndfile/FAQ.html#Q010

您可以尝试其他的应用程序,但我怀疑你希望当人们使用这个大言不惭甚至工作。

You could try another app, but I suspect you want this to work even when people use audacity.

其中的意见建议的互相关。你也可以使用音频指纹。这两种解决方案都有些复杂,虽然

One of the comments suggested cross-correlation. You could also use audio fingerprinting. Both of these solutions are somewhat complex, though.

可能的最简单的解决方法是在本机格式来读取数据。例如,如果文件是16位,则读16位整数(而不是字节)。然后,它比较的短,但是比较允许一些错误(从我的头顶,我是pretty确保您永远不应该由一个以上的被关闭,但是这是每一个它通过大胆的时间) 。因此,与其问这些值等于你要问是彼此的小量内这些价值观。当然对于事情有很多的沉默在其中,你会想做出一些异常。

Probably the simplest solution is to read data in the native format. For example, if the file is 16 bit, then read 16-bit ints (not bytes). Then compare it against the shorter one, but compare allowing some error (off the top of my head, I am pretty sure you should never be off by more than one, but that's for each and every time it goes through audacity). So instead of asking "are these values equal" you'll have to ask "are these values within epsilon of each other." Of course for things with lots of silence in them, you'll want to make some sort of exception.

这也可能是大言不惭使用抖动,因此要确保的关闭。抖动可以添加显著噪音,所以如果你想与工作入方程式,你需要不同的解决方案。

It is also possible that audacity is using dither, so make sure that's switched off. Dither can add significant noise, so if you want to work with that into equation you'll need a different solution.

这篇关于在Java中简单的Wav比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆