2024-06-16 05:31:13 -04:00
|
|
|
/* delay.h
|
|
|
|
|
|
|
|
This file is part of a program that implements a Software-Defined Radio.
|
|
|
|
|
|
|
|
Copyright (C) 2013, 2019 Warren Pratt, NR0V
|
|
|
|
Copyright (C) 2024 Edouard Griffiths, F4EXB Adapted to SDRangel
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
The author can be reached by email at
|
|
|
|
|
|
|
|
warren@wpratt.com
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef wdsp_delay_h
|
|
|
|
#define wdsp_delay_h
|
|
|
|
|
|
|
|
#include "export.h"
|
|
|
|
|
|
|
|
#define WSDEL 1025 // number of supported whole sample delays
|
|
|
|
|
|
|
|
namespace WDSP {
|
|
|
|
|
|
|
|
class WDSP_API DELAY
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int run; // run
|
|
|
|
int size; // number of input samples per buffer
|
2024-06-24 21:50:48 -04:00
|
|
|
float* in; // input buffer
|
|
|
|
float* out; // output buffer
|
2024-06-16 05:31:13 -04:00
|
|
|
int rate; // samplerate
|
2024-06-24 21:50:48 -04:00
|
|
|
float tdelta; // delay increment required (seconds)
|
|
|
|
float tdelay; // delay requested (seconds)
|
2024-06-16 05:31:13 -04:00
|
|
|
|
|
|
|
int L; // interpolation factor
|
|
|
|
int ncoef; // number of coefficients
|
|
|
|
int cpp; // coefficients per phase
|
2024-06-24 21:50:48 -04:00
|
|
|
float ft; // normalized cutoff frequency
|
|
|
|
float* h; // coefficients
|
2024-06-16 05:31:13 -04:00
|
|
|
int snum; // starting sample number (0 for sub-sample delay)
|
|
|
|
int phnum; // phase number
|
|
|
|
|
|
|
|
int idx_in; // index for input into ring
|
|
|
|
int rsize; // ring size in complex samples
|
2024-06-24 21:50:48 -04:00
|
|
|
float* ring; // ring buffer
|
2024-06-16 05:31:13 -04:00
|
|
|
|
2024-06-24 21:50:48 -04:00
|
|
|
float adelta; // actual delay increment
|
|
|
|
float adelay; // actual delay
|
2024-06-16 05:31:13 -04:00
|
|
|
|
2024-06-24 21:50:48 -04:00
|
|
|
static DELAY* create_delay (int run, int size, float* in, float* out, int rate, float tdelta, float tdelay);
|
2024-06-16 05:31:13 -04:00
|
|
|
static void destroy_delay (DELAY *a);
|
|
|
|
static void flush_delay (DELAY *a);
|
|
|
|
static void xdelay (DELAY *a);
|
|
|
|
// Properties
|
|
|
|
static void SetDelayRun (DELAY *a, int run);
|
2024-06-24 21:50:48 -04:00
|
|
|
static float SetDelayValue (DELAY *a, float delay); // returns actual delay in seconds
|
|
|
|
static void SetDelayBuffs (DELAY *a, int size, float* in, float* out);
|
2024-06-16 05:31:13 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace WDSP
|
|
|
|
|
|
|
|
#endif
|