Merge pull request #422 from DSheirer/421-nbfm-25-khz-channel-bandwidth

421 Add 25 kHz Channel Bandwidth Support to NBFM Decoder
This commit is contained in:
Denny Sheirer
2018-09-16 07:22:38 -04:00
committed by GitHub
18 changed files with 362 additions and 225 deletions

View File

@@ -186,7 +186,7 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
if(frequency > 0) if(frequency > 0)
{ {
Channel channel = getChannel(callEvent.getChannel(), new TunerChannel(frequency, Channel channel = getChannel(callEvent.getChannel(), new TunerChannel(frequency,
mDecodeConfiguration.getDecoderType().getChannelBandwidth())); mDecodeConfiguration.getChannelSpecification().getBandwidth()));
if(channel != null) if(channel != null)
{ {

View File

@@ -489,14 +489,14 @@ public class Channel extends Configuration implements Listener<SourceEvent>
SourceConfigTuner config = (SourceConfigTuner)mSourceConfiguration; SourceConfigTuner config = (SourceConfigTuner)mSourceConfiguration;
mTunerChannel = new TunerChannel(config.getFrequency(), mTunerChannel = new TunerChannel(config.getFrequency(),
mDecodeConfiguration.getDecoderType().getChannelBandwidth()); mDecodeConfiguration.getChannelSpecification().getBandwidth());
} }
else if(mSourceConfiguration.getSourceType() == SourceType.RECORDING) else if(mSourceConfiguration.getSourceType() == SourceType.RECORDING)
{ {
SourceConfigRecording config = (SourceConfigRecording)mSourceConfiguration; SourceConfigRecording config = (SourceConfigRecording)mSourceConfiguration;
mTunerChannel = new TunerChannel(config.getFrequency(), mTunerChannel = new TunerChannel(config.getFrequency(),
mDecodeConfiguration.getDecoderType().getChannelBandwidth()); mDecodeConfiguration.getChannelSpecification().getBandwidth());
} }
} }

View File

@@ -212,8 +212,7 @@ public class ChannelProcessingManager implements ChannelEventListener
try try
{ {
source = mSourceManager.getSource(channel.getSourceConfiguration(), source = mSourceManager.getSource(channel.getSourceConfiguration(),
channel.getDecodeConfiguration().getDecoderType().getChannelBandwidth(), channel.getDecodeConfiguration().getChannelSpecification());
channel.getDecodeConfiguration().getDecoderType().getChannelSpecification());
} }
catch(SourceException se) catch(SourceException se)
{ {

View File

@@ -62,12 +62,12 @@ public class FilterViewer extends Application
// .build(); // .build();
FIRFilterSpecification specification = FIRFilterSpecification.lowPassBuilder() FIRFilterSpecification specification = FIRFilterSpecification.lowPassBuilder()
.sampleRate(50000.0) .sampleRate(25000.0)
.gridDensity(16) .gridDensity(16)
.passBandCutoff(6000) .passBandCutoff(11800)
.passBandAmplitude(1.0) .passBandAmplitude(1.0)
.passBandRipple(0.01) .passBandRipple(0.01)
.stopBandStart(6700) .stopBandStart(12400)
.stopBandAmplitude(0.0) .stopBandAmplitude(0.0)
.stopBandRipple(0.01) .stopBandRipple(0.01)
.build(); .build();

View File

@@ -15,8 +15,6 @@
******************************************************************************/ ******************************************************************************/
package io.github.dsheirer.module.decode; package io.github.dsheirer.module.decode;
import io.github.dsheirer.source.tuner.channel.ChannelSpecification;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
@@ -26,36 +24,27 @@ import java.util.EnumSet;
public enum DecoderType public enum DecoderType
{ {
//Primary Decoders //Primary Decoders
AM("AM", "AM", 10000, new ChannelSpecification(25000.0, 3000.0, 5000.0)), AM("AM", "AM"),
LTR_STANDARD("LTR-Standard", "LTR", 12500, new ChannelSpecification(25000.0, 6000.0, 7000.0)), LTR_STANDARD("LTR-Standard", "LTR"),
LTR_NET("LTR-Net", "LTR-Net", 12500, new ChannelSpecification(25000.0, 6000.0, 7000.0)), LTR_NET("LTR-Net", "LTR-Net"),
MPT1327("MPT1327", "MPT1327", 12500, new ChannelSpecification(25000.0, 6000.0, 7000.0)), MPT1327("MPT1327", "MPT1327"),
NBFM("NBFM", "NBFM", 12500, new ChannelSpecification(25000.0, 6000.0, 7000.0)), NBFM("NBFM", "NBFM"),
PASSPORT("Passport", "Passport", 12500, new ChannelSpecification(25000.0, 6000.0, 7000.0)), PASSPORT("Passport", "Passport"),
P25_PHASE1("P25 Phase I", "P25-1", 12500, new ChannelSpecification(50000.0, 6000.0, 7000.0)), P25_PHASE1("P25 Phase I", "P25-1"),
//Auxiliary Decoders //Auxiliary Decoders
FLEETSYNC2("Fleetsync II", "Fleetsync2", 12500), FLEETSYNC2("Fleetsync II", "Fleetsync2"),
LJ_1200("LJ1200 173.075", "LJ1200", 12500), LJ_1200("LJ1200 173.075", "LJ1200"),
MDC1200("MDC1200", "MDC1200", 12500), MDC1200("MDC1200", "MDC1200"),
TAIT_1200("Tait 1200", "Tait 1200", 12500); TAIT_1200("Tait 1200", "Tait 1200");
private String mDisplayString; private String mDisplayString;
private String mShortDisplayString; private String mShortDisplayString;
private int mChannelBandwidth;
private ChannelSpecification mChannelSpecification;
DecoderType(String displayString, String shortDisplayString, int bandwidth, ChannelSpecification channelSpecification) DecoderType(String displayString, String shortDisplayString)
{ {
mDisplayString = displayString; mDisplayString = displayString;
mShortDisplayString = shortDisplayString; mShortDisplayString = shortDisplayString;
mChannelBandwidth = bandwidth;
mChannelSpecification = channelSpecification;
}
DecoderType(String displayString, String shortDisplayString, int bandwidth)
{
this(displayString, shortDisplayString, bandwidth, null);
} }
/** /**
@@ -97,20 +86,6 @@ public enum DecoderType
return mShortDisplayString; return mShortDisplayString;
} }
public int getChannelBandwidth()
{
return mChannelBandwidth;
}
/**
* Channel specification for a channel for this decoder type.
* @return specification or null
*/
public ChannelSpecification getChannelSpecification()
{
return mChannelSpecification;
}
@Override @Override
public String toString() public String toString()
{ {

View File

@@ -17,9 +17,11 @@
******************************************************************************/ ******************************************************************************/
package io.github.dsheirer.module.decode.am; package io.github.dsheirer.module.decode.am;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.module.decode.DecoderType; import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.module.decode.config.DecodeConfiguration; import io.github.dsheirer.module.decode.config.DecodeConfiguration;
import io.github.dsheirer.source.tuner.channel.ChannelSpecification;
public class DecodeConfigAM extends DecodeConfiguration public class DecodeConfigAM extends DecodeConfiguration
{ {
@@ -27,6 +29,17 @@ public class DecodeConfigAM extends DecodeConfiguration
{ {
} }
/**
* Source channel specification for this decoder
*/
@JsonIgnore
@Override
public ChannelSpecification getChannelSpecification()
{
return new ChannelSpecification(25000.0,
3000, 3000.0, 5000.0);
}
@JacksonXmlProperty(isAttribute = true, localName = "type", namespace = "http://www.w3.org/2001/XMLSchema-instance") @JacksonXmlProperty(isAttribute = true, localName = "type", namespace = "http://www.w3.org/2001/XMLSchema-instance")
public DecoderType getDecoderType() public DecoderType getDecoderType()
{ {

View File

@@ -29,6 +29,7 @@ import io.github.dsheirer.module.decode.mpt1327.DecodeConfigMPT1327;
import io.github.dsheirer.module.decode.nbfm.DecodeConfigNBFM; import io.github.dsheirer.module.decode.nbfm.DecodeConfigNBFM;
import io.github.dsheirer.module.decode.p25.DecodeConfigP25Phase1; import io.github.dsheirer.module.decode.p25.DecodeConfigP25Phase1;
import io.github.dsheirer.module.decode.passport.DecodeConfigPassport; import io.github.dsheirer.module.decode.passport.DecodeConfigPassport;
import io.github.dsheirer.source.tuner.channel.ChannelSpecification;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@@ -58,4 +59,7 @@ public abstract class DecodeConfiguration extends Configuration
@JsonIgnore @JsonIgnore
public abstract DecoderType getDecoderType(); public abstract DecoderType getDecoderType();
@JsonIgnore
public abstract ChannelSpecification getChannelSpecification();
} }

View File

@@ -17,10 +17,12 @@
******************************************************************************/ ******************************************************************************/
package io.github.dsheirer.module.decode.ltrnet; package io.github.dsheirer.module.decode.ltrnet;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.message.MessageDirection; import io.github.dsheirer.message.MessageDirection;
import io.github.dsheirer.module.decode.DecoderType; import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.module.decode.config.DecodeConfiguration; import io.github.dsheirer.module.decode.config.DecodeConfiguration;
import io.github.dsheirer.source.tuner.channel.ChannelSpecification;
public class DecodeConfigLTRNet extends DecodeConfiguration public class DecodeConfigLTRNet extends DecodeConfiguration
{ {
@@ -46,4 +48,15 @@ public class DecodeConfigLTRNet extends DecodeConfiguration
{ {
mMessageDirection = direction; mMessageDirection = direction;
} }
/**
* Source channel specification for this decoder
*/
@JsonIgnore
@Override
public ChannelSpecification getChannelSpecification()
{
return new ChannelSpecification(25000.0,
12500, 6000.0, 7000.0);
}
} }

View File

@@ -17,10 +17,12 @@
******************************************************************************/ ******************************************************************************/
package io.github.dsheirer.module.decode.ltrstandard; package io.github.dsheirer.module.decode.ltrstandard;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.message.MessageDirection; import io.github.dsheirer.message.MessageDirection;
import io.github.dsheirer.module.decode.DecoderType; import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.module.decode.config.DecodeConfiguration; import io.github.dsheirer.module.decode.config.DecodeConfiguration;
import io.github.dsheirer.source.tuner.channel.ChannelSpecification;
public class DecodeConfigLTRStandard extends DecodeConfiguration public class DecodeConfigLTRStandard extends DecodeConfiguration
{ {
@@ -47,4 +49,15 @@ public class DecodeConfigLTRStandard extends DecodeConfiguration
{ {
mMessageDirection = direction; mMessageDirection = direction;
} }
/**
* Source channel specification for this decoder
*/
@JsonIgnore
@Override
public ChannelSpecification getChannelSpecification()
{
return new ChannelSpecification(25000.0,
12500, 6000.0, 7000.0);
}
} }

View File

@@ -17,9 +17,11 @@
******************************************************************************/ ******************************************************************************/
package io.github.dsheirer.module.decode.mpt1327; package io.github.dsheirer.module.decode.mpt1327;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.module.decode.DecoderType; import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.module.decode.config.DecodeConfiguration; import io.github.dsheirer.module.decode.config.DecodeConfiguration;
import io.github.dsheirer.source.tuner.channel.ChannelSpecification;
public class DecodeConfigMPT1327 extends DecodeConfiguration public class DecodeConfigMPT1327 extends DecodeConfiguration
{ {
@@ -102,4 +104,15 @@ public class DecodeConfigMPT1327 extends DecodeConfiguration
{ {
mTrafficChannelPoolSize = size; mTrafficChannelPoolSize = size;
} }
/**
* Source channel specification for this decoder
*/
@JsonIgnore
@Override
public ChannelSpecification getChannelSpecification()
{
return new ChannelSpecification(25000.0,
12500, 6000.0, 7000.0);
}
} }

View File

@@ -17,12 +17,16 @@
******************************************************************************/ ******************************************************************************/
package io.github.dsheirer.module.decode.nbfm; package io.github.dsheirer.module.decode.nbfm;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.module.decode.DecoderType; import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.module.decode.config.DecodeConfiguration; import io.github.dsheirer.module.decode.config.DecodeConfiguration;
import io.github.dsheirer.source.tuner.channel.ChannelSpecification;
public class DecodeConfigNBFM extends DecodeConfiguration public class DecodeConfigNBFM extends DecodeConfiguration
{ {
private Bandwidth mBandwidth = Bandwidth.BW_12_5;
public DecodeConfigNBFM() public DecodeConfigNBFM()
{ {
} }
@@ -33,4 +37,53 @@ public class DecodeConfigNBFM extends DecodeConfiguration
return DecoderType.NBFM; return DecoderType.NBFM;
} }
/**
* Channel bandwidth
*/
@JacksonXmlProperty(isAttribute = true, localName = "bandwidth")
public Bandwidth getBandwidth()
{
return mBandwidth;
}
@JsonIgnore
@Override
public ChannelSpecification getChannelSpecification()
{
if(mBandwidth == Bandwidth.BW_12_5)
{
return new ChannelSpecification(25000.0, 12500, 6000.0, 7000.0);
}
else
{
return new ChannelSpecification(50000.0, 25000, 12500.0, 13500.0);
}
}
/**
* Sets the channel bandwidth
*/
public void setBandwidth(Bandwidth bandwidth)
{
mBandwidth = bandwidth;
}
public enum Bandwidth
{
BW_12_5("12.5 kHz"),
BW_25_0("25.0 kHz");
private String mLabel;
Bandwidth(String label)
{
mLabel = label;
}
@Override
public String toString()
{
return mLabel;
}
};
} }

View File

@@ -1,19 +1,17 @@
/******************************************************************************* /*******************************************************************************
* SDR Trunk * sdr-trunk
* Copyright (C) 2014-2016 Dennis Sheirer * Copyright (C) 2014-2018 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* it under the terms of the GNU General Public License as published by * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* the Free Software Foundation, either version 3 of the License, or * later version.
* (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* but WITHOUT ANY WARRANTY; without even the implied warranty of * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* 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/>
* *
* 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 io.github.dsheirer.module.decode.nbfm; package io.github.dsheirer.module.decode.nbfm;
@@ -24,70 +22,94 @@ import io.github.dsheirer.gui.editor.ValidatingEditor;
import io.github.dsheirer.module.decode.config.DecodeConfiguration; import io.github.dsheirer.module.decode.config.DecodeConfiguration;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JLabel; import javax.swing.JLabel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class NBFMDecoderEditor extends ValidatingEditor<Channel> public class NBFMDecoderEditor extends ValidatingEditor<Channel>
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public NBFMDecoderEditor() private JComboBox<DecodeConfigNBFM.Bandwidth> mComboBandwidth;
{
init();
}
private void init() public NBFMDecoderEditor()
{ {
setLayout( new MigLayout( "insets 0 0 0 0,wrap 2", "[right][grow,fill]", "" ) ); init();
add( new JLabel( "Narrow Band FM Decoder" ) ); }
}
@Override private void init()
public void validate( Editor<Channel> editor ) throws EditorValidationException {
{ setLayout(new MigLayout("insets 0 0 0 0,wrap 2", "[right][grow,fill]", ""));
//No validation
}
@Override mComboBandwidth = new JComboBox<>();
public void save() mComboBandwidth.setModel(new DefaultComboBoxModel<DecodeConfigNBFM.Bandwidth>(
{ DecodeConfigNBFM.Bandwidth.values()));
if( hasItem() && isModified() ) mComboBandwidth.setEnabled(false);
{ mComboBandwidth.addActionListener(new ActionListener()
DecodeConfigNBFM nbfm = new DecodeConfigNBFM(); {
getItem().setDecodeConfiguration( nbfm ); @Override
} public void actionPerformed(ActionEvent e)
{
setModified(true);
}
});
setModified( false ); add(new JLabel("Bandwidth:"));
} add(mComboBandwidth);
}
private void setControlsEnabled( boolean enabled ) @Override
{ public void validate(Editor<Channel> editor) throws EditorValidationException
} {
//No validation
}
@Override @Override
public void setItem( Channel item ) public void save()
{ {
super.setItem( item ); if(hasItem() && isModified())
{
DecodeConfigNBFM nbfm = new DecodeConfigNBFM();
nbfm.setBandwidth((DecodeConfigNBFM.Bandwidth)mComboBandwidth.getSelectedItem());
getItem().setDecodeConfiguration(nbfm);
}
if( hasItem() ) setModified(false);
{ }
setControlsEnabled( true );
DecodeConfiguration config = getItem().getDecodeConfiguration(); private void setControlsEnabled(boolean enabled)
{
mComboBandwidth.setEnabled(enabled);
}
if( config instanceof DecodeConfigNBFM ) @Override
{ public void setItem(Channel item)
DecodeConfigNBFM nbfm = (DecodeConfigNBFM)config; {
setModified( false ); super.setItem(item);
}
else if(hasItem())
{ {
setModified( true ); setControlsEnabled(true);
}
} DecodeConfiguration config = getItem().getDecodeConfiguration();
else
{ if(config instanceof DecodeConfigNBFM)
setControlsEnabled( false ); {
setModified( false ); DecodeConfigNBFM nbfm = (DecodeConfigNBFM)config;
} mComboBandwidth.setSelectedItem(nbfm.getBandwidth());
} setModified(false);
}
else
{
setModified(true);
}
}
else
{
setControlsEnabled(false);
setModified(false);
}
}
} }

View File

@@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.module.decode.DecoderType; import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.module.decode.config.DecodeConfiguration; import io.github.dsheirer.module.decode.config.DecodeConfiguration;
import io.github.dsheirer.source.tuner.channel.ChannelSpecification;
public class DecodeConfigP25Phase1 extends DecodeConfiguration public class DecodeConfigP25Phase1 extends DecodeConfiguration
{ {
@@ -104,4 +105,15 @@ public class DecodeConfigP25Phase1 extends DecodeConfiguration
{ {
mTrafficChannelPoolSize = size; mTrafficChannelPoolSize = size;
} }
/**
* Source channel specification for this decoder
*/
@JsonIgnore
@Override
public ChannelSpecification getChannelSpecification()
{
return new ChannelSpecification(50000.0,
12500, 6000.0, 7000.0);
}
} }

View File

@@ -1,7 +1,6 @@
/* /*******************************************************************************
* ********************************************************************************************************************* * sdr-trunk
* sdrtrunk * Copyright (C) 2014-2018 Dennis Sheirer
* Copyright (C) 2014-2017 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public * 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 * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
@@ -12,13 +11,15 @@
* *
* You should have received a copy of the GNU General Public License along with this program. * You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/> * If not, see <http://www.gnu.org/licenses/>
* ********************************************************************************************************************* *
*/ ******************************************************************************/
package io.github.dsheirer.module.decode.passport; package io.github.dsheirer.module.decode.passport;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.module.decode.DecoderType; import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.module.decode.config.DecodeConfiguration; import io.github.dsheirer.module.decode.config.DecodeConfiguration;
import io.github.dsheirer.source.tuner.channel.ChannelSpecification;
public class DecodeConfigPassport extends DecodeConfiguration public class DecodeConfigPassport extends DecodeConfiguration
{ {
@@ -31,4 +32,14 @@ public class DecodeConfigPassport extends DecodeConfiguration
{ {
return DecoderType.PASSPORT; return DecoderType.PASSPORT;
} }
/**
* Source channel specification for this decoder
*/
@JsonIgnore
@Override
public ChannelSpecification getChannelSpecification()
{
return new ChannelSpecification(25000.0, 12500, 6000.0, 7000.0);
}
} }

View File

@@ -74,8 +74,7 @@ public class SourceManager
return mTunerModel; return mTunerModel;
} }
public Source getSource(SourceConfiguration config, int bandwidth, ChannelSpecification channelSpecification) public Source getSource(SourceConfiguration config, ChannelSpecification channelSpecification) throws SourceException
throws SourceException
{ {
Source retVal = null; Source retVal = null;
@@ -85,10 +84,10 @@ public class SourceManager
retVal = mMixerManager.getSource(config); retVal = mMixerManager.getSource(config);
break; break;
case TUNER: case TUNER:
retVal = mTunerModel.getSource((SourceConfigTuner) config, bandwidth, channelSpecification); retVal = mTunerModel.getSource((SourceConfigTuner) config, channelSpecification);
break; break;
case RECORDING: case RECORDING:
retVal = mRecordingSourceManager.getSource(config, bandwidth); retVal = mRecordingSourceManager.getSource(config, channelSpecification);
case NONE: case NONE:
default: default:
break; break;

View File

@@ -1,19 +1,17 @@
/******************************************************************************* /*******************************************************************************
* SDR Trunk * sdr-trunk
* Copyright (C) 2014 Dennis Sheirer * Copyright (C) 2014-2018 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* it under the terms of the GNU General Public License as published by * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* the Free Software Foundation, either version 3 of the License, or * later version.
* (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* but WITHOUT ANY WARRANTY; without even the implied warranty of * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* 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/>
* *
* 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 io.github.dsheirer.source.recording; package io.github.dsheirer.source.recording;
@@ -22,6 +20,7 @@ import io.github.dsheirer.source.Source;
import io.github.dsheirer.source.SourceException; import io.github.dsheirer.source.SourceException;
import io.github.dsheirer.source.config.SourceConfigRecording; import io.github.dsheirer.source.config.SourceConfigRecording;
import io.github.dsheirer.source.config.SourceConfiguration; import io.github.dsheirer.source.config.SourceConfiguration;
import io.github.dsheirer.source.tuner.channel.ChannelSpecification;
import io.github.dsheirer.source.tuner.channel.TunerChannel; import io.github.dsheirer.source.tuner.channel.TunerChannel;
import io.github.dsheirer.source.tuner.channel.TunerChannelSource; import io.github.dsheirer.source.tuner.channel.TunerChannelSource;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -33,64 +32,64 @@ import java.util.List;
public class RecordingSourceManager public class RecordingSourceManager
{ {
private final static Logger mLog = LoggerFactory.getLogger( RecordingSourceManager.class ); private final static Logger mLog = LoggerFactory.getLogger(RecordingSourceManager.class);
private ArrayList<Recording> mRecordings = new ArrayList<Recording>(); private ArrayList<Recording> mRecordings = new ArrayList<Recording>();
private SettingsManager mSettingsManager; private SettingsManager mSettingsManager;
public RecordingSourceManager( SettingsManager settingsManager ) public RecordingSourceManager(SettingsManager settingsManager)
{ {
mSettingsManager = settingsManager; mSettingsManager = settingsManager;
loadRecordings(); loadRecordings();
} }
/** /**
* Iterates current recordings to get a tuner channel source for the frequency * Iterates current recordings to get a tuner channel source for the frequency
* specified in the channel config's source config object * specified in the channel config's source config object
*/ */
public Source getSource( SourceConfiguration config, int bandwidth ) public Source getSource(SourceConfiguration config, ChannelSpecification channelSpecification)
throws SourceException throws SourceException
{ {
TunerChannelSource retVal = null; TunerChannelSource retVal = null;
if( config instanceof SourceConfigRecording ) if(config instanceof SourceConfigRecording)
{ {
SourceConfigRecording configRecording = (SourceConfigRecording)config; SourceConfigRecording configRecording = (SourceConfigRecording)config;
TunerChannel tunerChannel = configRecording.getTunerChannel(); TunerChannel tunerChannel = configRecording.getTunerChannel();
tunerChannel.setBandwidth( bandwidth ); tunerChannel.setBandwidth(channelSpecification.getBandwidth());
Recording recording = getRecordingFromAlias( Recording recording = getRecordingFromAlias(
configRecording.getRecordingAlias() ); configRecording.getRecordingAlias());
if( recording != null ) if(recording != null)
{ {
retVal = recording.getChannel( tunerChannel ); retVal = recording.getChannel(tunerChannel);
} }
else else
{ {
throw new SourceException( "Recording with alias name [" + throw new SourceException("Recording with alias name [" +
configRecording.getRecordingAlias() + "] is not currently available" ); configRecording.getRecordingAlias() + "] is not currently available");
} }
} }
return retVal; return retVal;
} }
public Recording getRecordingFromAlias( String alias ) public Recording getRecordingFromAlias(String alias)
{ {
for( Recording recording: mRecordings ) for(Recording recording : mRecordings)
{ {
if( recording.getRecordingConfiguration() if(recording.getRecordingConfiguration()
.getAlias().contentEquals( alias ) ) .getAlias().contentEquals(alias))
{ {
return recording; return recording;
} }
} }
return null; return null;
} }
/** /**
@@ -98,47 +97,47 @@ public class RecordingSourceManager
*/ */
public List<Recording> getRecordings() public List<Recording> getRecordings()
{ {
Collections.sort( mRecordings ); Collections.sort(mRecordings);
return mRecordings; return mRecordings;
} }
public void addRecording( Recording recording ) public void addRecording(Recording recording)
{ {
mRecordings.add( recording ); mRecordings.add(recording);
} }
public Recording addRecording( RecordingConfiguration config ) public Recording addRecording(RecordingConfiguration config)
{ {
Recording recording = new Recording( mSettingsManager, config ); Recording recording = new Recording(mSettingsManager, config);
mRecordings.add( recording ); mRecordings.add(recording);
return recording; return recording;
} }
public void removeRecording( Recording recording ) public void removeRecording(Recording recording)
{ {
/* Remove the config from the settings manager */ /* Remove the config from the settings manager */
mSettingsManager.removeRecordingConfiguration( mSettingsManager.removeRecordingConfiguration(
recording.getRecordingConfiguration() ); recording.getRecordingConfiguration());
mRecordings.remove( recording ); mRecordings.remove(recording);
} }
private void loadRecordings() private void loadRecordings()
{ {
List<RecordingConfiguration> recordingConfigurations = List<RecordingConfiguration> recordingConfigurations =
mSettingsManager.getRecordingConfigurations(); mSettingsManager.getRecordingConfigurations();
mLog.info( "RecordingSourceManager - discovered [" + mLog.info("RecordingSourceManager - discovered [" +
recordingConfigurations.size() + "] recording configurations" ); recordingConfigurations.size() + "] recording configurations");
for( RecordingConfiguration config: recordingConfigurations ) for(RecordingConfiguration config : recordingConfigurations)
{ {
Recording recording = new Recording( mSettingsManager, config ); Recording recording = new Recording(mSettingsManager, config);
mRecordings.add( recording ); mRecordings.add(recording);
} }
} }
} }

View File

@@ -340,13 +340,13 @@ public class TunerModel extends AbstractTableModel implements Listener<TunerEven
* *
* Returns null if no tuner can source the channel * Returns null if no tuner can source the channel
*/ */
public Source getSource(SourceConfigTuner config, int bandwidth, ChannelSpecification channelSpecification) public Source getSource(SourceConfigTuner config, ChannelSpecification channelSpecification)
{ {
TunerChannelSource retVal = null; TunerChannelSource retVal = null;
TunerChannel tunerChannel = config.getTunerChannel(); TunerChannel tunerChannel = config.getTunerChannel();
tunerChannel.setBandwidth(bandwidth); tunerChannel.setBandwidth(channelSpecification.getBandwidth());
Iterator<Tuner> it = mTuners.iterator(); Iterator<Tuner> it = mTuners.iterator();

View File

@@ -21,18 +21,21 @@ package io.github.dsheirer.source.tuner.channel;
public class ChannelSpecification public class ChannelSpecification
{ {
private double mMinimumSampleRate; private double mMinimumSampleRate;
private int mBandwidth;
private double mPassFrequency; private double mPassFrequency;
private double mStopFrequency; private double mStopFrequency;
/** /**
* Constructs a channel specification instance. * Constructs a channel specification instance.
* @param minimumSampleRate requested for the channel * @param minimumSampleRate requested for the channel
* @param bandwidth
* @param passFrequency for the pass band of the channel * @param passFrequency for the pass band of the channel
* @param stopFrequency for the stop band of teh channel * @param stopFrequency for the stop band of teh channel
*/ */
public ChannelSpecification(double minimumSampleRate, double passFrequency, double stopFrequency) public ChannelSpecification(double minimumSampleRate, int bandwidth, double passFrequency, double stopFrequency)
{ {
mMinimumSampleRate = minimumSampleRate; mMinimumSampleRate = minimumSampleRate;
mBandwidth = bandwidth;
mPassFrequency = passFrequency; mPassFrequency = passFrequency;
mStopFrequency = stopFrequency; mStopFrequency = stopFrequency;
} }
@@ -45,6 +48,14 @@ public class ChannelSpecification
return mMinimumSampleRate; return mMinimumSampleRate;
} }
/**
* Bandwidth of the channel in Hertz
*/
public int getBandwidth()
{
return mBandwidth;
}
/** /**
* Pass band frequency for filtering the channel * Pass band frequency for filtering the channel
*/ */