1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 08:04:49 -05:00
sdrangel/wdsp/gain.cpp

118 lines
2.8 KiB
C++
Raw Normal View History

2024-06-16 05:31:13 -04:00
/* gain.c
This file is part of a program that implements a Software-Defined Radio.
Copyright (C) 2013 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
*/
#include "comm.hpp"
#include "gain.hpp"
namespace WDSP {
2024-06-24 21:50:48 -04:00
GAIN* GAIN::create_gain (int run, int* prun, int size, float* in, float* out, float Igain, float Qgain)
2024-06-16 05:31:13 -04:00
{
GAIN *a = new GAIN;
a->run = run;
a->prun = prun;
a->size = size;
a->in = in;
a->out = out;
a->Igain = Igain;
a->Qgain = Qgain;
return a;
}
void GAIN::destroy_gain (GAIN *a)
{
delete (a);
}
void GAIN::flush_gain (GAIN *)
{
}
void GAIN::xgain (GAIN *a)
{
int srun;
2024-07-13 17:59:46 -04:00
2024-06-16 05:31:13 -04:00
if (a->prun != 0)
srun = *(a->prun);
else
srun = 1;
2024-07-13 17:59:46 -04:00
2024-06-16 05:31:13 -04:00
if (a->run && srun)
{
int i;
2024-07-13 17:59:46 -04:00
2024-06-16 05:31:13 -04:00
for (i = 0; i < a->size; i++)
{
a->out[2 * i + 0] = a->Igain * a->in[2 * i + 0];
a->out[2 * i + 1] = a->Qgain * a->in[2 * i + 1];
}
}
else if (a->in != a->out)
2024-07-16 17:15:13 -04:00
std::copy( a->in, a->in + a->size * 2, a->out);
2024-06-16 05:31:13 -04:00
}
2024-06-24 21:50:48 -04:00
void GAIN::setBuffers_gain (GAIN *a, float* in, float* out)
2024-06-16 05:31:13 -04:00
{
a->in = in;
a->out = out;
}
void GAIN::setSamplerate_gain (GAIN *, int)
{
}
void GAIN::setSize_gain (GAIN *a, int size)
{
a->size = size;
}
/********************************************************************************************************
* *
* POINTER-BASED PROPERTIES *
* *
********************************************************************************************************/
2024-06-24 21:50:48 -04:00
void GAIN::pSetTXOutputLevel (GAIN *a, float level)
2024-06-16 05:31:13 -04:00
{
a->Igain = level;
a->Qgain = level;
}
void GAIN::pSetTXOutputLevelRun (GAIN *a, int run)
{
a->run = run;
}
void GAIN::pSetTXOutputLevelSize (GAIN *a, int size)
{
a->size = size;
}
} // namespace WDSP