fdmffingerprintconfig.java
来自「dump3 morpheus 0.2.9 src」· Java 代码 · 共 229 行
JAVA
229 行
/**
* DuMP3 version morpheus_0.2.9 - a duplicate/similar file finder in Java<BR>
* Copyright 2005 Alexander Grässer<BR>
* All Rights Reserved, http://dump3.sourceforge.net/<BR>
* <BR>
* This file is part of DuMP3.<BR>
* <BR>
* DuMP3 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later version.<BR>
* <BR>
* DuMP3 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.<BR>
* <BR>
* You should have received a copy of the GNU General Public License along with DuMP3; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.za.grasser.duplicate.fingerprint.configure;
import java.beans.PropertyVetoException;
import net.za.grasser.duplicate.Configure;
import net.za.grasser.duplicate.fingerprint.FdmfFingerprint;
import net.za.grasser.duplicate.util.fft.FFT;
import org.apache.log4j.Logger;
/**
* @author <a href="http://sourceforge.net/sendmessage.php?touser=733840">pyropunk at sourceforge dot net</a>
* @version $Revision: 1.8 $
*/
public class FdmfFingerprintConfig extends FingerprintConfig {
/**
* <code>serialVersionUID</code> FdmfFingerprintConfig.java -
*/
private static final long serialVersionUID = -1603772768877742066L;
/**
* <code>log</code> FdmfFingerprintConfig -
*/
private static final Logger log = Logger.getLogger(FdmfFingerprintConfig.class);
/**
* <code>fc</code> FdmfFingerprintConfig -
*/
private static FingerprintConfig fc = null;
/**
* <code>scaling_alg</code> FdmfFingerprintConfig - scaling algorithm
*/
private int windowType = FdmfFingerprint.WINDOW_RECTANGULAR;
/**
* <code>alpha</code> FdmfFingerprintConfig - modifier for Raised Cosine and Kaiser windows
*/
private double alpha = 5.0;
/**
* <code>window</code> FdmfFingerprintConfig - actual precalculated window values according to windowType
*/
private double[] window;
/**
* <code>windowTypes</code> FdmfFingerprintConfig -
*/
private final String[] windowTypes = {
"RECTANGULAR", "HAMMING", "HANNING", "RAISED COSINE", "BARTLETT", "WELCH", "KAISER"
};
/**
* This class ...
*
* @author <a href="http://sourceforge.net/sendmessage.php?touser=733840">pyropunk at sourceforge dot net</a>
* @version $Revision: 1.8 $
*/
static class Factory extends ConfigFactory {
/**
* @see net.za.grasser.duplicate.fingerprint.configure.ConfigFactory#create()
*/
@Override
protected FingerprintConfig create() {
return FdmfFingerprintConfig.getInstance();
}
}
static {
ConfigFactory.addFactory(FdmfFingerprintConfig.class.getSimpleName(), new Factory());
}
/**
*
*/
private FdmfFingerprintConfig() {
super();
Configure.load();
// configure
try {
setSimilarityThreshhold((float)Configure.getDoubleProperty("similarity threshhold", 75.0, FdmfFingerprint.class.getName()));
} catch (final PropertyVetoException e) {
log.warn("Could not set similarity threshhold.", e);
}
setWindowType(Configure.getProperty("window", "RECTANGULAR", FdmfFingerprint.class.getName()));
}
/**
* @return FingerprintConfig
*/
public final static FingerprintConfig getInstance() {
if (fc == null) {
fc = new FdmfFingerprintConfig();
}
return fc;
}
/**
* @return int - Returns the current window type.
*/
public int getWindowType() {
return windowType;
}
/**
* @return int - Returns the list of window types.
*/
public String[] getWindowTypes() {
return windowTypes;
}
/**
* Sets the windowType to the translated value of pWindowType.
*
* @param pWindowType int - The new value.
*/
public void setWindowType(final String pWindowType) {
final String win = pWindowType.toUpperCase();
if (win.startsWith("HAM")) {
windowType = FdmfFingerprint.WINDOW_HAMMING;
} else if (win.startsWith("HAN")) {
windowType = FdmfFingerprint.WINDOW_HANNING;
} else if (win.startsWith("RAI")) {
windowType = FdmfFingerprint.WINDOW_RAISED_COSINE;
setAlpha(Configure.getDoubleProperty("alpha", 0.5, FdmfFingerprint.class.getName()));
} else if (win.startsWith("BAR") || win.startsWith("TRI")) {
windowType = FdmfFingerprint.WINDOW_BARTLETT;
} else if (win.startsWith("WEL")) {
windowType = FdmfFingerprint.WINDOW_WELCH;
} else if (win.startsWith("KAI")) {
windowType = FdmfFingerprint.WINDOW_KAISER;
setAlpha(Configure.getDoubleProperty("alpha", alpha, FdmfFingerprint.class.getName()));
} else {
windowType = FdmfFingerprint.WINDOW_RECTANGULAR;
}
window = makeWindow(FdmfFingerprint.CHUNK_SAMPLES);
}
/**
* Sets the windowType to the value of pType
*
* @param pType
*/
public void setWindowType(final int pType) {
windowType = pType;
}
/**
* @return double
*/
public double getAlpha() {
return alpha;
}
/**
* @param pAlpha
*/
public void setAlpha(final double pAlpha) {
alpha = pAlpha;
}
/**
* @return double[]
*/
public double[] getWindow() {
return window;
}
/**
* Creates a windowType table acording tot he windowType definition set up.
*
* @param length
* @return the windowType table.
*/
public double[] makeWindow(final int length) {
double[] d = null;
switch (windowType) {
default:
case FdmfFingerprint.WINDOW_RECTANGULAR:
break;
case FdmfFingerprint.WINDOW_HAMMING:
d = FFT.setupHammingWindow(length);
break;
case FdmfFingerprint.WINDOW_HANNING:
d = FFT.setupHanningWindow(length);
break;
case FdmfFingerprint.WINDOW_RAISED_COSINE:
d = FFT.setupRaisedCosineWindow(length, alpha);
break;
case FdmfFingerprint.WINDOW_BARTLETT:
d = FFT.setupBartlettWindow(length);
break;
case FdmfFingerprint.WINDOW_WELCH:
d = FFT.setupWelchWindow(length);
break;
case FdmfFingerprint.WINDOW_KAISER:
d = FFT.setupKaiserWindow(length, alpha);
break;
}
return d;
}
/**
* @see net.za.grasser.duplicate.fingerprint.configure.FingerprintConfig#getFingerprintDescription()
*/
@Override
public String getFingerprintDescription() {
return "Runs a Fourier transform on the wave data and generates a bit sequence."
+ " Files are condsidered duplicate if more than the set percentage of bits are the same."
+ " A Java implementation of <a href=\"http://www.w140.com/audio/\">fdmf</a> by Thomas Jarosch.";
}
/**
* @see net.za.grasser.duplicate.fingerprint.configure.FingerprintConfig#getFingerprintName()
*/
@Override
public String getFingerprintName() {
return "Find Duplicate Music Files Fingerprint";
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?