mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-22 17:45:48 -05:00
Added simple AGC for AM demod
This commit is contained in:
parent
8d15cabe70
commit
3e922dbb0a
@ -84,6 +84,8 @@ To Do
|
|||||||
=====
|
=====
|
||||||
|
|
||||||
- Add the possibility to change the brightness and/or color of the grid. Sometimes it is barely visible yet useful
|
- Add the possibility to change the brightness and/or color of the grid. Sometimes it is barely visible yet useful
|
||||||
|
- Fix and possibly enhance (stereo, RDS?) WFM. Maybe into two plugins one for plain WFM and the other for Broadcast FM
|
||||||
|
- Make the the SSB filter frequency bounds tunable so that it can be used for CW. Change marker overlay accordingly.
|
||||||
- Possibility to completely undock the receiver in a separate window. Useful when there are many receivers
|
- Possibility to completely undock the receiver in a separate window. Useful when there are many receivers
|
||||||
- Larger decimation capability for narrowband and very narrowband work (32, 64, ...)
|
- Larger decimation capability for narrowband and very narrowband work (32, 64, ...)
|
||||||
- Even more demods ...
|
- Even more demods ...
|
||||||
|
71
include-gpl/dsp/agc.h
Normal file
71
include-gpl/dsp/agc.h
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* kissagc.h
|
||||||
|
*
|
||||||
|
* Created on: May 12, 2015
|
||||||
|
* Author: f4exb
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INCLUDE_GPL_DSP_AGC_H_
|
||||||
|
#define INCLUDE_GPL_DSP_AGC_H_
|
||||||
|
|
||||||
|
#include "movingaverage.h"
|
||||||
|
|
||||||
|
class SimpleAGC
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
SimpleAGC() :
|
||||||
|
m_squelch(false),
|
||||||
|
m_fill(0),
|
||||||
|
m_cutoff(0),
|
||||||
|
m_moving_average()
|
||||||
|
{}
|
||||||
|
|
||||||
|
SimpleAGC(int historySize, Real initial, Real cutoff) :
|
||||||
|
m_squelch(false),
|
||||||
|
m_fill(initial),
|
||||||
|
m_cutoff(cutoff),
|
||||||
|
m_moving_average(historySize, initial)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void resize(int historySize, Real initial, Real cutoff)
|
||||||
|
{
|
||||||
|
m_fill = initial;
|
||||||
|
m_cutoff = cutoff;
|
||||||
|
m_moving_average.resize(historySize, initial);
|
||||||
|
}
|
||||||
|
|
||||||
|
Real getValue()
|
||||||
|
{
|
||||||
|
return m_moving_average.average();
|
||||||
|
}
|
||||||
|
|
||||||
|
void feed(Real value)
|
||||||
|
{
|
||||||
|
if (value > m_cutoff)
|
||||||
|
{
|
||||||
|
m_moving_average.feed(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_squelch = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void close()
|
||||||
|
{
|
||||||
|
if (m_squelch)
|
||||||
|
{
|
||||||
|
m_moving_average.fill(m_fill);
|
||||||
|
m_squelch = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_squelch;
|
||||||
|
Real m_fill;
|
||||||
|
Real m_cutoff;
|
||||||
|
MovingAverage m_moving_average;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* INCLUDE_GPL_DSP_AGC_H_ */
|
@ -39,6 +39,13 @@ public:
|
|||||||
m_ptr = 0;
|
m_ptr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fill(Real value)
|
||||||
|
{
|
||||||
|
for(size_t i = 0; i < m_history.size(); i++)
|
||||||
|
m_history[i] = value;
|
||||||
|
m_sum = m_history.size() * value;
|
||||||
|
}
|
||||||
|
|
||||||
Real average() const
|
Real average() const
|
||||||
{
|
{
|
||||||
return m_sum / (Real)m_history.size();
|
return m_sum / (Real)m_history.size();
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include "dsp/dspcommands.h"
|
#include "dsp/dspcommands.h"
|
||||||
#include "dsp/pidcontroller.h"
|
#include "dsp/pidcontroller.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
MESSAGE_CLASS_DEFINITION(AMDemod::MsgConfigureAMDemod, Message)
|
MESSAGE_CLASS_DEFINITION(AMDemod::MsgConfigureAMDemod, Message)
|
||||||
|
|
||||||
AMDemod::AMDemod(AudioFifo* audioFifo, SampleSink* sampleSink) :
|
AMDemod::AMDemod(AudioFifo* audioFifo, SampleSink* sampleSink) :
|
||||||
@ -43,6 +45,7 @@ AMDemod::AMDemod(AudioFifo* audioFifo, SampleSink* sampleSink) :
|
|||||||
m_audioBufferFill = 0;
|
m_audioBufferFill = 0;
|
||||||
|
|
||||||
m_movingAverage.resize(16, 0);
|
m_movingAverage.resize(16, 0);
|
||||||
|
m_volumeAGC.resize(4096, 0.003, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
AMDemod::~AMDemod()
|
AMDemod::~AMDemod()
|
||||||
@ -55,6 +58,7 @@ void AMDemod::configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBan
|
|||||||
cmd->submit(messageQueue, this);
|
cmd->submit(messageQueue, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
float arctan2(Real y, Real x)
|
float arctan2(Real y, Real x)
|
||||||
{
|
{
|
||||||
Real coeff_1 = M_PI / 4;
|
Real coeff_1 = M_PI / 4;
|
||||||
@ -84,6 +88,7 @@ Real angleDist(Real a, Real b)
|
|||||||
|
|
||||||
return dist;
|
return dist;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void AMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst)
|
void AMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst)
|
||||||
{
|
{
|
||||||
@ -138,10 +143,14 @@ void AMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_itera
|
|||||||
else if(demod > 1)
|
else if(demod > 1)
|
||||||
demod = 1;
|
demod = 1;
|
||||||
|
|
||||||
|
m_volumeAGC.feed(demod);
|
||||||
|
|
||||||
|
demod *= (0.003 / m_volumeAGC.getValue());
|
||||||
demod *= m_running.m_volume;
|
demod *= m_running.m_volume;
|
||||||
sample = demod * 32700;
|
sample = demod * 32700 * 16;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
m_volumeAGC.close();
|
||||||
sample = 0;
|
sample = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "dsp/interpolator.h"
|
#include "dsp/interpolator.h"
|
||||||
#include "dsp/lowpass.h"
|
#include "dsp/lowpass.h"
|
||||||
#include "dsp/movingaverage.h"
|
#include "dsp/movingaverage.h"
|
||||||
|
#include "dsp/agc.h"
|
||||||
#include "audio/audiofifo.h"
|
#include "audio/audiofifo.h"
|
||||||
#include "util/message.h"
|
#include "util/message.h"
|
||||||
|
|
||||||
@ -117,6 +118,7 @@ private:
|
|||||||
Real m_lastArgument;
|
Real m_lastArgument;
|
||||||
Complex m_lastSample;
|
Complex m_lastSample;
|
||||||
MovingAverage m_movingAverage;
|
MovingAverage m_movingAverage;
|
||||||
|
SimpleAGC m_volumeAGC;
|
||||||
|
|
||||||
AudioVector m_audioBuffer;
|
AudioVector m_audioBuffer;
|
||||||
uint m_audioBufferFill;
|
uint m_audioBufferFill;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>215</width>
|
<width>234</width>
|
||||||
<height>94</height>
|
<height>94</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -14,7 +14,16 @@
|
|||||||
<string>Oscilloscope</string>
|
<string>Oscilloscope</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout" columnstretch="1,1,1,1">
|
<layout class="QGridLayout" name="gridLayout" columnstretch="1,1,1,1">
|
||||||
<property name="margin">
|
<property name="leftMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
@ -258,19 +267,6 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="ButtonSwitch" name="waterfall">
|
<widget class="ButtonSwitch" name="waterfall">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -446,6 +442,31 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDial" name="gridIntensity">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>24</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="cursor">
|
||||||
|
<cursorShape>ArrowCursor</cursorShape>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Grid intensity</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>255</number>
|
||||||
|
</property>
|
||||||
|
<property name="pageStep">
|
||||||
|
<number>16</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>64</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
Reference in New Issue
Block a user