Skip to content

Commit

Permalink
Gotta get that syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Kefta authored Dec 1, 2016
1 parent 5c14cc4 commit 9434f0f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Tuner.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ static double getFrequency(int rate, int size, int count, short[] buffer)
int sample = 0;
int len = condensed.length / 2;

for (int i = 0; i < len; i++) {
for (int i = 0; i < len; i++)
{
double dist = 0;

for (int j = 0; j < len; j++)
{
// Compare the base wave with one offset by horizontal translation i
// Compare the base wave peak with one offset by horizontal translation i
dist += Math.abs(condensed[j] - condensed[i + j]);
}

Expand All @@ -43,19 +44,21 @@ static double getFrequency(int rate, int size, int count, short[] buffer)
maxDist = Math.max(dist, maxDist);
}

// If we have a valid frequency, put it in a single octave range
if (sample > 0)
{
double frequency = (rate/sample);
//Log.d("Calculator", String.format("%.2fhz",frequency));

// Put hz into an octave range
// A4
while (frequency < 440) {
// A4 - low end
while (frequency < 440)
{
frequency *= 2;
}

// A5
while (frequency > 880) {
// A5 - high end
while (frequency > 880)
{
frequency /= 2;
}

Expand Down

0 comments on commit 9434f0f

Please sign in to comment.