arguments for the filter
This commit is contained in:
parent
ac5121e0d2
commit
507c5f96df
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -1,3 +1,7 @@
|
|||||||
[submodule "third-party/c-flags"]
|
[submodule "third-party/c-flags"]
|
||||||
path = third-party/c-flags
|
path = third-party/c-flags
|
||||||
url = https://github.com/DieTime/c-flags.git
|
url = https://github.com/DieTime/c-flags.git
|
||||||
|
[submodule "third-party/cxxopts"]
|
||||||
|
path = third-party/cxxopts
|
||||||
|
url = https://github.com/jarro2783/cxxopts.git
|
||||||
|
branch = v3.2.1
|
||||||
|
@ -4,7 +4,11 @@ project(pico-radio)
|
|||||||
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
|
||||||
|
|
||||||
include_directories(include /opt/picoscope/include third-party/c-flags/single-header)
|
include_directories(include
|
||||||
|
/opt/picoscope/include
|
||||||
|
third-party/c-flags/single-header
|
||||||
|
third-party/cxxopts/include)
|
||||||
|
|
||||||
link_directories(/opt/picoscope/lib)
|
link_directories(/opt/picoscope/lib)
|
||||||
|
|
||||||
add_subdirectory(src/recorder)
|
add_subdirectory(src/recorder)
|
||||||
|
@ -6,15 +6,30 @@
|
|||||||
#include <filter/filter/low_pass_filter.hpp>
|
#include <filter/filter/low_pass_filter.hpp>
|
||||||
#include <filter/window/hamming_window.hpp>
|
#include <filter/window/hamming_window.hpp>
|
||||||
|
|
||||||
#include <c-flags.h>
|
#include <cxxopts.hpp>
|
||||||
|
|
||||||
const std::size_t BUFFER_SIZE = 256;
|
const std::size_t BUFFER_SIZE = 256;
|
||||||
|
|
||||||
using namespace Filter;
|
using namespace Filter;
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
(void)argc;
|
// parse arguments
|
||||||
(void)argv;
|
cxxopts::Options options("filter", "filter signals; stdin->stdout");
|
||||||
|
options.add_options()("c,cutoff", "Cutoff frequency in Hz.", cxxopts::value<size_t>()->no_implicit_value())("s,sample_rate", "Sample rate of input in Hz.",
|
||||||
|
cxxopts::value<size_t>()->no_implicit_value());
|
||||||
|
|
||||||
|
cxxopts::ParseResult result;
|
||||||
|
try {
|
||||||
|
result = options.parse(argc, argv);
|
||||||
|
} catch (cxxopts::exceptions::exception e) {
|
||||||
|
std::cerr << e.what() << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.count("cutoff") + result.count("sample_rate") != 2) {
|
||||||
|
std::cerr << options.help() << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// prepare pipes for binary data
|
// prepare pipes for binary data
|
||||||
std::freopen(nullptr, "rb", stdin);
|
std::freopen(nullptr, "rb", stdin);
|
||||||
@ -30,7 +45,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create low pass filter
|
// create low pass filter
|
||||||
LowPassFilter lpf(BUFFER_SIZE, 1000, 10000, HammingWindow(BUFFER_SIZE).getWindow());
|
LowPassFilter lpf(BUFFER_SIZE, result["cutoff"].as<std::size_t>(), result["sample_rate"].as<std::size_t>(), HammingWindow(BUFFER_SIZE).getWindow());
|
||||||
|
|
||||||
// read data
|
// read data
|
||||||
std::vector<float> inputBuffer;
|
std::vector<float> inputBuffer;
|
||||||
|
1
third-party/cxxopts
vendored
Submodule
1
third-party/cxxopts
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 4bf61f08697b110d9e3991864650a405b3dd515d
|
Loading…
Reference in New Issue
Block a user