edu.cmu.emulator.signal
Class ScaleFactorWorker
java.lang.Object
edu.cmu.emulator.signal.ScaleFactorWorker
public class ScaleFactorWorker
- extends Object
A simplistic brute force approach to finding the best mult/shift
factors to achieve a given dB gain
Functions for reference (20 because we're doing voltage):
dB = 20 * log(scaleFactor)
scaleFactor = 10^(dB/20)
Constructor Summary |
ScaleFactorWorker(int maxMFBits,
int maxShift,
double minDB,
double maxDB)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
maxMFBits
int maxMFBits
maxShift
int maxShift
minDB
double minDB
maxDB
double maxDB
numDBBins
int numDBBins
val
double[] val
minError
double[] minError
bestMF
int[] bestMF
bestSF
int[] bestSF
bestRawDB
double[] bestRawDB
clipOutOfRange
boolean clipOutOfRange
dbResolution
private static final double dbResolution
- See Also:
- Constant Field Values
invDBResolution
private static final double invDBResolution
- See Also:
- Constant Field Values
MAX_SHIFT
private static final int MAX_SHIFT
- See Also:
- Constant Field Values
SLOP
private static final double SLOP
- See Also:
- Constant Field Values
log
protected Logger log
ScaleFactorWorker
public ScaleFactorWorker(int maxMFBits,
int maxShift,
double minDB,
double maxDB)
setClipOutOfRange
public void setClipOutOfRange(boolean clipOutOfRange)
dbBin
private int dbBin(double db)
searchForMinError
public void searchForMinError()
bitsRequired
private int bitsRequired(int mf,
int sf)
lba
private double lba(double x,
double base)
computeDB
private double computeDB(int multFactor,
int shiftFactor)
computeDB
public double computeDB(double scaleFactor)
getMultFactor
public byte getMultFactor(double db)
getShiftFactor
public byte getShiftFactor(double db)
displayResults
public void displayResults()
displayAvailableDB
public void displayAvailableDB()
isValidDB
public boolean isValidDB(double db,
double errorTolerance)
getDBAbove
public double getDBAbove(double db)
getDBBelow
public double getDBBelow(double db)
main
public static void main(String[] args)
Copyright © 2013. All Rights Reserved.