Skip to content

Commit

Permalink
Fixed bandpass width calculation for the start and end message detect…
Browse files Browse the repository at this point in the history
…ion. Added a test
  • Loading branch information
aringot committed Dec 16, 2019
1 parent 1038bd8 commit 4733357
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,21 @@ public interface SpectrumListener {
this.startFactor = startFactor;
this.endFactor = endFactor;

bandpassWidth = DecoderUtils.getBandpassWidth(nFrequencies, frequencySpace);

//Log.d("AllSettings", "silentmode: " + String.valueOf(silentMode) + " f0: " + f0 + " bitperiod: " + bitperiod + " pauseperiod: " + pauseperiod + " maxChar: " + nMaxCharacters + " nFreq: " + nFrequencies + " freqSpacing: " + frequencySpace + " freqOffSpec: " + frequencyOffsetForSpectrogram + " stepFactor: " + stepFactor);
/*Log.d("AllSettings", "silentmode: " + String.valueOf(this.silentMode));
Log.d("AllSettings", "f0: " + f0);
Log.d("AllSettings", "bitperiod: " + bitperiod);
Log.d("AllSettings", "pauseperiod: " + pauseperiod);
Log.d("AllSettings", "maxChar: " + nMaxCharacters);
//Log.d("AllSettings", "maxChar: " + this.config.);
Log.d("AllSettings", "nFreq: " + nFrequencies);
Log.d("AllSettings", "freqSpacing: " + frequencySpace);
Log.d("AllSettings", "freqOffSpec: " + this.frequencyOffsetForSpectrogram);
Log.d("AllSettings", "stepFactor: " + this.stepFactor);
Log.d("AllSettings", "bandpassWidth: " + this.bandpassWidth);
*/

bandpassWidth = frequencySpace *(nFrequencies /2);

winLenForSpectrogram = bitperiod;
winLenForSpectrogramInSamples = Math.round(Fs * (float) winLenForSpectrogram/1000);
if (winLenForSpectrogramInSamples % 2 != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,8 @@ public static double getComplexAbsolute(double real, double imaginary) {
}


public static int getBandpassWidth(int nFrequencies, int frequencySpace) {
return (int) Math.round((frequencySpace * (nFrequencies-1)) / 2.0);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,11 @@ public void nextPowerOfTwo() throws Exception {
assertEquals(64, DecoderUtils.nextPowerOfTwo(64));
assertEquals(4096, DecoderUtils.nextPowerOfTwo(2205));
}

@Test
public void bandpassWidth() throws Exception {
assertEquals(750, DecoderUtils.getBandpassWidth(16, 100));
assertEquals(350, DecoderUtils.getBandpassWidth(8, 100));
assertEquals(375, DecoderUtils.getBandpassWidth(16, 50));
}
}

0 comments on commit 4733357

Please sign in to comment.