Files
sdrtrunk/src/audio/inverted/AudioAdapter.java
denny 70e62ebb35 Adds airspy USB tuner support and updates the spectral display
component.

-Airspy supported with 10 and 2.5 MSps sample rates.  Additional
decimation may be added later.

-Spectral display updated to include smoothing and filtering options.

Note: the decimated output of a tuner channel from the airspy is
48,076.9 samples per second, versus the normal 48 kHz decimated rate.
This is 1.0015 times the normal rate and doesn't appear to impact the
decoders or audio processing.  Therefore, no fractional resampling has
been added.
2015-11-07 08:18:41 -05:00

100 lines
2.7 KiB
Java

/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 Dennis Sheirer
*
* 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 3 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, see <http://www.gnu.org/licenses/>
******************************************************************************/
package audio.inverted;
import dsp.filter.FilterFactory;
import dsp.filter.FloatFIRFilter;
import dsp.filter.Window.WindowType;
import dsp.mixer.Oscillator;
/**
* Based on the AudioType applied, produces normal, muted, or audio inverted
* audio output.
*/
public class AudioAdapter
{
private static int mGain = 5;
private Oscillator mSineWaveGenerator;
private FloatFIRFilter mPostInversionFilter;
private FloatFIRFilter mAudioHighPassFilter;
private AudioType mAudioType = AudioType.NORMAL;
private int mSampleRate;
public AudioAdapter( int sampleRate )
{
mSampleRate = sampleRate;
mSineWaveGenerator = new Oscillator( 3000, mSampleRate );
mAudioHighPassFilter = new FloatFIRFilter(
FilterFactory.getHighPass( mSampleRate, 200, 1600, 48,
WindowType.HAMMING, true ), mGain );
mPostInversionFilter = new FloatFIRFilter(
FilterFactory.getLowPass( mSampleRate, 3000, 5000, 48,
WindowType.HAMMING, true ), mGain );
}
public void setAudioType( AudioType type )
{
if( type != null && type != mAudioType )
{
mAudioType = type;
int inversionFrequency = type.getAudioInversionFrequency();
if( inversionFrequency != 0 )
{
mSineWaveGenerator.setFrequency( inversionFrequency );;
}
}
}
public float get( float sample )
{
float retVal;
switch( mAudioType )
{
case NORMAL:
retVal = mAudioHighPassFilter.get( sample );
break;
case MUTE:
retVal = 0.0f;
break;
case INV2632:
case INV2718:
case INV2868:
case INV3023:
case INV3107:
case INV3196:
case INV3333:
case INV3339:
case INV3496:
case INV3729:
case INV4096:
default:
retVal = (float)( mPostInversionFilter.get(
mAudioHighPassFilter.get( sample ) *
mSineWaveGenerator.getFloat() ) );
mSineWaveGenerator.rotate();
break;
}
return retVal;
}
}