mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-15 10:07:26 -05:00
Co-authored-by: denny <dennis.sheirer@gmail.com>
This commit is contained in:
@@ -41,11 +41,11 @@ public abstract class AmbeAudioModule extends JmbeAudioModule
|
|||||||
{
|
{
|
||||||
if(getAudioCodec() != null)
|
if(getAudioCodec() != null)
|
||||||
{
|
{
|
||||||
mLog.info("AMBE CODEC successfully loaded - P25-2/DMR/NXDN audio will be available");
|
mLog.info("AMBE CODEC successfully loaded - P25-2/DMR/NXDN audio can be processed");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mLog.warn("AMBE CODEC not loaded - P25-2/DMR/NXDN audio will NOT be available");
|
mLog.warn("AMBE CODEC not loaded - P25-2/DMR/NXDN audio will NOT be processed");
|
||||||
}
|
}
|
||||||
|
|
||||||
sLibraryStatusLogged = true;
|
sLibraryStatusLogged = true;
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
package io.github.dsheirer.dsp.gain;
|
|
||||||
|
|
||||||
public class NonClippingGain
|
|
||||||
{
|
|
||||||
private float mGain;
|
|
||||||
private float mMaxValue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies a fixed gain value to the float samples.
|
|
||||||
*
|
|
||||||
* @param gain value
|
|
||||||
* @param maxValue max absolute value to prevent clipping ( 0.0 to 1.0 )
|
|
||||||
*/
|
|
||||||
public NonClippingGain( float gain, float maxValue )
|
|
||||||
{
|
|
||||||
mGain = gain;
|
|
||||||
mMaxValue = maxValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies gain to the sample
|
|
||||||
*/
|
|
||||||
public float apply( float sample )
|
|
||||||
{
|
|
||||||
float adjusted = sample * mGain;
|
|
||||||
|
|
||||||
if( adjusted > mMaxValue )
|
|
||||||
{
|
|
||||||
adjusted = mMaxValue;
|
|
||||||
}
|
|
||||||
if( adjusted < -mMaxValue )
|
|
||||||
{
|
|
||||||
adjusted = -mMaxValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return adjusted;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies gain to the sample array
|
|
||||||
*/
|
|
||||||
public float[] apply( float[] samples )
|
|
||||||
{
|
|
||||||
for( int x = 0; x < samples.length; x++ )
|
|
||||||
{
|
|
||||||
samples[ x ] = apply( samples[ x ]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return samples;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,7 +22,6 @@ import io.github.dsheirer.alias.AliasList;
|
|||||||
import io.github.dsheirer.audio.codec.mbe.AmbeAudioModule;
|
import io.github.dsheirer.audio.codec.mbe.AmbeAudioModule;
|
||||||
import io.github.dsheirer.audio.squelch.SquelchState;
|
import io.github.dsheirer.audio.squelch.SquelchState;
|
||||||
import io.github.dsheirer.audio.squelch.SquelchStateEvent;
|
import io.github.dsheirer.audio.squelch.SquelchStateEvent;
|
||||||
import io.github.dsheirer.dsp.gain.NonClippingGain;
|
|
||||||
import io.github.dsheirer.message.IMessage;
|
import io.github.dsheirer.message.IMessage;
|
||||||
import io.github.dsheirer.module.decode.nxdn.layer3.call.Audio;
|
import io.github.dsheirer.module.decode.nxdn.layer3.call.Audio;
|
||||||
import io.github.dsheirer.module.decode.nxdn.layer3.call.Disconnect;
|
import io.github.dsheirer.module.decode.nxdn.layer3.call.Disconnect;
|
||||||
@@ -41,7 +40,6 @@ import java.util.List;
|
|||||||
public class NXDNAudioModule extends AmbeAudioModule
|
public class NXDNAudioModule extends AmbeAudioModule
|
||||||
{
|
{
|
||||||
private final SquelchStateListener mSquelchStateListener = new SquelchStateListener();
|
private final SquelchStateListener mSquelchStateListener = new SquelchStateListener();
|
||||||
private final NonClippingGain mGain = new NonClippingGain(5.0f, 0.95f);
|
|
||||||
private final List<Audio> mCachedAudioMessages = new ArrayList<>();
|
private final List<Audio> mCachedAudioMessages = new ArrayList<>();
|
||||||
private boolean mEncryptedCall = false;
|
private boolean mEncryptedCall = false;
|
||||||
private boolean mEncryptedCallStateEstablished = false;
|
private boolean mEncryptedCallStateEstablished = false;
|
||||||
@@ -142,9 +140,7 @@ public class NXDNAudioModule extends AmbeAudioModule
|
|||||||
{
|
{
|
||||||
for(byte[] frame : audio.getAudioFrames())
|
for(byte[] frame : audio.getAudioFrames())
|
||||||
{
|
{
|
||||||
float[] generatedAudio = getAudioCodec().getAudio(frame);
|
addAudio(getAudioCodec().getAudio(frame));
|
||||||
generatedAudio = mGain.apply(generatedAudio);
|
|
||||||
addAudio(generatedAudio);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import io.github.dsheirer.alias.AliasList;
|
|||||||
import io.github.dsheirer.audio.codec.mbe.ImbeAudioModule;
|
import io.github.dsheirer.audio.codec.mbe.ImbeAudioModule;
|
||||||
import io.github.dsheirer.audio.squelch.SquelchState;
|
import io.github.dsheirer.audio.squelch.SquelchState;
|
||||||
import io.github.dsheirer.audio.squelch.SquelchStateEvent;
|
import io.github.dsheirer.audio.squelch.SquelchStateEvent;
|
||||||
import io.github.dsheirer.dsp.gain.NonClippingGain;
|
|
||||||
import io.github.dsheirer.message.IMessage;
|
import io.github.dsheirer.message.IMessage;
|
||||||
import io.github.dsheirer.module.decode.p25.phase1.message.hdu.HDUMessage;
|
import io.github.dsheirer.module.decode.p25.phase1.message.hdu.HDUMessage;
|
||||||
import io.github.dsheirer.module.decode.p25.phase1.message.ldu.LDU1Message;
|
import io.github.dsheirer.module.decode.p25.phase1.message.ldu.LDU1Message;
|
||||||
|
|||||||
Reference in New Issue
Block a user