SatDump 2.0.0-alpha-520736c72
Loading...
Searching...
No Matches
block_helpers.h
1#pragma once
2
3#include "block.h"
4#include "common/dsp/complex.h"
5#include <memory>
6
7namespace satdump
8{
9 namespace ndsp // TODOREWORK back to normal DSP!
10 {
12 {
13 std::string id;
14 std::vector<std::shared_ptr<Block>> &blk;
15 };
16
17 // TODOREWORK cleanup!!!!
18 template <typename T>
19 std::string getShortTypeName()
20 {
21 if (std::is_same_v<T, complex_t>)
22 return "c";
23 else if (std::is_same_v<T, float>)
24 return "f";
25 else if (std::is_same_v<T, int16_t>)
26 return "s";
27 else if (std::is_same_v<T, int8_t>)
28 return "h";
29 else if (std::is_same_v<T, uint8_t>)
30 return "b";
31 else
32 throw satdump_exception("Invalid type for DSP blocks!");
33 }
34
35 template <typename T>
36 BlockIOType getTypeSampleType()
37 {
38 if (std::is_same_v<T, complex_t>)
39 return DSP_SAMPLE_TYPE_CF32;
40 else if (std::is_same_v<T, float>)
41 return DSP_SAMPLE_TYPE_F32;
42 else if (std::is_same_v<T, int16_t>)
43 return DSP_SAMPLE_TYPE_S16;
44 else if (std::is_same_v<T, int8_t>)
45 return DSP_SAMPLE_TYPE_S8;
46 else if (std::is_same_v<T, uint8_t>)
47 return DSP_SAMPLE_TYPE_U8;
48 else
49 throw satdump_exception("Invalid type for DSP blocks!");
50 }
51 } // namespace ndsp
52} // namespace satdump
Definition block_helpers.h:12