-
Notifications
You must be signed in to change notification settings - Fork 38
/
mpx.cc
49 lines (38 loc) · 1.24 KB
/
mpx.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <sstream>
#include <vector>
#include <catch2/catch_test_macros.hpp>
#include <nlohmann/json.hpp>
#include "../src/dsp/subcarrier.h"
#include "../src/input.h"
#include "../src/options.h"
#include "test_helpers.h"
TEST_CASE("MPX file input") {
redsea::Options options;
options.sndfilename = "../test/resources/mpx-testfile-yksi.flac";
options.input_type = redsea::InputType::MPX_sndfile;
std::vector<nlohmann::ordered_json> json;
redsea::MPXReader mpx;
mpx.init(options);
options.samplerate = mpx.getSamplerate();
options.num_channels = mpx.getNumChannels();
std::stringstream json_stream;
redsea::Channel channel(options, 0, json_stream);
redsea::Subcarrier subcarrier(57000.f, options.samplerate);
while (!mpx.eof()) {
mpx.fillBuffer();
const auto bits = subcarrier.processChunk(mpx.readChunk(0));
for (const auto& bit : bits.bits) {
channel.processBit(bit);
if (!json_stream.str().empty()) {
nlohmann::ordered_json jsonroot;
json_stream >> jsonroot;
json.push_back(jsonroot);
json_stream.str("");
json_stream.clear();
}
}
}
CHECK(json.size() == 1);
CHECK(json.at(0)["pi"] == "0x6201");
CHECK(json.at(0)["prog_type"] == "Serious classical");
}