Skip to content

Commit

Permalink
#35 Functional AM demodulator with squelch control.
Browse files Browse the repository at this point in the history
  • Loading branch information
sheirerd committed Apr 22, 2023
1 parent c6200a8 commit 3fa01c3
Show file tree
Hide file tree
Showing 12 changed files with 342 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions src/main/java/io/github/dsheirer/audio/AudioModule.java
Expand Up @@ -141,11 +141,16 @@ public class SquelchStateListener implements Listener<SquelchStateEvent>
@Override
public void receive(SquelchStateEvent event)
{
mSquelchState = event.getSquelchState();
SquelchState squelchState = event.getSquelchState();

if(mSquelchState == SquelchState.SQUELCH)
if(mSquelchState != squelchState)
{
closeAudioSegment();
mSquelchState = squelchState;

if(mSquelchState == SquelchState.SQUELCH)
{
closeAudioSegment();
}
}
}
}
Expand Down
Expand Up @@ -73,7 +73,7 @@ public String toString()
{
StringBuilder sb = new StringBuilder();

sb.append("Decoder State Event - source[").append(mSource.getClass())
sb.append("Decoder State Event - source[").append(mSource != null ? mSource.getClass() : "null")
.append("] event[").append(mEvent)
.append("] state[").append(mState)
.append("] timeslot[").append(mTimeslot)
Expand Down
Expand Up @@ -75,6 +75,8 @@ public void setSourceEventListener(Listener<SourceEvent> listener)
*/
public float[] demodulate(float[] i, float[] q)
{
setSquelchChanged(false);

float[] magnitude = mMagnitudeCalculator.getMagnitude(i, q);
float[] demodulated = mAmDemodulator.demodulateMagnitude(magnitude);

Expand Down
Expand Up @@ -130,10 +130,12 @@ public void process(float magnitude)

if(mSquelch && mPower >= mSquelchThreshold)
{
mLog.info("Setting squelch to false");
setSquelch(false);
}
else if(!mSquelch && mPower < mSquelchThreshold)
{
mLog.info("Setting squelch to true");
setSquelch(true);
}
}
Expand Down

0 comments on commit 3fa01c3

Please sign in to comment.