edu.cmu.emulator.signal
Class ScaleFactorWorker

java.lang.Object
  extended by 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)


Field Summary
(package private)  int[] bestMF
           
(package private)  double[] bestRawDB
           
(package private)  int[] bestSF
           
(package private)  boolean clipOutOfRange
           
private static double dbResolution
           
private static double invDBResolution
           
protected  Logger log
           
private static int MAX_SHIFT
           
(package private)  double maxDB
           
(package private)  int maxMFBits
           
(package private)  int maxShift
           
(package private)  double minDB
           
(package private)  double[] minError
           
(package private)  int numDBBins
           
private static double SLOP
           
(package private)  double[] val
           
 
Constructor Summary
ScaleFactorWorker(int maxMFBits, int maxShift, double minDB, double maxDB)
           
 
Method Summary
private  int bitsRequired(int mf, int sf)
           
 double computeDB(double scaleFactor)
           
private  double computeDB(int multFactor, int shiftFactor)
           
private  int dbBin(double db)
           
 void displayAvailableDB()
           
 void displayResults()
           
 double getDBAbove(double db)
           
 double getDBBelow(double db)
           
 byte getMultFactor(double db)
           
 byte getShiftFactor(double db)
           
 boolean isValidDB(double db, double errorTolerance)
           
private  double lba(double x, double base)
           
static void main(String[] args)
           
 void searchForMinError()
           
 void setClipOutOfRange(boolean clipOutOfRange)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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
Constructor Detail

ScaleFactorWorker

public ScaleFactorWorker(int maxMFBits,
                         int maxShift,
                         double minDB,
                         double maxDB)
Method Detail

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.