4 * Various functions for baseband sample processing
6 * Copyright (C) 2012 by Benjamin Larsson <benjamin@southpole.se>
7 * Copyright (C) 2015 Tommy Vestermark
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
15 #ifndef INCLUDE_BASEBAND_H_
16 #define INCLUDE_BASEBAND_H_
20 /// This will give a noisy envelope of OOK/ASK signals
22 /// Subtract the bias (-128) and get an envelope estimation (absolute squared)
23 /// @param *iq_buf: input samples (I/Q samples in interleaved uint8)
24 /// @param *y_buf: output
25 /// @param len: number of samples to process
26 void envelope_detect(const uint8_t *iq_buf, uint16_t *y_buf, uint32_t len);
28 #define FILTER_ORDER 1
30 /// Filter state buffer
32 int16_t y[FILTER_ORDER];
33 int16_t x[FILTER_ORDER];
36 /// FM_Demod state buffer
38 int16_t br, bi; // Last I/Q sample
39 int16_t xlp, ylp; // Low-pass filter state
44 /// Function is stateful
45 /// @param *x_buf: input samples to be filtered
46 /// @param *y_buf: output from filter
47 /// @param len: number of samples to process
48 /// @param FilterState: State to store between chunk processing
49 void baseband_low_pass_filter(const uint16_t *x_buf, int16_t *y_buf, uint32_t len, FilterState *state);
53 /// Function is stateful
54 /// @param *x_buf: input samples (I/Q samples in interleaved uint8)
55 /// @param *y_buf: output from FM demodulator
56 /// @param len: number of samples to process
57 /// @param DemodFM_State: State to store between chunk processing
58 void baseband_demod_FM(const uint8_t *x_buf, int16_t *y_buf, unsigned num_samples, DemodFM_State *state);
60 /// Initialize tables and constants
61 /// Should be called once at startup
62 void baseband_init(void);
64 /// Dump binary data (for debug purposes)
65 void baseband_dumpfile(const uint8_t *buf, uint32_t len);
67 #endif /* INCLUDE_BASEBAND_H_ */