public KeyFrequency(int f, int c, int rad, double[] indata, int center, int priori)
{
this.frequency = f;
this.channel = c;
this.radius = rad;
this.data = new double[radius * 2 + 1];
//rescale data to 0.0 to 1.0, to remove volume depencies.
double min = Double.PositiveInfinity;
double max = Double.NegativeInfinity;
for (int i = 0; i < this.data.Length; i++)
{
this.data[i] = indata[center - rad + i];
if (this.data[i] < min)
min = this.data[i];
}
for (int i = 0; i < this.data.Length; i++)
{
this.data[i] -= min;
if (this.data[i] > max)
max = this.data[i];
}
for (int i = 0; i < this.data.Length; i++)
this.data[i] /= max;
isBoth = false;
inverse_state = 0;
//semi standard speaker positions that work for a generic laptop and home theatre.
switch (c)
{
case 1:
speakerTheta = 55;
speakerAltitude = -10;
break;
case 2:
speakerTheta = -55;
speakerAltitude = -10;
break;
case 3:
speakerTheta = 0;
speakerAltitude = -10;
break;
case 4:
speakerTheta = 0;
speakerAltitude = 0;
break;
case 5:
speakerTheta = 110;
speakerAltitude = 30;
break;
case 6:
speakerTheta = -110;
speakerAltitude = 30;
break;
}
this.prior = priori;
//After creating storing the data, determine the bandwidth shift of the speaker
state = this.classify();
}