Added formatter file
This commit is contained in:
parent
b37ce97c4e
commit
477b425043
|
@ -0,0 +1,211 @@
|
|||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: Chromium
|
||||
AccessModifierOffset: 0
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveMacros: None
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveBitFields: None
|
||||
AlignConsecutiveDeclarations: None
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: true
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 80
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^<ext/.*\.h>'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^<.*\.h>'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^<.*'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentAccessModifiers: true
|
||||
IndentCaseLabels: true
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentRequires: false
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertTrailingCommas: None
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
LambdaBodyIndentation: Signature
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Never
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 1
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 200
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PointerAlignment: Left
|
||||
PPIndentWidth: -1
|
||||
RawStringFormats:
|
||||
- Language: Cpp
|
||||
Delimiters:
|
||||
- cc
|
||||
- CC
|
||||
- cpp
|
||||
- Cpp
|
||||
- CPP
|
||||
- 'c++'
|
||||
- 'C++'
|
||||
CanonicalDelimiter: ''
|
||||
BasedOnStyle: google
|
||||
- Language: TextProto
|
||||
Delimiters:
|
||||
- pb
|
||||
- PB
|
||||
- proto
|
||||
- PROTO
|
||||
EnclosingFunctions:
|
||||
- EqualsProto
|
||||
- EquivToProto
|
||||
- PARSE_PARTIAL_TEXT_PROTO
|
||||
- PARSE_TEST_PROTO
|
||||
- PARSE_TEXT_PROTO
|
||||
- ParseTextOrDie
|
||||
- ParseTextProtoOrDie
|
||||
- ParseTestProto
|
||||
- ParsePartialTestProto
|
||||
CanonicalDelimiter: pb
|
||||
BasedOnStyle: google
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: true
|
||||
ShortNamespaceLines: 1
|
||||
SortIncludes: CaseSensitive
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: Never
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
BitFieldColonSpacing: Both
|
||||
Standard: Auto
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 4
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
WhitespaceSensitiveMacros:
|
||||
- STRINGIZE
|
||||
- PP_STRINGIZE
|
||||
- BOOST_PP_STRINGIZE
|
||||
- NS_SWIFT_NAME
|
||||
- CF_SWIFT_NAME
|
||||
...
|
|
@ -13,4 +13,10 @@ LDFLAGS=-lliquid
|
|||
clean:
|
||||
rm *.o
|
||||
|
||||
format:
|
||||
clang-format -i *.h *.cpp
|
||||
|
||||
|
||||
include .depends
|
||||
|
||||
.PHONY: clean fmt
|
||||
|
|
|
@ -1,26 +1,30 @@
|
|||
#include "costas-beacon-sync.h"
|
||||
|
||||
#include<cmath>
|
||||
#include <liquid/liquid.h>
|
||||
|
||||
const size_t banpass_len = 47;
|
||||
|
||||
// 512000 ksps, pass end 10kHz, stop start 25khz, 40dB
|
||||
float bandpass_taps[banpass_len] = {
|
||||
0.0023692550603300333,0.002578944666311145,0.003062514355406165,0.0038352811243385077,
|
||||
0.004904961679130793,0.00627117557451129,0.007925170473754406,0.009849807247519493,
|
||||
0.012019773945212364,0.014402060769498348,0.016956664621829987,0.01963750831782818,
|
||||
0.022393573075532913,0.025170154869556427,0.027910303324460983,0.03055628389120102,
|
||||
0.03305114805698395,0.03534023091197014,0.03737267851829529,0.039102789014577866,
|
||||
0.04049133509397507,0.04150659218430519,0.04212525859475136,0.042333073914051056,
|
||||
0.04212525859475136,0.04150659218430519,0.04049133509397507,0.039102789014577866,
|
||||
0.03737267851829529,0.03534023091197014,0.03305114805698395,0.03055628389120102,
|
||||
0.027910303324460983,0.025170154869556427,0.022393573075532913,0.01963750831782818,
|
||||
0.016956664621829987,0.014402060769498348,0.012019773945212364,0.009849807247519493,
|
||||
0.007925170473754406,0.00627117557451129,0.004904961679130793,0.0038352811243385077,
|
||||
0.003062514355406165,0.002578944666311145,0.0023692550603300333};
|
||||
0.0023692550603300333, 0.002578944666311145, 0.003062514355406165,
|
||||
0.0038352811243385077, 0.004904961679130793, 0.00627117557451129,
|
||||
0.007925170473754406, 0.009849807247519493, 0.012019773945212364,
|
||||
0.014402060769498348, 0.016956664621829987, 0.01963750831782818,
|
||||
0.022393573075532913, 0.025170154869556427, 0.027910303324460983,
|
||||
0.03055628389120102, 0.03305114805698395, 0.03534023091197014,
|
||||
0.03737267851829529, 0.039102789014577866, 0.04049133509397507,
|
||||
0.04150659218430519, 0.04212525859475136, 0.042333073914051056,
|
||||
0.04212525859475136, 0.04150659218430519, 0.04049133509397507,
|
||||
0.039102789014577866, 0.03737267851829529, 0.03534023091197014,
|
||||
0.03305114805698395, 0.03055628389120102, 0.027910303324460983,
|
||||
0.025170154869556427, 0.022393573075532913, 0.01963750831782818,
|
||||
0.016956664621829987, 0.014402060769498348, 0.012019773945212364,
|
||||
0.009849807247519493, 0.007925170473754406, 0.00627117557451129,
|
||||
0.004904961679130793, 0.0038352811243385077, 0.003062514355406165,
|
||||
0.002578944666311145, 0.0023692550603300333};
|
||||
|
||||
CostasBeaconSync::CostasBeaconSync(float agc_bw, float loop_bw, float min_freq, float max_freq) {
|
||||
CostasBeaconSync::CostasBeaconSync(float agc_bw,
|
||||
float loop_bw,
|
||||
float min_freq,
|
||||
float max_freq) {
|
||||
this->min_freq = min_freq;
|
||||
this->max_freq = max_freq;
|
||||
|
||||
|
@ -32,20 +36,19 @@ CostasBeaconSync::CostasBeaconSync(float agc_bw, float loop_bw, float min_freq,
|
|||
loop_freq = 0.0;
|
||||
loop_phase = 0.0;
|
||||
|
||||
bandpass = firfilt_crcf_create(bandpass_taps,banpass_len);
|
||||
bandpass = firfilt_crcf_create(bandpass_taps, banpass_len);
|
||||
|
||||
agc = agc_crcf_create();
|
||||
agc_crcf_set_bandwidth(agc, agc_bw);
|
||||
}
|
||||
|
||||
|
||||
std::complex<float> CostasBeaconSync::work(std::complex<float> in) {
|
||||
|
||||
std::complex<float> filtered;
|
||||
firfilt_crcf_push(bandpass, in); // push input sample
|
||||
firfilt_crcf_execute(bandpass,&filtered);
|
||||
firfilt_crcf_push(bandpass, in); // push input sample
|
||||
firfilt_crcf_execute(bandpass, &filtered);
|
||||
|
||||
std::complex<float> out = std::complex<float>(cos(-loop_phase),sin(-loop_phase));
|
||||
std::complex<float> out =
|
||||
std::complex<float>(cos(-loop_phase), sin(-loop_phase));
|
||||
|
||||
agc_crcf_execute(agc, filtered, &filtered);
|
||||
|
||||
|
@ -56,15 +59,15 @@ std::complex<float> CostasBeaconSync::work(std::complex<float> in) {
|
|||
loop_freq += beta * error;
|
||||
loop_phase += loop_freq + alpha * error;
|
||||
|
||||
while(loop_phase > (2 * M_PI))
|
||||
while (loop_phase > (2 * M_PI))
|
||||
loop_phase -= 2 * M_PI;
|
||||
while(loop_phase < (-2 * M_PI))
|
||||
while (loop_phase < (-2 * M_PI))
|
||||
loop_phase += 2 * M_PI;
|
||||
|
||||
if(loop_freq > max_freq)
|
||||
if (loop_freq > max_freq)
|
||||
loop_freq = max_freq;
|
||||
else if(loop_freq < min_freq)
|
||||
else if (loop_freq < min_freq)
|
||||
loop_freq = min_freq;
|
||||
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _COSTAS_
|
||||
|
||||
#include <complex>
|
||||
|
||||
#include <liquid/liquid.h>
|
||||
|
||||
class CostasBeaconSync {
|
||||
|
@ -25,5 +26,4 @@ class CostasBeaconSync {
|
|||
std::complex<float> work(liquid_float_complex);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,52 +6,53 @@ FFTBeaconFinder::FFTBeaconFinder(int samplingrate) {
|
|||
coarse_correction = nco_crcf_create(LIQUID_NCO);
|
||||
nco_crcf_set_frequency(coarse_correction, 0.0f);
|
||||
|
||||
fft = fft_create_plan(FFT_LEN, fft_in, fft_out,
|
||||
LIQUID_FFT_FORWARD, 0);
|
||||
fft = fft_create_plan(FFT_LEN, fft_in, fft_out, LIQUID_FFT_FORWARD, 0);
|
||||
|
||||
pos = 0;
|
||||
next_fft_in = 0;
|
||||
}
|
||||
|
||||
std::complex<float> FFTBeaconFinder::work(std::complex<float> in) {
|
||||
if(next_fft_in <= 0) {
|
||||
if (next_fft_in <= 0) {
|
||||
fft_in[pos] = in;
|
||||
pos += 1;
|
||||
if(pos == FFT_LEN) {
|
||||
if (pos == FFT_LEN) {
|
||||
pos = 0;
|
||||
fft_execute(fft);
|
||||
|
||||
float fft_max = std::abs(fft_out[0]);
|
||||
for(int i = 0; i < FFT_LEN; i++) {
|
||||
for (int i = 0; i < FFT_LEN; i++) {
|
||||
float mag = std::abs(fft_out[i]);
|
||||
if(mag > fft_max) {
|
||||
if (mag > fft_max) {
|
||||
fft_max = mag;
|
||||
}
|
||||
}
|
||||
|
||||
float max_levels = 0;
|
||||
int max_center = 0;
|
||||
for(int bin = -50; bin <= 50; bin++) {
|
||||
for (int bin = -50; bin <= 50; bin++) {
|
||||
int center_idx = spectral_bin_to_fft_idx(bin);
|
||||
float center_val = std::abs(fft_out[center_idx]) / fft_max;
|
||||
if(center_val > 0.25) {
|
||||
if (center_val > 0.25) {
|
||||
printf("Found peak candidate at %d\n", bin);
|
||||
int left_idx = spectral_bin_to_fft_idx(bin - 127);
|
||||
int right_idx = spectral_bin_to_fft_idx(bin + 127);
|
||||
float left_val = std::abs(fft_out[left_idx]) / fft_max;
|
||||
float right_val = std::abs(fft_out[right_idx]) / fft_max;
|
||||
|
||||
if(center_val + left_val + right_val > max_levels) {
|
||||
if (center_val + left_val + right_val > max_levels) {
|
||||
max_levels = center_val + left_val + right_val;
|
||||
max_center = bin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(max_levels > 0.0) {
|
||||
if (max_levels > 0.0) {
|
||||
float center_freq = max_center * samplingrate / FFT_LEN;
|
||||
printf("Found center at %f\n", center_freq);
|
||||
nco_crcf_set_frequency(coarse_correction, -(2 * M_PI * center_freq) / samplingrate);
|
||||
nco_crcf_set_frequency(
|
||||
coarse_correction,
|
||||
-(2 * M_PI * center_freq) / samplingrate);
|
||||
}
|
||||
|
||||
next_fft_in = samplingrate / 4;
|
||||
|
@ -69,11 +70,10 @@ std::complex<float> FFTBeaconFinder::work(std::complex<float> in) {
|
|||
return y * in;
|
||||
}
|
||||
|
||||
|
||||
int FFTBeaconFinder::spectral_bin_to_fft_idx(int bin) {
|
||||
if(bin == 0) {
|
||||
return FFT_LEN/2;
|
||||
} else if(bin > 0) {
|
||||
if (bin == 0) {
|
||||
return FFT_LEN / 2;
|
||||
} else if (bin > 0) {
|
||||
return bin - 1;
|
||||
} else {
|
||||
return bin + FFT_LEN;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _FFT_BEACON_FINDER_
|
||||
|
||||
#include <complex>
|
||||
|
||||
#include <liquid/liquid.h>
|
||||
|
||||
const size_t FFT_LEN = 512;
|
||||
|
@ -20,12 +21,11 @@ class FFTBeaconFinder {
|
|||
int next_fft_in;
|
||||
|
||||
int spectral_bin_to_fft_idx(int);
|
||||
|
||||
|
||||
public:
|
||||
FFTBeaconFinder(int);
|
||||
|
||||
std::complex<float> work(std::complex<float>);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue