1 #ifndef __SDR_AUTOCAST_HH__
2 #define __SDR_AUTOCAST_HH__
13 template <
class Scalar>
31 switch (src_cfg.
type()) {
39 switch (src_cfg.
type()) {
51 switch (src_cfg.
type()) {
59 switch (src_cfg.
type()) {
83 msg <<
"Configure AutoCast node:" << std::endl
84 <<
" input type: " << src_cfg.
type() << std::endl
94 if (0 ==
_cast) {
return; }
119 for (
size_t i=0; i<N; i++) {
120 reinterpret_cast<int8_t *
>(out.
data())[i] =
121 int16_t(reinterpret_cast<uint8_t *>(in.
data())[i]) - 127;
129 for (
size_t i=0; i<N; i++) {
130 reinterpret_cast<int8_t *
>(out.
data())[i] =
131 int16_t(reinterpret_cast<uint16_t *>(in.
data())[i]>>8) - 127;
139 for (
size_t i=0; i<N; i++) {
140 reinterpret_cast<int8_t *
>(out.
data())[i] =
141 reinterpret_cast<int16_t *>(in.
data())[i]>>8;
149 uint8_t *values =
reinterpret_cast<uint8_t *
>(in.
data());
150 for (
size_t i=0; i<N; i++) {
151 reinterpret_cast<std::complex<int8_t> *
>(out.
data())[i] =
152 (int16_t(values[i])-127);
160 for (
size_t i=0; i<N; i++) {
161 reinterpret_cast<std::complex<int8_t> *
>(out.
data())[i] =
162 reinterpret_cast<int8_t *>(in.
data())[i];
170 for (
size_t i=0; i<N; i++) {
171 reinterpret_cast<std::complex<int8_t> *
>(out.
data())[i]
172 = int32_t(reinterpret_cast<int16_t *>(in.
data())[i]>>8)-((2<<15)-1);
180 for (
size_t i=0; i<N; i++) {
181 reinterpret_cast<std::complex<int8_t> *
>(out.
data())[i] = reinterpret_cast<int16_t *>(in.
data())[i]>>8;
189 int8_t *values =
reinterpret_cast<int8_t *
>(in.
data());
190 for (
size_t i=0; i<N; i++) {
191 reinterpret_cast<int16_t *
>(out.
data())[i] = (int16_t(values[i])-127)<<8;
199 int8_t *values =
reinterpret_cast<int8_t *
>(in.
data());
200 for (
size_t i=0; i<N; i++) {
201 reinterpret_cast<int16_t *
>(out.
data())[i] = int16_t(values[i])<<8;
209 uint16_t *values =
reinterpret_cast<uint16_t *
>(in.
data());
210 for (
size_t i=0; i<N; i++) {
211 reinterpret_cast<int16_t *
>(out.
data())[i] = int32_t(values[i])-((2<<15)-1);
219 uint8_t *values =
reinterpret_cast<uint8_t *
>(in.
data());
220 for (
size_t i=0; i<N; i++) {
221 reinterpret_cast<std::complex<int16_t> *
>(out.
data())[i]
222 = std::complex<int16_t>((int16_t(values[i])-127)<<8);
230 int8_t *values =
reinterpret_cast<int8_t *
>(in.
data());
231 for (
size_t i=0; i<N; i++) {
232 reinterpret_cast<std::complex<int16_t> *
>(out.
data())[i]
233 = std::complex<int16_t>(int16_t(values[i])*(1<<8));
241 uint16_t *values =
reinterpret_cast<uint16_t *
>(in.
data());
242 for (
size_t i=0; i<N; i++) {
243 reinterpret_cast<std::complex<int16_t> *
>(out.
data())[i]
244 = std::complex<int16_t>(int32_t(values[i])-(1<<15));
252 int16_t *values =
reinterpret_cast<int16_t *
>(in.
data());
253 for (
size_t i=0; i<N; i++) {
254 reinterpret_cast<std::complex<int16_t> *
>(out.
data())[i] = std::complex<int16_t>(values[i]);
262 #endif // __SDR_AUTOCAST_HH__
static size_t _int16_int8(const RawBuffer &in, const RawBuffer &out)
int16 -> int8
Definition: autocast.hh:137
A collection of configuration information that is send by a source to all connected sinks to properga...
Definition: node.hh:35
Base class of all buffers, represents an untyped array of bytes.
Definition: buffer.hh:32
Buffer< Scalar > _buffer
Output buffer.
Definition: autocast.hh:105
static size_t _uint16_cint8(const RawBuffer &in, const RawBuffer &out)
uint16 -> complex int 8.
Definition: autocast.hh:168
Real signed 16b ints.
Definition: node.hh:44
virtual void send(const RawBuffer &buffer, bool allow_overwrite=false)
Sends the given buffer to all connected sinks.
Definition: node.cc:67
Complex (aka I/Q) type of unsigned 16b ints.
Definition: node.hh:49
Definition: autocast.hh:8
Real signed 8b ints.
Definition: node.hh:42
Generic source class.
Definition: node.hh:213
Real unsigned 8b ints.
Definition: node.hh:41
size_t bytesLen() const
Returns the size of the buffer by the view.
Definition: buffer.hh:73
static size_t _uint8_int16(const RawBuffer &in, const RawBuffer &out)
uint8 -> int16.
Definition: autocast.hh:187
char * data() const
Returns the pointer to the data of the buffer view.
Definition: buffer.hh:69
Real unsigned 16b ints.
Definition: node.hh:43
static size_t _int8_cint8(const RawBuffer &in, const RawBuffer &out)
int8 -> complex int8.
Definition: autocast.hh:158
virtual void setConfig(const Config &config)
Stores the configuration and propergates it if the configuration has been changed.
Definition: node.cc:98
virtual void handleBuffer(const RawBuffer &buffer, bool allow_overwrite)
Needs to be implemented by any sub-type to process the received data.
Definition: autocast.hh:92
void log(const LogMessage &message)
Logs a message.
Definition: logger.cc:100
Type type() const
Returns the type.
Definition: node.hh:71
size_t(* _cast)(const RawBuffer &in, const RawBuffer &out)
Cast function.
Definition: autocast.hh:107
static size_t _uint8_int8(const RawBuffer &in, const RawBuffer &out)
uint8_t -> int8_t
Definition: autocast.hh:117
static Logger & get()
Returns the singleton instance of the logger.
Definition: logger.cc:89
The configuration error class.
Definition: exception.hh:24
A log message.
Definition: logger.hh:22
size_t bufferSize() const
Returns the max.
Definition: node.hh:83
static size_t _int8_int16(const RawBuffer &in, const RawBuffer &out)
int8 -> int16.
Definition: autocast.hh:197
static size_t _int16_cint8(const RawBuffer &in, const RawBuffer &out)
int16 -> complex int 8.
Definition: autocast.hh:178
AutoCast()
Constructor.
Definition: autocast.hh:18
static size_t _int16_cint16(const RawBuffer &in, const RawBuffer &out)
int16 -> complex int16.
Definition: autocast.hh:250
This class performs some automatic casts to a certain buffer type (if possible) specified by the temp...
Definition: autocast.hh:14
Basic interface of all Sinks.
Definition: node.hh:174
char * ptr() const
Returns the pointer to the data (w/o view).
Definition: buffer.hh:67
Complex (aka I/Q) type of signed 8b ints.
Definition: node.hh:48
virtual void config(const Config &src_cfg)
Configures the auto cast node.
Definition: autocast.hh:25
static size_t _uint8_cint16(const RawBuffer &in, const RawBuffer &out)
unsinged int8 -> complex int16.
Definition: autocast.hh:217
static size_t _int8_cint16(const RawBuffer &in, const RawBuffer &out)
int8 -> complex int16.
Definition: autocast.hh:228
Complex (aka I/Q) type of signed 16b ints.
Definition: node.hh:50
static size_t _uint16_int16(const RawBuffer &in, const RawBuffer &out)
uint16 -> int16.
Definition: autocast.hh:207
Complex (aka I/Q) type of unsigned 8b ints.
Definition: node.hh:47
static size_t _uint16_int8(const RawBuffer &in, const RawBuffer &out)
uint16 -> int8
Definition: autocast.hh:127
Forward declaration of type tratis template.
Definition: traits.hh:20
static size_t _uint16_cint16(const RawBuffer &in, const RawBuffer &out)
uint16 -> complex int16.
Definition: autocast.hh:239
static size_t _uint8_cint8(const RawBuffer &in, const RawBuffer &out)
uint8 -> complex int8.
Definition: autocast.hh:147
static size_t _identity(const RawBuffer &in, const RawBuffer &out)
Performs no cast at all.
Definition: autocast.hh:111
double sampleRate() const
Returns the sample rate.
Definition: node.hh:77