mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-20 12:36:07 -05:00
wip-channelizer
This commit is contained in:
@@ -36,18 +36,18 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.real.IOverflowListener;
|
import sample.real.IOverflowListener;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent;
|
||||||
import source.tuner.frequency.IFrequencyChangeListener;
|
import source.ISourceEventListener;
|
||||||
|
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static source.tuner.frequency.FrequencyChangeEvent.Event.NOTIFICATION_FREQUENCY_CHANGE;
|
import static source.SourceEvent.Event.NOTIFICATION_FREQUENCY_CHANGE;
|
||||||
|
|
||||||
public class ChannelState extends Module implements ICallEventProvider, IDecoderStateEventListener,
|
public class ChannelState extends Module implements ICallEventProvider, IDecoderStateEventListener,
|
||||||
IDecoderStateEventProvider, IFrequencyChangeListener, ISquelchStateProvider, IAttributeChangeRequestListener,
|
IDecoderStateEventProvider, ISourceEventListener, ISquelchStateProvider, IAttributeChangeRequestListener,
|
||||||
IOverflowListener
|
IOverflowListener
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(ChannelState.class);
|
private final static Logger mLog = LoggerFactory.getLogger(ChannelState.class);
|
||||||
@@ -66,7 +66,7 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
private ChannelType mChannelType;
|
private ChannelType mChannelType;
|
||||||
private TrafficChannelManager mTrafficChannelEndListener;
|
private TrafficChannelManager mTrafficChannelEndListener;
|
||||||
private CallEvent mTrafficChannelCallEvent;
|
private CallEvent mTrafficChannelCallEvent;
|
||||||
private FrequencyChangeListener mFrequencyChangeListener;
|
private SourceChangeListener mSourceChangeListener;
|
||||||
|
|
||||||
private boolean mSquelchLocked = false;
|
private boolean mSquelchLocked = false;
|
||||||
private boolean mSelected = false;
|
private boolean mSelected = false;
|
||||||
@@ -196,14 +196,14 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
public Listener<SourceEvent> getSourceEventListener()
|
||||||
{
|
{
|
||||||
if(mFrequencyChangeListener == null)
|
if(mSourceChangeListener == null)
|
||||||
{
|
{
|
||||||
mFrequencyChangeListener = new FrequencyChangeListener();
|
mSourceChangeListener = new SourceChangeListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
return mFrequencyChangeListener;
|
return mSourceChangeListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isStandardChannel()
|
private boolean isStandardChannel()
|
||||||
@@ -552,14 +552,14 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
/**
|
/**
|
||||||
* Listener to receive frequency change events and rebroadcast them to the decoder states
|
* Listener to receive frequency change events and rebroadcast them to the decoder states
|
||||||
*/
|
*/
|
||||||
public class FrequencyChangeListener implements Listener<FrequencyChangeEvent>
|
public class SourceChangeListener implements Listener<SourceEvent>
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void receive(FrequencyChangeEvent frequencyChangeEvent)
|
public void receive(SourceEvent sourceEvent)
|
||||||
{
|
{
|
||||||
if(frequencyChangeEvent.getEvent() == NOTIFICATION_FREQUENCY_CHANGE)
|
if(sourceEvent.getEvent() == NOTIFICATION_FREQUENCY_CHANGE)
|
||||||
{
|
{
|
||||||
long frequency = frequencyChangeEvent.getValue().longValue();
|
long frequency = sourceEvent.getValue().longValue();
|
||||||
|
|
||||||
broadcast(new DecoderStateEvent(this, Event.SOURCE_FREQUENCY, getState(), frequency));
|
broadcast(new DecoderStateEvent(this, Event.SOURCE_FREQUENCY, getState(), frequency));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package channel.traffic;
|
package channel.traffic;
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
import alias.id.priority.Priority;
|
|
||||||
import channel.state.DecoderStateEvent;
|
import channel.state.DecoderStateEvent;
|
||||||
import channel.state.IDecoderStateEventListener;
|
import channel.state.IDecoderStateEventListener;
|
||||||
import controller.channel.Channel;
|
import controller.channel.Channel;
|
||||||
@@ -27,7 +25,6 @@ import controller.channel.Channel.ChannelType;
|
|||||||
import controller.channel.ChannelEvent;
|
import controller.channel.ChannelEvent;
|
||||||
import controller.channel.ChannelEvent.Event;
|
import controller.channel.ChannelEvent.Event;
|
||||||
import controller.channel.ChannelModel;
|
import controller.channel.ChannelModel;
|
||||||
import controller.channel.ChannelProcessingManager;
|
|
||||||
import controller.channel.TrafficChannelEvent;
|
import controller.channel.TrafficChannelEvent;
|
||||||
import module.Module;
|
import module.Module;
|
||||||
import module.decode.config.DecodeConfiguration;
|
import module.decode.config.DecodeConfiguration;
|
||||||
@@ -40,7 +37,6 @@ import record.config.RecordConfiguration;
|
|||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import source.config.SourceConfigTuner;
|
import source.config.SourceConfigTuner;
|
||||||
import source.tuner.TunerChannel;
|
import source.tuner.TunerChannel;
|
||||||
import source.tuner.TunerChannel.Type;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -193,8 +189,8 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
|
|||||||
|
|
||||||
if(frequency > 0)
|
if(frequency > 0)
|
||||||
{
|
{
|
||||||
Channel channel = getChannel(callEvent.getChannel(), new TunerChannel(Type.TRAFFIC,
|
Channel channel = getChannel(callEvent.getChannel(), new TunerChannel(frequency,
|
||||||
frequency, mDecodeConfiguration.getDecoderType().getChannelBandwidth()));
|
mDecodeConfiguration.getDecoderType().getChannelBandwidth()));
|
||||||
|
|
||||||
if(channel != null)
|
if(channel != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,9 +34,8 @@ import source.config.SourceConfigRecording;
|
|||||||
import source.config.SourceConfigTuner;
|
import source.config.SourceConfigTuner;
|
||||||
import source.config.SourceConfiguration;
|
import source.config.SourceConfiguration;
|
||||||
import source.tuner.TunerChannel;
|
import source.tuner.TunerChannel;
|
||||||
import source.tuner.TunerChannel.Type;
|
import source.SourceEvent;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent.Event;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
@@ -46,7 +45,7 @@ import javax.xml.bind.annotation.XmlTransient;
|
|||||||
|
|
||||||
@XmlSeeAlso({Configuration.class})
|
@XmlSeeAlso({Configuration.class})
|
||||||
@XmlRootElement(name = "channel")
|
@XmlRootElement(name = "channel")
|
||||||
public class Channel extends Configuration implements Listener<FrequencyChangeEvent>
|
public class Channel extends Configuration implements Listener<SourceEvent>
|
||||||
{
|
{
|
||||||
// Standard channels are persisted and traffic channels are temporary
|
// Standard channels are persisted and traffic channels are temporary
|
||||||
public enum ChannelType
|
public enum ChannelType
|
||||||
@@ -418,15 +417,14 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
|||||||
{
|
{
|
||||||
SourceConfigTuner config = (SourceConfigTuner)mSourceConfiguration;
|
SourceConfigTuner config = (SourceConfigTuner)mSourceConfiguration;
|
||||||
|
|
||||||
mTunerChannel = new TunerChannel(Type.LOCKED, config.getFrequency(),
|
mTunerChannel = new TunerChannel(config.getFrequency(),
|
||||||
mDecodeConfiguration.getDecoderType().getChannelBandwidth());
|
mDecodeConfiguration.getDecoderType().getChannelBandwidth());
|
||||||
}
|
}
|
||||||
else if(mSourceConfiguration.getSourceType() == SourceType.RECORDING)
|
else if(mSourceConfiguration.getSourceType() == SourceType.RECORDING)
|
||||||
{
|
{
|
||||||
SourceConfigRecording config =
|
SourceConfigRecording config = (SourceConfigRecording)mSourceConfiguration;
|
||||||
(SourceConfigRecording)mSourceConfiguration;
|
|
||||||
|
|
||||||
mTunerChannel = new TunerChannel(Type.LOCKED, config.getFrequency(),
|
mTunerChannel = new TunerChannel(config.getFrequency(),
|
||||||
mDecodeConfiguration.getDecoderType().getChannelBandwidth());
|
mDecodeConfiguration.getDecoderType().getChannelBandwidth());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -452,7 +450,7 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
|||||||
* be used to visually show in the spectral display.
|
* be used to visually show in the spectral display.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void receive(FrequencyChangeEvent event)
|
public void receive(SourceEvent event)
|
||||||
{
|
{
|
||||||
if(event.getEvent() == Event.NOTIFICATION_CHANNEL_FREQUENCY_CORRECTION_CHANGE)
|
if(event.getEvent() == Event.NOTIFICATION_CHANNEL_FREQUENCY_CORRECTION_CHANGE)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -567,7 +567,7 @@ public class FilterFactory
|
|||||||
* For 40db attenuation, calculate the number of symbols based on the following formula:
|
* For 40db attenuation, calculate the number of symbols based on the following formula:
|
||||||
* Symbols = -44 * alpha + 33
|
* Symbols = -44 * alpha + 33
|
||||||
*
|
*
|
||||||
* Polyphase Channelizer notes:
|
* Polyphase TunerChannelizer notes:
|
||||||
* -Set samples Per Symbol at 2 (or more) * number of channels
|
* -Set samples Per Symbol at 2 (or more) * number of channels
|
||||||
* -Set symbolCount to sufficient size to produce required attenuation
|
* -Set symbolCount to sufficient size to produce required attenuation
|
||||||
* -Set symbol rate in hertz
|
* -Set symbol rate in hertz
|
||||||
@@ -725,7 +725,7 @@ public class FilterFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a windowed-sync (Nyquist) M/2 prototype FIR filter for use with a Polyphase Channelizer/Synthesizer.
|
* Creates a windowed-sync (Nyquist) M/2 prototype FIR filter for use with a Polyphase TunerChannelizer/Synthesizer.
|
||||||
* The filter is designed for x2 oversampling of each channel and the filter cutoff frequency is incrementally
|
* The filter is designed for x2 oversampling of each channel and the filter cutoff frequency is incrementally
|
||||||
* adjusted to achieve a -6.02 dB attenuation at the channel band edge to enable perfect reconstruction of adjacent
|
* adjusted to achieve a -6.02 dB attenuation at the channel band edge to enable perfect reconstruction of adjacent
|
||||||
* channels.
|
* channels.
|
||||||
@@ -833,7 +833,7 @@ public class FilterFactory
|
|||||||
|
|
||||||
if(logResults)
|
if(logResults)
|
||||||
{
|
{
|
||||||
mLog.debug("Polyphase Channelizer Filter Design Summary");
|
mLog.debug("Polyphase TunerChannelizer Filter Design Summary");
|
||||||
mLog.debug("-------------------------------------------");
|
mLog.debug("-------------------------------------------");
|
||||||
mLog.debug("Channels: " + channels);
|
mLog.debug("Channels: " + channels);
|
||||||
mLog.debug("Taps Per Channel: " + tapsPerChannel);
|
mLog.debug("Taps Per Channel: " + tapsPerChannel);
|
||||||
|
|||||||
@@ -0,0 +1,128 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* 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 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 dsp.filter.channelizer;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import sample.Broadcaster;
|
||||||
|
import sample.Listener;
|
||||||
|
import sample.complex.ComplexBuffer;
|
||||||
|
import source.ISourceEventListener;
|
||||||
|
import source.SourceEvent;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
public abstract class AbstractComplexPolyphaseChannelizer implements Listener<ComplexBuffer>, ISourceEventListener
|
||||||
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger(AbstractComplexPolyphaseChannelizer.class);
|
||||||
|
|
||||||
|
private Broadcaster<SourceEvent> mSourceChangeBroadcaster = new Broadcaster();
|
||||||
|
private List<PolyphaseChannelSource> mChannels = new CopyOnWriteArrayList<>();
|
||||||
|
private int mChannelCount;
|
||||||
|
private int mChannelSampleRate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Complex sample polyphase channelizer
|
||||||
|
*
|
||||||
|
* @param channelCount
|
||||||
|
*/
|
||||||
|
public AbstractComplexPolyphaseChannelizer(int channelCount, int channelSampleRate)
|
||||||
|
{
|
||||||
|
mChannelCount = channelCount;
|
||||||
|
mChannelSampleRate = channelSampleRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of channels being processed by this channelizer.
|
||||||
|
*/
|
||||||
|
public int getChannelCount()
|
||||||
|
{
|
||||||
|
return mChannelCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output sample rate for each channel
|
||||||
|
* @return sample rate in hertz
|
||||||
|
*/
|
||||||
|
public int getChannelSampleRate()
|
||||||
|
{
|
||||||
|
return mChannelSampleRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters the complex sample pair
|
||||||
|
*
|
||||||
|
* @param inphase sample
|
||||||
|
* @param quadrature sample
|
||||||
|
*/
|
||||||
|
protected abstract void filter(float inphase, float quadrature);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receive(ComplexBuffer complexBuffer)
|
||||||
|
{
|
||||||
|
float[] samples = complexBuffer.getSamples();
|
||||||
|
|
||||||
|
for(int x = 0; x < samples.length; x += 2)
|
||||||
|
{
|
||||||
|
filter(samples[x], samples[x + 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatches the processed channel samples to any registered polyphase channel outputs.
|
||||||
|
*
|
||||||
|
* @param channels containing an array of I/Q samples per channel
|
||||||
|
*/
|
||||||
|
protected void dispatch(float[] channels)
|
||||||
|
{
|
||||||
|
for(PolyphaseChannelSource channel : mChannels)
|
||||||
|
{
|
||||||
|
channel.processChannels(channels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the polyphase channel source to receive processed output channel samples
|
||||||
|
*
|
||||||
|
* @param polyphaseChannelSource
|
||||||
|
*/
|
||||||
|
public void addChannel(PolyphaseChannelSource polyphaseChannelSource)
|
||||||
|
{
|
||||||
|
mChannels.add(polyphaseChannelSource);
|
||||||
|
mSourceChangeBroadcaster.addListener(polyphaseChannelSource.getSourceEventListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the polyphase channel source from receiving output channel samples.
|
||||||
|
*
|
||||||
|
* @param polyphaseChannelSource
|
||||||
|
*/
|
||||||
|
public void removeChannel(PolyphaseChannelSource polyphaseChannelSource)
|
||||||
|
{
|
||||||
|
mChannels.remove(polyphaseChannelSource);
|
||||||
|
mSourceChangeBroadcaster.removeListener(polyphaseChannelSource.getSourceEventListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener<SourceEvent> getSourceEventListener()
|
||||||
|
{
|
||||||
|
return mSourceChangeBroadcaster;
|
||||||
|
}
|
||||||
|
}
|
||||||
135
src/dsp/filter/channelizer/Channelizer.java
Normal file
135
src/dsp/filter/channelizer/Channelizer.java
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* 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 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 dsp.filter.channelizer;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import sample.Listener;
|
||||||
|
import source.ISourceEventProcessor;
|
||||||
|
import source.Source;
|
||||||
|
import source.SourceEvent;
|
||||||
|
import source.tuner.Tuner;
|
||||||
|
import source.tuner.TunerChannel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
public class Channelizer implements ISourceEventProcessor, Listener<SourceEvent>
|
||||||
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger(Channelizer.class);
|
||||||
|
|
||||||
|
private Tuner mTuner;
|
||||||
|
private List<PolyphaseChannelSource> mChannelSources = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Digital Drop Channel (DDC) sources from the tuner. Incorporates a polyphase channelizer
|
||||||
|
* with downstream channel and upstream tuner management.
|
||||||
|
*
|
||||||
|
* @param tuner providing broadband sample buffers
|
||||||
|
*/
|
||||||
|
public Channelizer(Tuner tuner)
|
||||||
|
{
|
||||||
|
mTuner = tuner;
|
||||||
|
mTuner.addSourceEventListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Source getChannel(TunerChannel tunerChannel)
|
||||||
|
{
|
||||||
|
//TODO: return a polyphase channel here
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts/adds the channel source to receive channelized sample buffers, registering with the tuner to receive
|
||||||
|
* sample buffers when this is the first channel.
|
||||||
|
*
|
||||||
|
* @param channelSource to start
|
||||||
|
*/
|
||||||
|
private void startChannelSource(PolyphaseChannelSource channelSource)
|
||||||
|
{
|
||||||
|
if(mChannelSources.isEmpty())
|
||||||
|
{
|
||||||
|
//TODO: start the tuner
|
||||||
|
}
|
||||||
|
|
||||||
|
mChannelSources.add(channelSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops/removes the channel source from receiving channelized sample buffers and deregisters from the tuner
|
||||||
|
* if this is the last channel being sourced.
|
||||||
|
*
|
||||||
|
* @param channelSource to stop
|
||||||
|
*/
|
||||||
|
private void stopChannelSource(PolyphaseChannelSource channelSource)
|
||||||
|
{
|
||||||
|
mChannelSources.remove(channelSource);
|
||||||
|
|
||||||
|
if(mChannelSources.isEmpty())
|
||||||
|
{
|
||||||
|
//TODO: stop the tuner
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mTuner != null)
|
||||||
|
{
|
||||||
|
//TODO: change the tuner to accept a remove(TunerChannel) method
|
||||||
|
// mTuner.remove(channel.getTunerChannel());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(SourceEvent sourceEvent)
|
||||||
|
{
|
||||||
|
switch(sourceEvent.getEvent())
|
||||||
|
{
|
||||||
|
case REQUEST_START_SAMPLE_STREAM:
|
||||||
|
if(sourceEvent.hasSource() && sourceEvent.getSource() instanceof PolyphaseChannelSource)
|
||||||
|
{
|
||||||
|
startChannelSource((PolyphaseChannelSource)sourceEvent.getSource());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mLog.error("Request to stop sample stream for unrecognized source: " +
|
||||||
|
(sourceEvent.hasSource() ? sourceEvent.getSource().getClass() : "null source"));
|
||||||
|
}
|
||||||
|
//TODO: add the channel and register for samples from the tuner
|
||||||
|
break;
|
||||||
|
case REQUEST_STOP_SAMPLE_STREAM:
|
||||||
|
if(sourceEvent.hasSource() && sourceEvent.getSource() instanceof PolyphaseChannelSource)
|
||||||
|
{
|
||||||
|
stopChannelSource((PolyphaseChannelSource)sourceEvent.getSource());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mLog.error("Request to stop sample stream for unrecognized source: " +
|
||||||
|
(sourceEvent.hasSource() ? sourceEvent.getSource().getClass() : "null source"));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receive(SourceEvent sourceEvent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,6 @@ package dsp.filter.channelizer;
|
|||||||
|
|
||||||
import dsp.filter.FilterFactory;
|
import dsp.filter.FilterFactory;
|
||||||
import dsp.filter.Window;
|
import dsp.filter.Window;
|
||||||
import dsp.filter.correction.IQCorrectionFilter;
|
|
||||||
import dsp.filter.design.FilterDesignException;
|
import dsp.filter.design.FilterDesignException;
|
||||||
import dsp.mixer.LowPhaseNoiseOscillator;
|
import dsp.mixer.LowPhaseNoiseOscillator;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
@@ -31,7 +30,7 @@ import sample.SampleType;
|
|||||||
import sample.complex.ComplexBuffer;
|
import sample.complex.ComplexBuffer;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import source.tuner.configuration.TunerConfigurationModel;
|
import source.tuner.configuration.TunerConfigurationModel;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent;
|
||||||
import spectrum.DFTProcessor;
|
import spectrum.DFTProcessor;
|
||||||
import spectrum.DFTSize;
|
import spectrum.DFTSize;
|
||||||
import spectrum.SpectrumPanel;
|
import spectrum.SpectrumPanel;
|
||||||
@@ -86,7 +85,7 @@ public class ChannelizerViewer extends JFrame
|
|||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
setTitle("Channelizer Viewer");
|
setTitle("TunerChannelizer Viewer");
|
||||||
setSize(1000, 800);
|
setSize(1000, 800);
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
|
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
|
||||||
@@ -212,7 +211,7 @@ public class ChannelizerViewer extends JFrame
|
|||||||
|
|
||||||
public class ChannelArrayPanel extends JPanel implements Listener<ComplexBuffer>
|
public class ChannelArrayPanel extends JPanel implements Listener<ComplexBuffer>
|
||||||
{
|
{
|
||||||
private ComplexPolyphaseChannelizerM2 mPolyphaseChannelizer;
|
private ComplexPolyphaseChannelizer mPolyphaseChannelizer;
|
||||||
private ChannelDistributor mChannelDistributor;
|
private ChannelDistributor mChannelDistributor;
|
||||||
|
|
||||||
public ChannelArrayPanel(float[] taps)
|
public ChannelArrayPanel(float[] taps)
|
||||||
@@ -223,7 +222,7 @@ public class ChannelizerViewer extends JFrame
|
|||||||
bufferSize++;
|
bufferSize++;
|
||||||
}
|
}
|
||||||
|
|
||||||
mPolyphaseChannelizer = new ComplexPolyphaseChannelizerM2(taps, mChannelCount);
|
mPolyphaseChannelizer = new ComplexPolyphaseChannelizer(taps, mChannelCount, CHANNEL_BANDWIDTH);
|
||||||
mChannelDistributor = new ChannelDistributor(bufferSize, mChannelCount);
|
mChannelDistributor = new ChannelDistributor(bufferSize, mChannelCount);
|
||||||
mPolyphaseChannelizer.setChannelDistributor(mChannelDistributor);
|
mPolyphaseChannelizer.setChannelDistributor(mChannelDistributor);
|
||||||
|
|
||||||
@@ -272,8 +271,7 @@ public class ChannelizerViewer extends JFrame
|
|||||||
add(mSpectrumPanel);
|
add(mSpectrumPanel);
|
||||||
|
|
||||||
mDFTProcessor.addConverter(mComplexDecibelConverter);
|
mDFTProcessor.addConverter(mComplexDecibelConverter);
|
||||||
mDFTProcessor.frequencyChanged(new FrequencyChangeEvent(
|
mDFTProcessor.process(SourceEvent.sampleRateChange(sampleRate));
|
||||||
FrequencyChangeEvent.Event.NOTIFICATION_SAMPLE_RATE_CHANGE, sampleRate));
|
|
||||||
mComplexDecibelConverter.addListener(mSpectrumPanel);
|
mComplexDecibelConverter.addListener(mSpectrumPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,44 +25,40 @@ import dsp.mixer.Oscillator;
|
|||||||
import org.jtransforms.fft.FloatFFT_1D;
|
import org.jtransforms.fft.FloatFFT_1D;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import sample.Listener;
|
|
||||||
import sample.complex.ComplexBuffer;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
public class ComplexPolyphaseChannelizer extends AbstractComplexPolyphaseChannelizer
|
||||||
|
|
||||||
public class ComplexPolyphaseChannelizer implements Listener<ComplexBuffer>
|
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(ComplexPolyphaseChannelizer.class);
|
private final static Logger mLog = LoggerFactory.getLogger(ComplexPolyphaseChannelizer.class);
|
||||||
|
|
||||||
private RealFIRFilter[] mInphaseFilters;
|
private RealFIRFilter[] mInphaseFilters;
|
||||||
private RealFIRFilter[] mQuadratureFilters;
|
private RealFIRFilter[] mQuadratureFilters;
|
||||||
private int mFilterPointer = 0;
|
private int mFilterPointer = 0;
|
||||||
private int mChannelCount;
|
|
||||||
private float[] mFilteredSamples;
|
private float[] mFilteredSamples;
|
||||||
private FloatFFT_1D mFFT;
|
private FloatFFT_1D mFFT;
|
||||||
private ChannelDistributor mChannelDistributor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximally Decimated Polyphase Filter Bank (MDPFB) channelizer that divides the input frequency band into
|
* Maximally Decimated Polyphase Filter Bank (MDPFB) channelizer that divides the input frequency band into
|
||||||
* equal bandwidth channels.
|
* equal bandwidth channels.
|
||||||
*
|
*
|
||||||
* @param taps of a low-pass filter designed for the inbound sample rate with a cutoff frequency
|
* @param coefficients of a prototype low-pass filter designed for the inbound sample rate with a cutoff frequency
|
||||||
* equal to the channel bandwidth (sample rate / filters). If you need to synthesize (combine two or more
|
* equal to the channel bandwidth (sample rate / filters). If you need to synthesize (combine two or more
|
||||||
* filte outputs) a new bandwidth signal from the outputs of this filter, then the filter should be designed
|
* filter outputs) a new bandwidth signal from the outputs of this filter, then the filter should be designed
|
||||||
* as a nyquist filter with -6 dB attenuation at the channel bandwidth cutoff frequency
|
* as a nyquist filter with -6 dB attenuation at the channel bandwidth cutoff frequency
|
||||||
*
|
*
|
||||||
* @param channels - number of channels to output.
|
* @param channelCount - number of channels to output.
|
||||||
|
* @param channelSampleRate - channel sample rate (after decimation)
|
||||||
*/
|
*/
|
||||||
public ComplexPolyphaseChannelizer(float[] taps, int channels)
|
public ComplexPolyphaseChannelizer(float[] coefficients, int channelCount, int channelSampleRate)
|
||||||
{
|
{
|
||||||
mChannelCount = channels;
|
super(channelCount, channelSampleRate);
|
||||||
|
|
||||||
initFilters(taps);
|
initFilters(coefficients);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void filter(float inphase, float quadrature)
|
@Override
|
||||||
|
protected void filter(float inphase, float quadrature)
|
||||||
{
|
{
|
||||||
int index = (mChannelCount - mFilterPointer - 1) * 2;
|
int index = (getChannelCount() - mFilterPointer - 1) * 2;
|
||||||
|
|
||||||
mFilteredSamples[index] = mInphaseFilters[mFilterPointer].filter(inphase);
|
mFilteredSamples[index] = mInphaseFilters[mFilterPointer].filter(inphase);
|
||||||
mFilteredSamples[index + 1] = mQuadratureFilters[mFilterPointer].filter(quadrature);
|
mFilteredSamples[index + 1] = mQuadratureFilters[mFilterPointer].filter(quadrature);
|
||||||
@@ -70,7 +66,7 @@ public class ComplexPolyphaseChannelizer implements Listener<ComplexBuffer>
|
|||||||
if(mFilterPointer == 0)
|
if(mFilterPointer == 0)
|
||||||
{
|
{
|
||||||
calculate();
|
calculate();
|
||||||
mFilterPointer = mChannelCount - 1;
|
mFilterPointer = getChannelCount() - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -78,20 +74,9 @@ public class ComplexPolyphaseChannelizer implements Listener<ComplexBuffer>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive(ComplexBuffer complexBuffer)
|
|
||||||
{
|
|
||||||
float[] samples = complexBuffer.getSamples();
|
|
||||||
|
|
||||||
for(int x = 0; x < samples.length; x += 2)
|
|
||||||
{
|
|
||||||
filter(samples[x], samples[x + 1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void calculate()
|
private void calculate()
|
||||||
{
|
{
|
||||||
float[] samples = new float[mChannelCount * 2];
|
float[] samples = new float[getChannelCount() * 2];
|
||||||
System.arraycopy(mFilteredSamples, 0, samples, 0, mFilteredSamples.length);
|
System.arraycopy(mFilteredSamples, 0, samples, 0, mFilteredSamples.length);
|
||||||
|
|
||||||
//FFT is executed in-place where the output overwrites the input
|
//FFT is executed in-place where the output overwrites the input
|
||||||
@@ -100,24 +85,6 @@ public class ComplexPolyphaseChannelizer implements Listener<ComplexBuffer>
|
|||||||
dispatch(samples);
|
dispatch(samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dispatch(float[] channels)
|
|
||||||
{
|
|
||||||
if(mChannelDistributor != null)
|
|
||||||
{
|
|
||||||
mChannelDistributor.receive(channels);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChannelDistributor(ChannelDistributor channelDistributor)
|
|
||||||
{
|
|
||||||
mChannelDistributor = channelDistributor;
|
|
||||||
}
|
|
||||||
|
|
||||||
private double magnitude(float real, float imaginary, int fftSize)
|
|
||||||
{
|
|
||||||
return Math.sqrt(Math.pow(real, 2.0) + Math.pow(imaginary, 2.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Distributes the filter taps to each of the polyphase filters
|
* Distributes the filter taps to each of the polyphase filters
|
||||||
*
|
*
|
||||||
@@ -125,15 +92,15 @@ public class ComplexPolyphaseChannelizer implements Listener<ComplexBuffer>
|
|||||||
*/
|
*/
|
||||||
private void initFilters(float[] taps)
|
private void initFilters(float[] taps)
|
||||||
{
|
{
|
||||||
int tapCount = (int)Math.ceil((double)taps.length / (double)mChannelCount);
|
int tapCount = (int)Math.ceil((double)taps.length / (double)getChannelCount());
|
||||||
|
|
||||||
float[][] coefficients = new float[mChannelCount][tapCount];
|
float[][] coefficients = new float[getChannelCount()][tapCount];
|
||||||
|
|
||||||
for(int tap = 0; tap < tapCount; tap++)
|
for(int tap = 0; tap < tapCount; tap++)
|
||||||
{
|
{
|
||||||
for(int filter = 0; filter < mChannelCount; filter++)
|
for(int filter = 0; filter < getChannelCount(); filter++)
|
||||||
{
|
{
|
||||||
int index = tap * mChannelCount + filter;
|
int index = tap * getChannelCount() + filter;
|
||||||
|
|
||||||
if(index < taps.length)
|
if(index < taps.length)
|
||||||
{
|
{
|
||||||
@@ -142,18 +109,18 @@ public class ComplexPolyphaseChannelizer implements Listener<ComplexBuffer>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mInphaseFilters = new RealFIRFilter[mChannelCount];
|
mInphaseFilters = new RealFIRFilter[getChannelCount()];
|
||||||
mQuadratureFilters = new RealFIRFilter[mChannelCount];
|
mQuadratureFilters = new RealFIRFilter[getChannelCount()];
|
||||||
|
|
||||||
for(int filter = 0; filter < mChannelCount; filter++)
|
for(int filter = 0; filter < getChannelCount(); filter++)
|
||||||
{
|
{
|
||||||
mInphaseFilters[filter] = new RealFIRFilter(coefficients[filter], 1.0f);
|
mInphaseFilters[filter] = new RealFIRFilter(coefficients[filter], 1.0f);
|
||||||
mQuadratureFilters[filter] = new RealFIRFilter(coefficients[filter], 1.0f);
|
mQuadratureFilters[filter] = new RealFIRFilter(coefficients[filter], 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
mFilteredSamples = new float[mChannelCount * 2];
|
mFilteredSamples = new float[getChannelCount() * 2];
|
||||||
mFFT = new FloatFFT_1D(mChannelCount);
|
mFFT = new FloatFFT_1D(getChannelCount());
|
||||||
mFilterPointer = mChannelCount -1;
|
mFilterPointer = getChannelCount() -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
@@ -171,14 +138,14 @@ public class ComplexPolyphaseChannelizer implements Listener<ComplexBuffer>
|
|||||||
int channelCenter = (int)(12500 * 1.5);
|
int channelCenter = (int)(12500 * 1.5);
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("\nPolyphase Channelizer\n");
|
sb.append("\nPolyphase TunerChannelizer\n");
|
||||||
sb.append("Sample Rate:" + sampleRate + " Channels:" + channels + " Channel Rate:" + channelBandwidth + "\n");
|
sb.append("Sample Rate:" + sampleRate + " Channels:" + channels + " Channel Rate:" + channelBandwidth + "\n");
|
||||||
sb.append("Tap Count:" + taps.length + "\n");
|
sb.append("Tap Count:" + taps.length + "\n");
|
||||||
sb.append("Channel:" + channelCenter);
|
sb.append("Channel:" + channelCenter);
|
||||||
|
|
||||||
mLog.debug(sb.toString());
|
mLog.debug(sb.toString());
|
||||||
|
|
||||||
ComplexPolyphaseChannelizer channelizer = new ComplexPolyphaseChannelizer(taps, 8);
|
ComplexPolyphaseChannelizer channelizer = new ComplexPolyphaseChannelizer(taps, 8, channelBandwidth);
|
||||||
|
|
||||||
Oscillator oscillator = new Oscillator(channelCenter, 2 * sampleRate);
|
Oscillator oscillator = new Oscillator(channelCenter, 2 * sampleRate);
|
||||||
|
|
||||||
|
|||||||
@@ -25,21 +25,18 @@ import dsp.mixer.Oscillator;
|
|||||||
import org.jtransforms.fft.FloatFFT_1D;
|
import org.jtransforms.fft.FloatFFT_1D;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import sample.Listener;
|
|
||||||
import sample.complex.ComplexBuffer;
|
import sample.complex.ComplexBuffer;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
public class ComplexPolyphaseChannelizerM2 implements Listener<ComplexBuffer>
|
public class ComplexPolyphaseChannelizerM2 extends AbstractComplexPolyphaseChannelizer
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(ComplexPolyphaseChannelizerM2.class);
|
private final static Logger mLog = LoggerFactory.getLogger(ComplexPolyphaseChannelizerM2.class);
|
||||||
|
|
||||||
private ReverseFloatCircularBuffer[] mDataBuffers;
|
private ReverseFloatCircularBuffer[] mDataBuffers;
|
||||||
private float[][] mFilterCoefficients;
|
private float[][] mFilterCoefficients;
|
||||||
private int mFilterPointer = 0;
|
private int mFilterPointer = 0;
|
||||||
private int mChannelCount;
|
|
||||||
private FloatFFT_1D mFFT;
|
private FloatFFT_1D mFFT;
|
||||||
private ChannelDistributor mChannelDistributor;
|
|
||||||
|
|
||||||
private DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.0000");
|
private DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.0000");
|
||||||
|
|
||||||
@@ -51,23 +48,23 @@ public class ComplexPolyphaseChannelizerM2 implements Listener<ComplexBuffer>
|
|||||||
* equal to the channel bandwidth (sample rate / filters). If you need to synthesize (combine two or more
|
* equal to the channel bandwidth (sample rate / filters). If you need to synthesize (combine two or more
|
||||||
* filte outputs) a new bandwidth signal from the outputs of this filter, then the filter should be designed
|
* filte outputs) a new bandwidth signal from the outputs of this filter, then the filter should be designed
|
||||||
* as a nyquist filter with -6 dB attenuation at the channel bandwidth cutoff frequency
|
* as a nyquist filter with -6 dB attenuation at the channel bandwidth cutoff frequency
|
||||||
*
|
|
||||||
* @param channels - number of filters/channels to output. Since this filter bank oversamples each filter
|
* @param channels - number of filters/channels to output. Since this filter bank oversamples each filter
|
||||||
* output, this number must be even (divisible by the oversample rate).
|
* output, this number must be even (divisible by the oversample rate).
|
||||||
|
* @param channelSampleRate for each decimated, oversampled channel
|
||||||
*/
|
*/
|
||||||
public ComplexPolyphaseChannelizerM2(float[] taps, int channels)
|
public ComplexPolyphaseChannelizerM2(float[] taps, int channels, int channelSampleRate)
|
||||||
{
|
{
|
||||||
|
super(channels, channelSampleRate);
|
||||||
|
|
||||||
if(channels % 2 != 0)
|
if(channels % 2 != 0)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("Channel count must be a multiple of 2");
|
throw new IllegalArgumentException("Channel count must be a multiple of 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
mChannelCount = channels;
|
|
||||||
|
|
||||||
initFilters(taps);
|
initFilters(taps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void filter(float inphase, float quadrature)
|
protected void filter(float inphase, float quadrature)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -77,9 +74,9 @@ public class ComplexPolyphaseChannelizerM2 implements Listener<ComplexBuffer>
|
|||||||
if(mFilterPointer == 0)
|
if(mFilterPointer == 0)
|
||||||
{
|
{
|
||||||
calculate();
|
calculate();
|
||||||
mFilterPointer = mChannelCount * 2;
|
mFilterPointer = getChannelCount() * 2;
|
||||||
}
|
}
|
||||||
else if(mFilterPointer == mChannelCount)
|
else if(mFilterPointer == getChannelCount())
|
||||||
{
|
{
|
||||||
calculate();
|
calculate();
|
||||||
}
|
}
|
||||||
@@ -92,20 +89,9 @@ public class ComplexPolyphaseChannelizerM2 implements Listener<ComplexBuffer>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive(ComplexBuffer complexBuffer)
|
|
||||||
{
|
|
||||||
float[] samples = complexBuffer.getSamples();
|
|
||||||
|
|
||||||
for(int x = 0; x < samples.length; x += 2)
|
|
||||||
{
|
|
||||||
filter(samples[x], samples[x + 1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void calculate()
|
private void calculate()
|
||||||
{
|
{
|
||||||
float[] samples = new float[mChannelCount * 2];
|
float[] samples = new float[getChannelCount() * 2];
|
||||||
|
|
||||||
if(mFilterPointer == 0)
|
if(mFilterPointer == 0)
|
||||||
{
|
{
|
||||||
@@ -158,6 +144,7 @@ public class ComplexPolyphaseChannelizerM2 implements Listener<ComplexBuffer>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the samples contained in the buffer against the filter coefficients
|
* Filters the samples contained in the buffer against the filter coefficients
|
||||||
|
*
|
||||||
* @param coefficients of the sub filter
|
* @param coefficients of the sub filter
|
||||||
* @param buffer containing data samples
|
* @param buffer containing data samples
|
||||||
* @return
|
* @return
|
||||||
@@ -174,24 +161,6 @@ public class ComplexPolyphaseChannelizerM2 implements Listener<ComplexBuffer>
|
|||||||
return accumulator;
|
return accumulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dispatch(float[] channels)
|
|
||||||
{
|
|
||||||
if(mChannelDistributor != null)
|
|
||||||
{
|
|
||||||
mChannelDistributor.receive(channels);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChannelDistributor(ChannelDistributor channelDistributor)
|
|
||||||
{
|
|
||||||
mChannelDistributor = channelDistributor;
|
|
||||||
}
|
|
||||||
|
|
||||||
private double magnitude(float real, float imaginary, int fftSize)
|
|
||||||
{
|
|
||||||
return Math.sqrt(Math.pow(real, 2.0) + Math.pow(imaginary, 2.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Distributes the filter taps to each of the polyphase filters
|
* Distributes the filter taps to each of the polyphase filters
|
||||||
*
|
*
|
||||||
@@ -199,22 +168,22 @@ public class ComplexPolyphaseChannelizerM2 implements Listener<ComplexBuffer>
|
|||||||
*/
|
*/
|
||||||
private void initFilters(float[] taps)
|
private void initFilters(float[] taps)
|
||||||
{
|
{
|
||||||
int tapCount = (int)Math.ceil((double)taps.length / (double)mChannelCount);
|
int tapCount = (int)Math.ceil((double)taps.length / (double)getChannelCount());
|
||||||
|
|
||||||
mDataBuffers = new ReverseFloatCircularBuffer[mChannelCount * 2];
|
mDataBuffers = new ReverseFloatCircularBuffer[getChannelCount() * 2];
|
||||||
|
|
||||||
for(int x = 0; x < mChannelCount * 2; x++)
|
for(int x = 0; x < getChannelCount() * 2; x++)
|
||||||
{
|
{
|
||||||
mDataBuffers[x] = new ReverseFloatCircularBuffer(tapCount);
|
mDataBuffers[x] = new ReverseFloatCircularBuffer(tapCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
mFilterCoefficients = new float[mChannelCount][tapCount];
|
mFilterCoefficients = new float[getChannelCount()][tapCount];
|
||||||
|
|
||||||
for(int tap = 0; tap < tapCount; tap++)
|
for(int tap = 0; tap < tapCount; tap++)
|
||||||
{
|
{
|
||||||
for(int filter = 0; filter < mChannelCount; filter++)
|
for(int filter = 0; filter < getChannelCount(); filter++)
|
||||||
{
|
{
|
||||||
int index = tap * mChannelCount + filter;
|
int index = tap * getChannelCount() + filter;
|
||||||
|
|
||||||
if(index < taps.length)
|
if(index < taps.length)
|
||||||
{
|
{
|
||||||
@@ -223,8 +192,8 @@ public class ComplexPolyphaseChannelizerM2 implements Listener<ComplexBuffer>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mFFT = new FloatFFT_1D(mChannelCount);
|
mFFT = new FloatFFT_1D(getChannelCount());
|
||||||
mFilterPointer = mChannelCount - 1; //Start at M/2
|
mFilterPointer = getChannelCount() - 1; //Start at M/2
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
@@ -242,14 +211,14 @@ public class ComplexPolyphaseChannelizerM2 implements Listener<ComplexBuffer>
|
|||||||
int channelCenter = (int)(12500 * 1.5);
|
int channelCenter = (int)(12500 * 1.5);
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("\nPolyphase Channelizer\n");
|
sb.append("\nPolyphase TunerChannelizer\n");
|
||||||
sb.append("Sample Rate:" + sampleRate + " Channels:" + channels + " Channel Rate:" + channelBandwidth + "\n");
|
sb.append("Sample Rate:" + sampleRate + " Channels:" + channels + " Channel Rate:" + channelBandwidth + "\n");
|
||||||
sb.append("Tap Count:" + taps.length + "\n");
|
sb.append("Tap Count:" + taps.length + "\n");
|
||||||
sb.append("Channel:" + channelCenter);
|
sb.append("Channel:" + channelCenter);
|
||||||
|
|
||||||
mLog.debug(sb.toString());
|
mLog.debug(sb.toString());
|
||||||
|
|
||||||
ComplexPolyphaseChannelizerM2 channelizer = new ComplexPolyphaseChannelizerM2(taps, 8);
|
ComplexPolyphaseChannelizerM2 channelizer = new ComplexPolyphaseChannelizerM2(taps, 8, channelBandwidth * 2);
|
||||||
|
|
||||||
Oscillator oscillator = new Oscillator(channelCenter, 2 * sampleRate);
|
Oscillator oscillator = new Oscillator(channelCenter, 2 * sampleRate);
|
||||||
|
|
||||||
|
|||||||
201
src/dsp/filter/channelizer/PolyphaseChannelSource.java
Normal file
201
src/dsp/filter/channelizer/PolyphaseChannelSource.java
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* 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 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 dsp.filter.channelizer;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import sample.Listener;
|
||||||
|
import sample.complex.ComplexBuffer;
|
||||||
|
import source.ISourceEventProcessor;
|
||||||
|
import source.SourceEvent;
|
||||||
|
import source.SourceException;
|
||||||
|
import source.tuner.ComplexChannelSource;
|
||||||
|
import source.tuner.TunerChannel;
|
||||||
|
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
|
public class PolyphaseChannelSource extends ComplexChannelSource
|
||||||
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger(PolyphaseChannelSource.class);
|
||||||
|
|
||||||
|
private TunerChannel mTunerChannel;
|
||||||
|
private long mTunerCenterFrequency;
|
||||||
|
private int mUpstreamSampleRate;
|
||||||
|
private int mChannelSampleRate;
|
||||||
|
private int mChannelCount;
|
||||||
|
private int mOutputFrequencyCorrection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Polyphase channelizer channel implementation. Adapts the channel array output samples from the polyphase
|
||||||
|
* channelizer into a single channel, or a channel synthesized from two adjacent channels that is frequency
|
||||||
|
* translated and decimated to a single channel.
|
||||||
|
*
|
||||||
|
* @param tunerChannel - requested output tuner channel frequency and bandwidth.
|
||||||
|
*/
|
||||||
|
public PolyphaseChannelSource(ISourceEventProcessor upstreamSourceEventProcessor, TunerChannel tunerChannel)
|
||||||
|
{
|
||||||
|
super(upstreamSourceEventProcessor);
|
||||||
|
|
||||||
|
mTunerChannel = tunerChannel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process source event notifications received from upstream source provider and source event requests
|
||||||
|
* received from downstream consumers.
|
||||||
|
*
|
||||||
|
* @param sourceEvent containing a request or notification
|
||||||
|
* @throws SourceException if there are any errors while processing the source event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void process(SourceEvent sourceEvent) throws SourceException
|
||||||
|
{
|
||||||
|
switch(sourceEvent.getEvent())
|
||||||
|
{
|
||||||
|
case NOTIFICATION_CHANNEL_SAMPLE_RATE_CHANGE:
|
||||||
|
setChannelSampleRate(sourceEvent.getValue().intValue());
|
||||||
|
break;
|
||||||
|
case NOTIFICATION_FREQUENCY_CHANGE:
|
||||||
|
mTunerCenterFrequency = sourceEvent.getValue().longValue();
|
||||||
|
updateInputConfiguration();
|
||||||
|
break;
|
||||||
|
case NOTIFICATION_SAMPLE_RATE_CHANGE:
|
||||||
|
setUpstreamSampleRate(sourceEvent.getValue().intValue());
|
||||||
|
updateInputConfiguration();
|
||||||
|
break;
|
||||||
|
case REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE:
|
||||||
|
setFrequencyCorrection(sourceEvent.getValue().intValue());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the array samples for each of the output channels from the polyphase channelizer.
|
||||||
|
* @param channels
|
||||||
|
*/
|
||||||
|
public void processChannels(float[] channels)
|
||||||
|
{
|
||||||
|
|
||||||
|
//TODO we have to dispatch full buffers on a separate thread so that we don't bog down the channelizer
|
||||||
|
//TODO thread that is delivering the channel samples to us.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates current processing configuration any time there is a change in tuner center frequency
|
||||||
|
* or tuner sample rate.
|
||||||
|
*/
|
||||||
|
private void updateInputConfiguration()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Downstream sample rate
|
||||||
|
*
|
||||||
|
* @return sample rate in Hertz
|
||||||
|
* @throws SourceException if this method is accessed before the channel count is established
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getSampleRate() throws SourceException
|
||||||
|
{
|
||||||
|
if(mChannelSampleRate > 0)
|
||||||
|
{
|
||||||
|
return mChannelSampleRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new SourceException("Channel sample rate has not been set.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the downstream channel sample rate. Since oversampling may occur in the upstream channelizer, we can't
|
||||||
|
* rely on simply dividing the upstream sample rate by the number of channels. Thus, we required the upstream
|
||||||
|
* channelizer to tell us the exact channel sample rate.
|
||||||
|
*
|
||||||
|
* @param channelSampleRate in hertz
|
||||||
|
*/
|
||||||
|
private void setChannelSampleRate(int channelSampleRate)
|
||||||
|
{
|
||||||
|
mChannelSampleRate = channelSampleRate;
|
||||||
|
|
||||||
|
//Translate the upstream channel sample rate event into a downstream sample rate change event
|
||||||
|
broadcast(SourceEvent.sampleRateChange(mChannelSampleRate));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the input sample rate and broadcasts a source change event to the downstream listener
|
||||||
|
* @param sampleRate from the upstream source
|
||||||
|
*/
|
||||||
|
private void setUpstreamSampleRate(int sampleRate)
|
||||||
|
{
|
||||||
|
mUpstreamSampleRate = sampleRate;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
broadcast(SourceEvent.sampleRateChange(getSampleRate()));
|
||||||
|
}
|
||||||
|
catch(SourceException se)
|
||||||
|
{
|
||||||
|
mLog.error("Upstream sample rate changed - couldn't broadcast channel sample rate change event " +
|
||||||
|
"to downstream channel", se);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the polyphase channel count.
|
||||||
|
* @param channelCount number of channels being processed by the polyphase channelizer
|
||||||
|
*/
|
||||||
|
private void setChannelCount(int channelCount)
|
||||||
|
{
|
||||||
|
mChannelCount = channelCount;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
broadcast(SourceEvent.sampleRateChange(getSampleRate()));
|
||||||
|
}
|
||||||
|
catch(SourceException se)
|
||||||
|
{
|
||||||
|
mLog.error("Polyphase channel count changed - couldn't broadcast channel sample rate change event " +
|
||||||
|
"to downstream channel", se);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getFrequency() throws SourceException
|
||||||
|
{
|
||||||
|
return mTunerChannel.getFrequency();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFrequencyCorrection(int correction)
|
||||||
|
{
|
||||||
|
//TODO:
|
||||||
|
mLog.debug("Request for frequency correction: " + correction + " -- not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -151,7 +151,7 @@ public class FIRFilterSpecification
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Polyphase Channelizer filter specification builder that allows you to define the filter parameters and
|
* Creates a Polyphase TunerChannelizer filter specification builder that allows you to define the filter parameters and
|
||||||
* create a filter specification
|
* create a filter specification
|
||||||
*/
|
*/
|
||||||
public static ChannelizerBuilder channelizerBuilder()
|
public static ChannelizerBuilder channelizerBuilder()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import dsp.filter.fir.FIRFilterSpecification;
|
|||||||
public class PolyphaseChannelizerDesigner extends FIRFilterSpecification
|
public class PolyphaseChannelizerDesigner extends FIRFilterSpecification
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructs a Polyphase Channelizer Remez filter specification.
|
* Constructs a Polyphase TunerChannelizer Remez filter specification.
|
||||||
*
|
*
|
||||||
* Constructor is package private -- use the PolyphaseChannelizerFilterFactory to create a filter
|
* Constructor is package private -- use the PolyphaseChannelizerFilterFactory to create a filter
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import java.util.List;
|
|||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.complex.Complex;
|
import sample.complex.Complex;
|
||||||
import sample.complex.ComplexSampleListener;
|
import sample.complex.ComplexSampleListener;
|
||||||
import source.tuner.frequency.IFrequencyChangeListener;
|
import source.ISourceEventListener;
|
||||||
import buffer.FloatAveragingBuffer;
|
import buffer.FloatAveragingBuffer;
|
||||||
import dsp.filter.interpolator.RealInterpolator;
|
import dsp.filter.interpolator.RealInterpolator;
|
||||||
import dsp.symbol.Dibit;
|
import dsp.symbol.Dibit;
|
||||||
@@ -73,7 +73,7 @@ public class LSMDemodulator implements Instrumentable, ComplexSampleListener
|
|||||||
|
|
||||||
private CostasLoop mCostasLoop = new CostasLoop();
|
private CostasLoop mCostasLoop = new CostasLoop();
|
||||||
|
|
||||||
private IFrequencyChangeListener mFrequencyChangeListener;
|
private ISourceEventListener mFrequencyChangeListener;
|
||||||
|
|
||||||
private EyeDiagramDataTap mEyeDiagramDataTap;
|
private EyeDiagramDataTap mEyeDiagramDataTap;
|
||||||
|
|
||||||
@@ -147,12 +147,12 @@ public class LSMDemodulator implements Instrumentable, ComplexSampleListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener( IFrequencyChangeListener listener )
|
public void addListener( ISourceEventListener listener )
|
||||||
{
|
{
|
||||||
mFrequencyChangeListener = listener;
|
mFrequencyChangeListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeListener( IFrequencyChangeListener listener )
|
public void removeListener( ISourceEventListener listener )
|
||||||
{
|
{
|
||||||
mFrequencyChangeListener = null;
|
mFrequencyChangeListener = null;
|
||||||
}
|
}
|
||||||
@@ -202,8 +202,8 @@ public class LSMDemodulator implements Instrumentable, ComplexSampleListener
|
|||||||
// if( correctionNeeded && mFrequencyChangeListener != null )
|
// if( correctionNeeded && mFrequencyChangeListener != null )
|
||||||
// {
|
// {
|
||||||
// mLog.debug( "Issuing Frequency Correction: " + mFrequencyError );
|
// mLog.debug( "Issuing Frequency Correction: " + mFrequencyError );
|
||||||
// mFrequencyChangeListener.frequencyChanged(
|
// mFrequencyChangeListener.process(
|
||||||
// new FrequencyChangeEvent( Attribute.FREQUENCY_ERROR,
|
// new SourceEvent( Attribute.FREQUENCY_ERROR,
|
||||||
// mFrequencyError ) );
|
// mFrequencyError ) );
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 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 License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,15 +14,21 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package gui.control;
|
package gui.control;
|
||||||
|
|
||||||
import java.awt.Color;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import java.awt.Cursor;
|
import org.slf4j.Logger;
|
||||||
import java.awt.Font;
|
import org.slf4j.LoggerFactory;
|
||||||
import java.awt.Image;
|
import source.ISourceEventProcessor;
|
||||||
import java.awt.Point;
|
import source.InvalidFrequencyException;
|
||||||
import java.awt.Toolkit;
|
import source.SourceEvent;
|
||||||
|
import source.SourceEvent.Event;
|
||||||
|
import source.SourceException;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
@@ -35,26 +41,12 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.*;
|
public class JFrequencyControl extends JPanel implements ISourceEventProcessor
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import source.InvalidFrequencyException;
|
|
||||||
import source.SourceException;
|
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
|
||||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
|
||||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
|
||||||
|
|
||||||
public class JFrequencyControl extends JPanel implements IFrequencyChangeProcessor
|
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private final static Logger mLog =
|
private final static Logger mLog = LoggerFactory.getLogger(JFrequencyControl.class);
|
||||||
LoggerFactory.getLogger(JFrequencyControl.class);
|
|
||||||
|
|
||||||
private List<IFrequencyChangeProcessor> mProcessors = new ArrayList<>();
|
private List<ISourceEventProcessor> mProcessors = new ArrayList<>();
|
||||||
|
|
||||||
private Color mHighlightColor = Color.YELLOW;
|
private Color mHighlightColor = Color.YELLOW;
|
||||||
|
|
||||||
@@ -145,7 +137,7 @@ public class JFrequencyControl extends JPanel implements IFrequencyChangeProcess
|
|||||||
* rebroadcast this event, just set the control to indicate the new frequency.
|
* rebroadcast this event, just set the control to indicate the new frequency.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void frequencyChanged(FrequencyChangeEvent event)
|
public void process(SourceEvent event)
|
||||||
{
|
{
|
||||||
if(event.getEvent() == Event.NOTIFICATION_FREQUENCY_CHANGE)
|
if(event.getEvent() == Event.NOTIFICATION_FREQUENCY_CHANGE)
|
||||||
{
|
{
|
||||||
@@ -184,27 +176,26 @@ public class JFrequencyControl extends JPanel implements IFrequencyChangeProcess
|
|||||||
mFrequency = frequency;
|
mFrequency = frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fireFrequencyChanged() throws SourceException
|
private void fireSourceChanged() throws SourceException
|
||||||
{
|
{
|
||||||
updateFrequency();
|
updateFrequency();
|
||||||
|
|
||||||
Iterator<IFrequencyChangeProcessor> it = mProcessors.iterator();
|
Iterator<ISourceEventProcessor> it = mProcessors.iterator();
|
||||||
|
|
||||||
FrequencyChangeEvent event = new FrequencyChangeEvent(
|
SourceEvent event = SourceEvent.frequencyRequest(mFrequency);
|
||||||
Event.REQUEST_FREQUENCY_CHANGE, mFrequency);
|
|
||||||
|
|
||||||
while(it.hasNext())
|
while(it.hasNext())
|
||||||
{
|
{
|
||||||
it.next().frequencyChanged(event);
|
it.next().process(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener(IFrequencyChangeProcessor processor)
|
public void addListener(ISourceEventProcessor processor)
|
||||||
{
|
{
|
||||||
mProcessors.add(processor);
|
mProcessors.add(processor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeListener(IFrequencyChangeProcessor processor)
|
public void removeListener(ISourceEventProcessor processor)
|
||||||
{
|
{
|
||||||
mProcessors.remove(processor);
|
mProcessors.remove(processor);
|
||||||
}
|
}
|
||||||
@@ -326,7 +317,7 @@ public class JFrequencyControl extends JPanel implements IFrequencyChangeProcess
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fireFrequencyChanged();
|
fireSourceChanged();
|
||||||
}
|
}
|
||||||
catch(SourceException se)
|
catch(SourceException se)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,10 +30,8 @@ import channel.metadata.IAttributeChangeRequestProvider;
|
|||||||
import channel.state.ChannelState;
|
import channel.state.ChannelState;
|
||||||
import channel.state.DecoderState;
|
import channel.state.DecoderState;
|
||||||
import channel.state.DecoderStateEvent;
|
import channel.state.DecoderStateEvent;
|
||||||
import channel.state.DecoderStateEvent.Event;
|
|
||||||
import channel.state.IDecoderStateEventListener;
|
import channel.state.IDecoderStateEventListener;
|
||||||
import channel.state.IDecoderStateEventProvider;
|
import channel.state.IDecoderStateEventProvider;
|
||||||
import channel.state.State;
|
|
||||||
import controller.channel.Channel.ChannelType;
|
import controller.channel.Channel.ChannelType;
|
||||||
import controller.channel.ChannelEvent;
|
import controller.channel.ChannelEvent;
|
||||||
import controller.channel.IChannelEventListener;
|
import controller.channel.IChannelEventListener;
|
||||||
@@ -63,11 +61,9 @@ import sample.real.RealBuffer;
|
|||||||
import source.ComplexSource;
|
import source.ComplexSource;
|
||||||
import source.RealSource;
|
import source.RealSource;
|
||||||
import source.Source;
|
import source.Source;
|
||||||
import source.SourceException;
|
import source.ISourceEventListener;
|
||||||
import source.tuner.TunerChannelSource;
|
import source.ISourceEventProvider;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent;
|
||||||
import source.tuner.frequency.IFrequencyChangeListener;
|
|
||||||
import source.tuner.frequency.IFrequencyChangeProvider;
|
|
||||||
import util.ThreadPool;
|
import util.ThreadPool;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -102,7 +98,7 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
private Broadcaster<ChannelEvent> mChannelEventBroadcaster = new Broadcaster<>();
|
private Broadcaster<ChannelEvent> mChannelEventBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<ComplexBuffer> mComplexBufferBroadcaster = new Broadcaster<>();
|
private Broadcaster<ComplexBuffer> mComplexBufferBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<DecoderStateEvent> mDecoderStateEventBroadcaster = new Broadcaster<>();
|
private Broadcaster<DecoderStateEvent> mDecoderStateEventBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<FrequencyChangeEvent> mFrequencyChangeEventBroadcaster = new Broadcaster<>();
|
private Broadcaster<SourceEvent> mFrequencyChangeEventBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<Message> mMessageBroadcaster = new Broadcaster<>();
|
private Broadcaster<Message> mMessageBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<RealBuffer> mFilteredRealBufferBroadcaster = new Broadcaster<>();
|
private Broadcaster<RealBuffer> mFilteredRealBufferBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<RealBuffer> mUnFilteredRealBufferBroadcaster = new Broadcaster<>();
|
private Broadcaster<RealBuffer> mUnFilteredRealBufferBroadcaster = new Broadcaster<>();
|
||||||
@@ -318,9 +314,9 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
mDecoderStateEventBroadcaster.addListener(((IDecoderStateEventListener) module).getDecoderStateListener());
|
mDecoderStateEventBroadcaster.addListener(((IDecoderStateEventListener) module).getDecoderStateListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IFrequencyChangeListener)
|
if(module instanceof ISourceEventListener)
|
||||||
{
|
{
|
||||||
mFrequencyChangeEventBroadcaster.addListener(((IFrequencyChangeListener) module).getFrequencyChangeListener());
|
mFrequencyChangeEventBroadcaster.addListener(((ISourceEventListener) module).getSourceEventListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IMessageListener)
|
if(module instanceof IMessageListener)
|
||||||
@@ -380,9 +376,9 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
mDecoderStateEventBroadcaster.removeListener(((IDecoderStateEventListener) module).getDecoderStateListener());
|
mDecoderStateEventBroadcaster.removeListener(((IDecoderStateEventListener) module).getDecoderStateListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IFrequencyChangeListener)
|
if(module instanceof ISourceEventListener)
|
||||||
{
|
{
|
||||||
mFrequencyChangeEventBroadcaster.removeListener(((IFrequencyChangeListener) module).getFrequencyChangeListener());
|
mFrequencyChangeEventBroadcaster.removeListener(((ISourceEventListener) module).getSourceEventListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IMessageListener)
|
if(module instanceof IMessageListener)
|
||||||
@@ -437,9 +433,9 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
((IDecoderStateEventProvider) module).setDecoderStateListener(mDecoderStateEventBroadcaster);
|
((IDecoderStateEventProvider) module).setDecoderStateListener(mDecoderStateEventBroadcaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IFrequencyChangeProvider)
|
if(module instanceof IFilteredRealBufferProvider)
|
||||||
{
|
{
|
||||||
((IFrequencyChangeProvider) module).setFrequencyChangeListener(mFrequencyChangeEventBroadcaster);
|
((IFilteredRealBufferProvider) module).setFilteredRealBufferListener(mFilteredRealBufferBroadcaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IMessageProvider)
|
if(module instanceof IMessageProvider)
|
||||||
@@ -447,9 +443,9 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
((IMessageProvider) module).setMessageListener(mMessageBroadcaster);
|
((IMessageProvider) module).setMessageListener(mMessageBroadcaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IFilteredRealBufferProvider)
|
if(module instanceof ISourceEventProvider)
|
||||||
{
|
{
|
||||||
((IFilteredRealBufferProvider) module).setFilteredRealBufferListener(mFilteredRealBufferBroadcaster);
|
((ISourceEventProvider) module).setSourceEventListener(mFrequencyChangeEventBroadcaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof ISquelchStateProvider)
|
if(module instanceof ISquelchStateProvider)
|
||||||
@@ -494,9 +490,9 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
((IDecoderStateEventProvider) module).setDecoderStateListener(null);
|
((IDecoderStateEventProvider) module).setDecoderStateListener(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IFrequencyChangeProvider)
|
if(module instanceof IFilteredRealBufferProvider)
|
||||||
{
|
{
|
||||||
((IFrequencyChangeProvider) module).setFrequencyChangeListener(null);
|
((IFilteredRealBufferProvider) module).setFilteredRealBufferListener(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IMessageProvider)
|
if(module instanceof IMessageProvider)
|
||||||
@@ -504,9 +500,9 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
((IMessageProvider) module).setMessageListener(null);
|
((IMessageProvider) module).setMessageListener(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IFilteredRealBufferProvider)
|
if(module instanceof ISourceEventProvider)
|
||||||
{
|
{
|
||||||
((IFilteredRealBufferProvider) module).setFilteredRealBufferListener(null);
|
((ISourceEventProvider) module).setSourceEventListener(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof ISquelchStateProvider)
|
if(module instanceof ISquelchStateProvider)
|
||||||
@@ -743,7 +739,7 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
* Adds the listener to receive frequency change events from the processing chain
|
* Adds the listener to receive frequency change events from the processing chain
|
||||||
* @param listener to receive events
|
* @param listener to receive events
|
||||||
*/
|
*/
|
||||||
public void addFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
public void addFrequencyChangeListener(Listener<SourceEvent> listener)
|
||||||
{
|
{
|
||||||
mFrequencyChangeEventBroadcaster.addListener(listener);
|
mFrequencyChangeEventBroadcaster.addListener(listener);
|
||||||
}
|
}
|
||||||
@@ -752,7 +748,7 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
* Removes the listener from receiving frequency change events
|
* Removes the listener from receiving frequency change events
|
||||||
* @param listener to remove
|
* @param listener to remove
|
||||||
*/
|
*/
|
||||||
public void removeFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
public void removeFrequencyChangeListener(Listener<SourceEvent> listener)
|
||||||
{
|
{
|
||||||
mFrequencyChangeEventBroadcaster.removeListener(listener);
|
mFrequencyChangeEventBroadcaster.removeListener(listener);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,22 @@
|
|||||||
package module.decode.p25;
|
package module.decode.p25;
|
||||||
|
|
||||||
|
import dsp.gain.DirectGainControl;
|
||||||
import instrument.Instrumentable;
|
import instrument.Instrumentable;
|
||||||
import instrument.tap.Tap;
|
import instrument.tap.Tap;
|
||||||
import instrument.tap.TapGroup;
|
import instrument.tap.TapGroup;
|
||||||
import instrument.tap.stream.AdditiveFloatTap;
|
import instrument.tap.stream.AdditiveFloatTap;
|
||||||
import instrument.tap.stream.FloatTap;
|
import instrument.tap.stream.FloatTap;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.real.RealBuffer;
|
import sample.real.RealBuffer;
|
||||||
import sample.real.RealSampleListener;
|
import sample.real.RealSampleListener;
|
||||||
import sample.real.RealSampleProvider;
|
import sample.real.RealSampleProvider;
|
||||||
import source.tuner.TunerChannelSource;
|
import source.ISourceEventListener;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
|
||||||
import source.tuner.frequency.IFrequencyChangeListener;
|
|
||||||
import dsp.gain.DirectGainControl;
|
|
||||||
|
|
||||||
public class C4FMSymbolFilter implements Listener<RealBuffer>, IFrequencyChangeListener, RealSampleProvider, Instrumentable
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class C4FMSymbolFilter implements Listener<RealBuffer>, ISourceEventListener, RealSampleProvider, Instrumentable
|
||||||
{
|
{
|
||||||
private static final float TAPS[][] =
|
private static final float TAPS[][] =
|
||||||
{
|
{
|
||||||
@@ -205,7 +200,7 @@ public class C4FMSymbolFilter implements Listener<RealBuffer>, IFrequencyChangeL
|
|||||||
private int mFrequencyCorrectionMaximum = 3000;
|
private int mFrequencyCorrectionMaximum = 3000;
|
||||||
private boolean mResetFrequencyTracker = false;
|
private boolean mResetFrequencyTracker = false;
|
||||||
private FrequencyCorrectionProcessor mFrequencyCorrectionProcessor;
|
private FrequencyCorrectionProcessor mFrequencyCorrectionProcessor;
|
||||||
private Listener<FrequencyChangeEvent> mFrequencyChangeListener;
|
private Listener<SourceEvent> mFrequencyChangeListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* C4FM Symbol Filter
|
* C4FM Symbol Filter
|
||||||
@@ -257,7 +252,7 @@ public class C4FMSymbolFilter implements Listener<RealBuffer>, IFrequencyChangeL
|
|||||||
correction = -mFrequencyCorrectionMaximum;
|
correction = -mFrequencyCorrectionMaximum;
|
||||||
}
|
}
|
||||||
|
|
||||||
broadcast( new FrequencyChangeEvent(Event.REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE, correction ) );
|
broadcast(SourceEvent.channelFrequencyCorrectionRequest(correction));
|
||||||
|
|
||||||
mFrequencyAdjustmentRequested = 0;
|
mFrequencyAdjustmentRequested = 0;
|
||||||
}
|
}
|
||||||
@@ -272,8 +267,7 @@ public class C4FMSymbolFilter implements Listener<RealBuffer>, IFrequencyChangeL
|
|||||||
mCoarseFrequencyCorrection = 0.0f;
|
mCoarseFrequencyCorrection = 0.0f;
|
||||||
mFineFrequencyCorrection = 0.0f;
|
mFineFrequencyCorrection = 0.0f;
|
||||||
|
|
||||||
broadcast( new FrequencyChangeEvent(
|
broadcast(SourceEvent.channelFrequencyCorrectionRequest(0l));
|
||||||
Event.REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE, 0 ));
|
|
||||||
|
|
||||||
mResetFrequencyTracker = false;
|
mResetFrequencyTracker = false;
|
||||||
}
|
}
|
||||||
@@ -452,9 +446,10 @@ public class C4FMSymbolFilter implements Listener<RealBuffer>, IFrequencyChangeL
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcasts a frequency change event to the registered listener
|
* Broadcasts a frequency change event to the registered listener
|
||||||
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
public void broadcast( FrequencyChangeEvent event )
|
public void broadcast(SourceEvent event)
|
||||||
{
|
{
|
||||||
if(mFrequencyChangeListener != null)
|
if(mFrequencyChangeListener != null)
|
||||||
{
|
{
|
||||||
@@ -464,15 +459,16 @@ public class C4FMSymbolFilter implements Listener<RealBuffer>, IFrequencyChangeL
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the listener for frequency change events.
|
* Sets the listener for frequency change events.
|
||||||
|
*
|
||||||
* @param listener
|
* @param listener
|
||||||
*/
|
*/
|
||||||
public void setFrequencyChangeListener( Listener<FrequencyChangeEvent> listener )
|
public void setFrequencyChangeListener(Listener<SourceEvent> listener)
|
||||||
{
|
{
|
||||||
mFrequencyChangeListener = listener;
|
mFrequencyChangeListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
public Listener<SourceEvent> getSourceEventListener()
|
||||||
{
|
{
|
||||||
if(mFrequencyCorrectionProcessor == null)
|
if(mFrequencyCorrectionProcessor == null)
|
||||||
{
|
{
|
||||||
@@ -486,10 +482,10 @@ public class C4FMSymbolFilter implements Listener<RealBuffer>, IFrequencyChangeL
|
|||||||
* Receives notifications that the channel frequency correction has been
|
* Receives notifications that the channel frequency correction has been
|
||||||
* applied and updates internal tracking value.
|
* applied and updates internal tracking value.
|
||||||
*/
|
*/
|
||||||
public class FrequencyCorrectionProcessor implements Listener<FrequencyChangeEvent>
|
public class FrequencyCorrectionProcessor implements Listener<SourceEvent>
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void receive( FrequencyChangeEvent event )
|
public void receive(SourceEvent event)
|
||||||
{
|
{
|
||||||
switch(event.getEvent())
|
switch(event.getEvent())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import alias.AliasList;
|
|||||||
import instrument.Instrumentable;
|
import instrument.Instrumentable;
|
||||||
import module.decode.Decoder;
|
import module.decode.Decoder;
|
||||||
import module.decode.DecoderType;
|
import module.decode.DecoderType;
|
||||||
import source.tuner.frequency.IFrequencyChangeListener;
|
import source.ISourceEventListener;
|
||||||
import source.tuner.frequency.IFrequencyChangeProvider;
|
import source.ISourceEventProvider;
|
||||||
|
|
||||||
public abstract class P25Decoder extends Decoder implements IFrequencyChangeListener, IFrequencyChangeProvider, Instrumentable
|
public abstract class P25Decoder extends Decoder implements ISourceEventListener, ISourceEventProvider, Instrumentable
|
||||||
{
|
{
|
||||||
private P25MessageProcessor mMessageProcessor;
|
private P25MessageProcessor mMessageProcessor;
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ package module.decode.p25;
|
|||||||
import instrument.tap.Tap;
|
import instrument.tap.Tap;
|
||||||
import instrument.tap.TapGroup;
|
import instrument.tap.TapGroup;
|
||||||
import instrument.tap.stream.DibitTap;
|
import instrument.tap.stream.DibitTap;
|
||||||
import instrument.tap.stream.FloatBufferTap;
|
|
||||||
import instrument.tap.stream.FloatTap;
|
import instrument.tap.stream.FloatTap;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -35,12 +34,7 @@ import alias.AliasList;
|
|||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.real.IFilteredRealBufferListener;
|
import sample.real.IFilteredRealBufferListener;
|
||||||
import sample.real.RealBuffer;
|
import sample.real.RealBuffer;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent;
|
||||||
import source.tuner.frequency.IFrequencyChangeListener;
|
|
||||||
import source.tuner.frequency.IFrequencyChangeProvider;
|
|
||||||
import dsp.filter.FilterFactory;
|
|
||||||
import dsp.filter.Window.WindowType;
|
|
||||||
import dsp.filter.fir.real.RealFIRFilter_RB_RB;
|
|
||||||
|
|
||||||
public class P25_C4FMDecoder extends P25Decoder implements IFilteredRealBufferListener
|
public class P25_C4FMDecoder extends P25Decoder implements IFilteredRealBufferListener
|
||||||
{
|
{
|
||||||
@@ -222,7 +216,7 @@ public class P25_C4FMDecoder extends P25Decoder implements IFilteredRealBufferLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFrequencyChangeListener( Listener<FrequencyChangeEvent> listener )
|
public void setSourceEventListener(Listener<SourceEvent> listener )
|
||||||
{
|
{
|
||||||
if( mSymbolFilter != null )
|
if( mSymbolFilter != null )
|
||||||
{
|
{
|
||||||
@@ -231,7 +225,7 @@ public class P25_C4FMDecoder extends P25Decoder implements IFilteredRealBufferLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeFrequencyChangeListener()
|
public void removeSourceEventListener()
|
||||||
{
|
{
|
||||||
if( mSymbolFilter != null )
|
if( mSymbolFilter != null )
|
||||||
{
|
{
|
||||||
@@ -240,11 +234,11 @@ public class P25_C4FMDecoder extends P25Decoder implements IFilteredRealBufferLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
public Listener<SourceEvent> getSourceEventListener()
|
||||||
{
|
{
|
||||||
if( mSymbolFilter != null )
|
if( mSymbolFilter != null )
|
||||||
{
|
{
|
||||||
return mSymbolFilter.getFrequencyChangeListener();
|
return mSymbolFilter.getSourceEventListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import dsp.filter.fir.complex.ComplexFIRFilter_CB_CB;
|
|||||||
import dsp.gain.ComplexFeedForwardGainControl;
|
import dsp.gain.ComplexFeedForwardGainControl;
|
||||||
import dsp.psk.LSMDemodulator;
|
import dsp.psk.LSMDemodulator;
|
||||||
import dsp.psk.QPSKPolarSlicer;
|
import dsp.psk.QPSKPolarSlicer;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent;
|
||||||
|
|
||||||
public class P25_LSMDecoder extends P25Decoder implements IComplexBufferListener
|
public class P25_LSMDecoder extends P25Decoder implements IComplexBufferListener
|
||||||
{
|
{
|
||||||
@@ -109,22 +109,22 @@ public class P25_LSMDecoder extends P25Decoder implements IComplexBufferListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
public void setSourceEventListener(Listener<SourceEvent> listener)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeFrequencyChangeListener()
|
public void removeSourceEventListener()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
public Listener<SourceEvent> getSourceEventListener()
|
||||||
{
|
{
|
||||||
return new Listener<FrequencyChangeEvent>()
|
return new Listener<SourceEvent>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void receive(FrequencyChangeEvent frequencyChangeEvent)
|
public void receive(SourceEvent sourceEvent)
|
||||||
{
|
{
|
||||||
//Ignored
|
//Ignored
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package sample;
|
|||||||
|
|
||||||
public enum SampleType
|
public enum SampleType
|
||||||
{
|
{
|
||||||
COMPLEX, //Baseband
|
COMPLEX, // I/Q
|
||||||
REAL, //Demodulated
|
REAL; // Real
|
||||||
COMPLEX_AND_REAL; //Baseband and Demodulated
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* 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 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 source;
|
package source;
|
||||||
|
|
||||||
import sample.Provider;
|
import sample.Provider;
|
||||||
@@ -6,8 +24,9 @@ import sample.complex.ComplexBuffer;
|
|||||||
|
|
||||||
public abstract class ComplexSource extends Source implements Provider<ComplexBuffer>
|
public abstract class ComplexSource extends Source implements Provider<ComplexBuffer>
|
||||||
{
|
{
|
||||||
public ComplexSource()
|
@Override
|
||||||
|
public SampleType getSampleType()
|
||||||
{
|
{
|
||||||
super( SampleType.COMPLEX );
|
return SampleType.COMPLEX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
35
src/source/ISourceEventListener.java
Normal file
35
src/source/ISourceEventListener.java
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* 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 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 source;
|
||||||
|
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for broadcasting changes to frequency, bandwidth, sample rate,
|
||||||
|
* and actual sample rate values to all registered listeners.
|
||||||
|
*
|
||||||
|
* Note: broadcasted frequency should be the uncorrected, or displayable
|
||||||
|
* frequency value. All frequency correction aspects should be handled within
|
||||||
|
* the device that implements the tuning of the frequency.
|
||||||
|
*/
|
||||||
|
public interface ISourceEventListener
|
||||||
|
{
|
||||||
|
Listener<SourceEvent> getSourceEventListener();
|
||||||
|
}
|
||||||
24
src/source/ISourceEventProcessor.java
Normal file
24
src/source/ISourceEventProcessor.java
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* 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 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 source;
|
||||||
|
|
||||||
|
public interface ISourceEventProcessor
|
||||||
|
{
|
||||||
|
void process(SourceEvent event) throws SourceException;
|
||||||
|
}
|
||||||
@@ -16,15 +16,15 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package source.tuner.frequency;
|
package source;
|
||||||
|
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provider of Frequency Change Events
|
* Provider of Source Change Events
|
||||||
*/
|
*/
|
||||||
public interface IFrequencyChangeProvider
|
public interface ISourceEventProvider
|
||||||
{
|
{
|
||||||
void setFrequencyChangeListener( Listener<FrequencyChangeEvent> listener );
|
void setSourceEventListener(Listener<SourceEvent> listener );
|
||||||
void removeFrequencyChangeListener();
|
void removeSourceEventListener();
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,32 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* 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 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 source;
|
package source;
|
||||||
|
|
||||||
import sample.Provider;
|
import sample.Provider;
|
||||||
import sample.SampleType;
|
import sample.SampleType;
|
||||||
import sample.real.RealBuffer;
|
import sample.real.RealBuffer;
|
||||||
|
|
||||||
|
|
||||||
public abstract class RealSource extends Source implements Provider<RealBuffer>
|
public abstract class RealSource extends Source implements Provider<RealBuffer>
|
||||||
{
|
{
|
||||||
public RealSource()
|
@Override
|
||||||
|
public SampleType getSampleType()
|
||||||
{
|
{
|
||||||
super( SampleType.REAL );
|
return SampleType.REAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,38 +20,38 @@ package source;
|
|||||||
import module.Module;
|
import module.Module;
|
||||||
import sample.SampleType;
|
import sample.SampleType;
|
||||||
import sample.real.IOverflowListener;
|
import sample.real.IOverflowListener;
|
||||||
import source.tuner.frequency.IFrequencyChangeListener;
|
|
||||||
import source.tuner.frequency.IFrequencyChangeProvider;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class to define the minimum functionality of a sample data provider.
|
* Abstract class to define the minimum functionality of a sample data provider.
|
||||||
*/
|
*/
|
||||||
public abstract class Source extends Module implements IFrequencyChangeListener, IFrequencyChangeProvider
|
public abstract class Source extends Module implements ISourceEventListener, ISourceEventProvider
|
||||||
{
|
{
|
||||||
protected SampleType mSampleType;
|
|
||||||
protected IOverflowListener mOverflowListener;
|
protected IOverflowListener mOverflowListener;
|
||||||
|
|
||||||
public Source( SampleType sampleType )
|
/**
|
||||||
{
|
* Indicates the type of samples provided by this source: real or complex
|
||||||
mSampleType = sampleType;
|
*/
|
||||||
}
|
public abstract SampleType getSampleType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sample rate provided by this source
|
||||||
|
*
|
||||||
|
* @throws SourceException if there is an issue determining the sample rate for this source
|
||||||
|
*/
|
||||||
public abstract int getSampleRate() throws SourceException;
|
public abstract int getSampleRate() throws SourceException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Center frequency for this source in Hertz
|
||||||
|
*
|
||||||
|
* @throws SourceException if there is an issue in determining the center frequency for this source
|
||||||
|
*/
|
||||||
public abstract long getFrequency() throws SourceException;
|
public abstract long getFrequency() throws SourceException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process any cleanup actions to prepare for garbage collection of this source
|
||||||
|
*/
|
||||||
public abstract void dispose();
|
public abstract void dispose();
|
||||||
|
|
||||||
public SampleType getSampleType()
|
|
||||||
{
|
|
||||||
return mSampleType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSampleType( SampleType sampleType )
|
|
||||||
{
|
|
||||||
mSampleType = sampleType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the listener to receive overflow state changes. Use null argument to clear the listener
|
* Registers the listener to receive overflow state changes. Use null argument to clear the listener
|
||||||
*/
|
*/
|
||||||
@@ -63,7 +63,7 @@ public abstract class Source extends Module implements IFrequencyChangeListener,
|
|||||||
/**
|
/**
|
||||||
* Broadcasts an overflow state
|
* Broadcasts an overflow state
|
||||||
*
|
*
|
||||||
* @param overflow true if overlow, false if normal
|
* @param overflow true if overflow, false if normal
|
||||||
*/
|
*/
|
||||||
protected void broadcastOverflowState(boolean overflow)
|
protected void broadcastOverflowState(boolean overflow)
|
||||||
{
|
{
|
||||||
|
|||||||
192
src/source/SourceEvent.java
Normal file
192
src/source/SourceEvent.java
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* 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 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 source;
|
||||||
|
|
||||||
|
public class SourceEvent
|
||||||
|
{
|
||||||
|
public enum Event
|
||||||
|
{
|
||||||
|
NOTIFICATION_CHANNEL_FREQUENCY_CORRECTION_CHANGE,
|
||||||
|
NOTIFICATION_CHANNEL_SAMPLE_RATE_CHANGE,
|
||||||
|
NOTIFICATION_FREQUENCY_CHANGE,
|
||||||
|
NOTIFICATION_FREQUENCY_CORRECTION_CHANGE,
|
||||||
|
NOTIFICATION_POLYPHASE_CHANNEL_COUNT_CHANGE,
|
||||||
|
NOTIFICATION_SAMPLE_RATE_CHANGE,
|
||||||
|
|
||||||
|
REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE,
|
||||||
|
REQUEST_FREQUENCY_CHANGE,
|
||||||
|
REQUEST_START_SAMPLE_STREAM,
|
||||||
|
REQUEST_STOP_SAMPLE_STREAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Event mEvent;
|
||||||
|
private Number mValue;
|
||||||
|
private Source mSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private constructor. Use the static constructor methods to create an event.
|
||||||
|
*/
|
||||||
|
private SourceEvent(Event event, Number value)
|
||||||
|
{
|
||||||
|
mEvent = event;
|
||||||
|
mValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private constructor. Use the static constructor methods to create an event.
|
||||||
|
*/
|
||||||
|
private SourceEvent(Event event, Source source)
|
||||||
|
{
|
||||||
|
mEvent = event;
|
||||||
|
mSource = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event description.
|
||||||
|
*/
|
||||||
|
public Event getEvent()
|
||||||
|
{
|
||||||
|
return mEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Value associated with the event.
|
||||||
|
*/
|
||||||
|
public Number getValue()
|
||||||
|
{
|
||||||
|
return mValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasValue()
|
||||||
|
{
|
||||||
|
return mValue != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source associated with the event
|
||||||
|
*/
|
||||||
|
public Source getSource()
|
||||||
|
{
|
||||||
|
return mSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if this event contains an optional source
|
||||||
|
*/
|
||||||
|
public boolean hasSource()
|
||||||
|
{
|
||||||
|
return mSource != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new frequency change event
|
||||||
|
*
|
||||||
|
* @param frequency in hertz
|
||||||
|
*/
|
||||||
|
public static SourceEvent frequencyChange(long frequency)
|
||||||
|
{
|
||||||
|
return new SourceEvent(Event.NOTIFICATION_FREQUENCY_CHANGE, frequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new frequency correction change event
|
||||||
|
*
|
||||||
|
* @param frequencyCorrection in hertz
|
||||||
|
*/
|
||||||
|
public static SourceEvent frequencyCorrectionChange(long frequencyCorrection)
|
||||||
|
{
|
||||||
|
return new SourceEvent(Event.NOTIFICATION_FREQUENCY_CORRECTION_CHANGE, frequencyCorrection);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new channel frequency correction change event
|
||||||
|
*
|
||||||
|
* @param frequencyCorrection in hertz
|
||||||
|
*/
|
||||||
|
public static SourceEvent channelFrequencyCorrectionChange(long frequencyCorrection)
|
||||||
|
{
|
||||||
|
return new SourceEvent(Event.NOTIFICATION_CHANNEL_FREQUENCY_CORRECTION_CHANGE, frequencyCorrection);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new sample rate change event
|
||||||
|
*
|
||||||
|
* @param sampleRate in hertz
|
||||||
|
*/
|
||||||
|
public static SourceEvent sampleRateChange(int sampleRate)
|
||||||
|
{
|
||||||
|
return new SourceEvent(Event.NOTIFICATION_SAMPLE_RATE_CHANGE, sampleRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new channel sample rate change event
|
||||||
|
*
|
||||||
|
* @param sampleRate in hertz
|
||||||
|
*/
|
||||||
|
public static SourceEvent channelSampleRateChange(int sampleRate)
|
||||||
|
{
|
||||||
|
return new SourceEvent(Event.NOTIFICATION_CHANNEL_SAMPLE_RATE_CHANGE, sampleRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new channel count change event
|
||||||
|
*
|
||||||
|
* @param channelCount
|
||||||
|
*/
|
||||||
|
public static SourceEvent channelCountChange(int channelCount)
|
||||||
|
{
|
||||||
|
return new SourceEvent(Event.NOTIFICATION_POLYPHASE_CHANNEL_COUNT_CHANGE, channelCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new frequency change request event
|
||||||
|
*
|
||||||
|
* @param frequency requested
|
||||||
|
*/
|
||||||
|
public static SourceEvent frequencyRequest(long frequency)
|
||||||
|
{
|
||||||
|
return new SourceEvent(Event.REQUEST_FREQUENCY_CHANGE, frequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new channel frequency correction change request event
|
||||||
|
*
|
||||||
|
* @param frequency requested
|
||||||
|
*/
|
||||||
|
public static SourceEvent channelFrequencyCorrectionRequest(long frequency)
|
||||||
|
{
|
||||||
|
return new SourceEvent(Event.REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE, frequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new start sample stream request event
|
||||||
|
*/
|
||||||
|
public static SourceEvent startSampleStream(Source source)
|
||||||
|
{
|
||||||
|
return new SourceEvent(Event.REQUEST_START_SAMPLE_STREAM, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new stop sample stream request event
|
||||||
|
*/
|
||||||
|
public static SourceEvent stopSampleStream(Source source)
|
||||||
|
{
|
||||||
|
return new SourceEvent(Event.REQUEST_STOP_SAMPLE_STREAM, source);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 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 License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,14 +14,14 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package source.config;
|
package source.config;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
|
||||||
|
|
||||||
import source.SourceType;
|
import source.SourceType;
|
||||||
import source.tuner.TunerChannel;
|
import source.tuner.TunerChannel;
|
||||||
import source.tuner.TunerChannel.Type;
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
|
||||||
public class SourceConfigRecording extends SourceConfiguration
|
public class SourceConfigRecording extends SourceConfiguration
|
||||||
{
|
{
|
||||||
@@ -63,8 +63,8 @@ public class SourceConfigRecording extends SourceConfiguration
|
|||||||
|
|
||||||
public TunerChannel getTunerChannel()
|
public TunerChannel getTunerChannel()
|
||||||
{
|
{
|
||||||
/* Create a tuner channel with a default bandwidth of 15 kHz */
|
/* Create a tuner channel with a default bandwidth of 12.5 kHz */
|
||||||
return new TunerChannel( Type.LOCKED, mFrequency, 15000 );
|
return new TunerChannel(mFrequency, 12500);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 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 License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,20 +14,19 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package source.config;
|
package source.config;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
|
||||||
|
|
||||||
import source.SourceType;
|
import source.SourceType;
|
||||||
import source.tuner.TunerChannel;
|
import source.tuner.TunerChannel;
|
||||||
import source.tuner.TunerChannel.Type;
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
public class SourceConfigTuner extends SourceConfiguration
|
public class SourceConfigTuner extends SourceConfiguration
|
||||||
{
|
{
|
||||||
private static DecimalFormat sFORMAT = new DecimalFormat( "0.00000" );
|
private static DecimalFormat FREQUENCY_FORMAT = new DecimalFormat("0.00000");
|
||||||
|
|
||||||
private long mFrequency = 0;
|
private long mFrequency = 0;
|
||||||
private int mBandwidth = 12500;
|
private int mBandwidth = 12500;
|
||||||
@@ -59,11 +58,11 @@ public class SourceConfigTuner extends SourceConfiguration
|
|||||||
@Override
|
@Override
|
||||||
public String getDescription()
|
public String getDescription()
|
||||||
{
|
{
|
||||||
return sFORMAT.format( (double)mFrequency / 1000000.0d ) + " MHz";
|
return FREQUENCY_FORMAT.format((double)mFrequency / 1000000.0d) + " MHz";
|
||||||
}
|
}
|
||||||
|
|
||||||
public TunerChannel getTunerChannel()
|
public TunerChannel getTunerChannel()
|
||||||
{
|
{
|
||||||
return new TunerChannel( Type.LOCKED, mFrequency, mBandwidth );
|
return new TunerChannel(mFrequency, mBandwidth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import sample.real.RealBuffer;
|
|||||||
import source.RealSource;
|
import source.RealSource;
|
||||||
import source.SourceException;
|
import source.SourceException;
|
||||||
import dsp.gain.AutomaticGainControl;
|
import dsp.gain.AutomaticGainControl;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent;
|
||||||
|
|
||||||
public class RealMixerSource extends RealSource
|
public class RealMixerSource extends RealSource
|
||||||
{
|
{
|
||||||
@@ -80,19 +80,19 @@ public class RealMixerSource extends RealSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
public void setSourceEventListener(Listener<SourceEvent> listener)
|
||||||
{
|
{
|
||||||
//Not implemented
|
//Not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeFrequencyChangeListener()
|
public void removeSourceEventListener()
|
||||||
{
|
{
|
||||||
//Not implemented
|
//Not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
public Listener<SourceEvent> getSourceEventListener()
|
||||||
{
|
{
|
||||||
//Not implemented
|
//Not implemented
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ import source.SourceException;
|
|||||||
import source.tuner.ITunerChannelProvider;
|
import source.tuner.ITunerChannelProvider;
|
||||||
import source.tuner.TunerChannel;
|
import source.tuner.TunerChannel;
|
||||||
import source.tuner.TunerChannelSource;
|
import source.tuner.TunerChannelSource;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
import source.SourceEvent.Event;
|
||||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
import source.ISourceEventProcessor;
|
||||||
|
|
||||||
public class Recording implements Comparable<Recording>,
|
public class Recording implements Comparable<Recording>,
|
||||||
IFrequencyChangeProcessor,
|
ISourceEventProcessor,
|
||||||
ITunerChannelProvider
|
ITunerChannelProvider
|
||||||
{
|
{
|
||||||
private RecordingConfiguration mConfiguration;
|
private RecordingConfiguration mConfiguration;
|
||||||
@@ -89,7 +89,7 @@ public class Recording implements Comparable<Recording>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void frequencyChanged( FrequencyChangeEvent event ) throws SourceException
|
public void process(SourceEvent event ) throws SourceException
|
||||||
{
|
{
|
||||||
if( event.getEvent() == Event.NOTIFICATION_FREQUENCY_CHANGE )
|
if( event.getEvent() == Event.NOTIFICATION_FREQUENCY_CHANGE )
|
||||||
{
|
{
|
||||||
@@ -103,7 +103,7 @@ public class Recording implements Comparable<Recording>,
|
|||||||
|
|
||||||
for( TunerChannelSource channel: mTunerChannels )
|
for( TunerChannelSource channel: mTunerChannels )
|
||||||
{
|
{
|
||||||
channel.frequencyChanged( event );
|
channel.process( event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
169
src/source/tuner/ComplexChannelSource.java
Normal file
169
src/source/tuner/ComplexChannelSource.java
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* 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 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 source.tuner;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import sample.Listener;
|
||||||
|
import sample.complex.ComplexBuffer;
|
||||||
|
import source.ComplexSource;
|
||||||
|
import source.ISourceEventProcessor;
|
||||||
|
import source.SourceEvent;
|
||||||
|
import source.SourceException;
|
||||||
|
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Complex source that provides a complex sample stream at the channel's required sample rate
|
||||||
|
*/
|
||||||
|
public abstract class ComplexChannelSource extends ComplexSource implements ISourceEventProcessor
|
||||||
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger(ComplexChannelSource.class);
|
||||||
|
private SourceEventProcessor mSourceEventProcessor = new SourceEventProcessor();
|
||||||
|
private Listener<SourceEvent> mSourceEventListener;
|
||||||
|
private Listener<ComplexBuffer> mComplexBufferListener;
|
||||||
|
private ISourceEventProcessor mUpstreamSourceEventProcessor;
|
||||||
|
|
||||||
|
public ComplexChannelSource(ISourceEventProcessor upstreamSourceEventProcessor)
|
||||||
|
{
|
||||||
|
mUpstreamSourceEventProcessor = upstreamSourceEventProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the source event listener to receive source events from this source
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setSourceEventListener(Listener<SourceEvent> listener)
|
||||||
|
{
|
||||||
|
mSourceEventListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the source event listener from receiving source events from this source
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeSourceEventListener()
|
||||||
|
{
|
||||||
|
mSourceEventListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Broadcasts the source event to the registered source event listener
|
||||||
|
*/
|
||||||
|
protected void broadcast(SourceEvent sourceEvent)
|
||||||
|
{
|
||||||
|
if(mSourceEventListener != null)
|
||||||
|
{
|
||||||
|
mSourceEventListener.receive(sourceEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the listener to receive complex sample buffers from this channel source
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setListener(Listener<ComplexBuffer> listener)
|
||||||
|
{
|
||||||
|
mComplexBufferListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeListener(Listener<ComplexBuffer> listener)
|
||||||
|
{
|
||||||
|
mComplexBufferListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatches the processed complex buffer to the downstream consumer.
|
||||||
|
* @param complexBuffer containing complex samples
|
||||||
|
*/
|
||||||
|
protected void broadcast(ComplexBuffer complexBuffer)
|
||||||
|
{
|
||||||
|
if(mComplexBufferListener != null)
|
||||||
|
{
|
||||||
|
mComplexBufferListener.receive(complexBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(ScheduledExecutorService executor)
|
||||||
|
{
|
||||||
|
//TODO: start a runnable to process downstream buffer dispatching
|
||||||
|
|
||||||
|
if(mUpstreamSourceEventProcessor != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mUpstreamSourceEventProcessor.process(SourceEvent.startSampleStream(ComplexChannelSource.this));
|
||||||
|
}
|
||||||
|
catch(SourceException se)
|
||||||
|
{
|
||||||
|
mLog.error("Error starting complex channel source");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop()
|
||||||
|
{
|
||||||
|
if(mUpstreamSourceEventProcessor != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mUpstreamSourceEventProcessor.process(SourceEvent.stopSampleStream(ComplexChannelSource.this));
|
||||||
|
}
|
||||||
|
catch(SourceException se)
|
||||||
|
{
|
||||||
|
mLog.error("Error starting complex channel source");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: cancel a runnable to process downstream buffer dispatching
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source Event processor interface for this source to receive source events
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Listener<SourceEvent> getSourceEventListener()
|
||||||
|
{
|
||||||
|
return mSourceEventProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapter for implementing ISourceEventProcessor and dispatching source events to subclasses via the
|
||||||
|
* ISourceEventProcessor.process() method.
|
||||||
|
*/
|
||||||
|
public class SourceEventProcessor implements Listener<SourceEvent>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void receive(SourceEvent sourceEvent)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
process(sourceEvent);
|
||||||
|
}
|
||||||
|
catch(SourceException se)
|
||||||
|
{
|
||||||
|
mLog.error("Error processing source event", se);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 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 License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,23 +14,24 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package source.tuner;
|
package source.tuner;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import sample.Broadcaster;
|
||||||
|
import sample.Listener;
|
||||||
|
import sample.complex.ComplexBuffer;
|
||||||
|
import source.ISourceEventProcessor;
|
||||||
|
import source.SourceEvent;
|
||||||
|
import source.SourceException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import sample.Listener;
|
|
||||||
import sample.complex.ComplexBuffer;
|
|
||||||
import source.SourceException;
|
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
|
||||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tuner - provides tuner channel sources, representing a channel frequency
|
* Tuner - provides tuner channel sources, representing a channel frequency
|
||||||
*/
|
*/
|
||||||
@@ -44,11 +45,9 @@ public abstract class Tuner implements ITunerChannelProvider
|
|||||||
* Sample Listeners - these will typically be the DFT processor for spectral
|
* Sample Listeners - these will typically be the DFT processor for spectral
|
||||||
* display, or it will be one or more tuner channel sources
|
* display, or it will be one or more tuner channel sources
|
||||||
*/
|
*/
|
||||||
protected List<Listener<ComplexBuffer>> mSampleListeners =
|
protected List<Listener<ComplexBuffer>> mSampleListeners = new CopyOnWriteArrayList<>();
|
||||||
new CopyOnWriteArrayList<>();
|
protected List<Listener<TunerEvent>> mTunerChangeListeners = new ArrayList<>();
|
||||||
|
protected Broadcaster<SourceEvent> mSourceEventBroadcaster = new Broadcaster<>();
|
||||||
protected List<Listener<TunerEvent>> mTunerChangeListeners =
|
|
||||||
new ArrayList<>();
|
|
||||||
|
|
||||||
public Tuner(String name, TunerController tunerController)
|
public Tuner(String name, TunerController tunerController)
|
||||||
{
|
{
|
||||||
@@ -56,10 +55,10 @@ public abstract class Tuner implements ITunerChannelProvider
|
|||||||
mTunerController = tunerController;
|
mTunerController = tunerController;
|
||||||
|
|
||||||
//Rebroadcast frequency and sample rate change events as tuner events
|
//Rebroadcast frequency and sample rate change events as tuner events
|
||||||
mTunerController.addListener( new IFrequencyChangeProcessor()
|
mTunerController.addListener(new ISourceEventProcessor()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void frequencyChanged( FrequencyChangeEvent event )
|
public void process(SourceEvent event)
|
||||||
{
|
{
|
||||||
switch(event.getEvent())
|
switch(event.getEvent())
|
||||||
{
|
{
|
||||||
@@ -121,6 +120,7 @@ public abstract class Tuner implements ITunerChannelProvider
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of this tuner object
|
* Name of this tuner object
|
||||||
|
*
|
||||||
* @return - string name of this tuner object
|
* @return - string name of this tuner object
|
||||||
*/
|
*/
|
||||||
public String getName()
|
public String getName()
|
||||||
@@ -140,8 +140,7 @@ public abstract class Tuner implements ITunerChannelProvider
|
|||||||
* tuner channel source as a listener on the tuner, to receive frequency
|
* tuner channel source as a listener on the tuner, to receive frequency
|
||||||
* change events.
|
* change events.
|
||||||
*
|
*
|
||||||
* @param frequency - desired frequency
|
* @param channel - desired frequency and bandwidth
|
||||||
*
|
|
||||||
* @return - source for 48k sample rate
|
* @return - source for 48k sample rate
|
||||||
*/
|
*/
|
||||||
public abstract TunerChannelSource getChannel(TunerChannel channel)
|
public abstract TunerChannelSource getChannel(TunerChannel channel)
|
||||||
@@ -153,7 +152,7 @@ public abstract class Tuner implements ITunerChannelProvider
|
|||||||
* Note: ensure the concrete implementation unregisters the tuner channel
|
* Note: ensure the concrete implementation unregisters the tuner channel
|
||||||
* source from the tuner as a frequency change listener
|
* source from the tuner as a frequency change listener
|
||||||
*
|
*
|
||||||
* @param channel - previously obtained tuner channel
|
* @param source - previously obtained tuner channel
|
||||||
*/
|
*/
|
||||||
public abstract void releaseChannel(TunerChannelSource source);
|
public abstract void releaseChannel(TunerChannelSource source);
|
||||||
|
|
||||||
@@ -203,11 +202,38 @@ public abstract class Tuner implements ITunerChannelProvider
|
|||||||
/**
|
/**
|
||||||
* Broadcasts the tuner change event
|
* Broadcasts the tuner change event
|
||||||
*/
|
*/
|
||||||
public void broadcast( TunerEvent event )
|
public void broadcast(TunerEvent tunerEvent)
|
||||||
{
|
{
|
||||||
for(Listener<TunerEvent> listener : mTunerChangeListeners)
|
for(Listener<TunerEvent> listener : mTunerChangeListeners)
|
||||||
{
|
{
|
||||||
listener.receive( event );
|
listener.receive(tunerEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Re-broadcast frequency and sample rate change events as source events
|
||||||
|
switch(tunerEvent.getEvent())
|
||||||
|
{
|
||||||
|
case FREQUENCY:
|
||||||
|
mSourceEventBroadcaster.broadcast(SourceEvent.frequencyChange(getTunerController().getFrequency()));
|
||||||
|
break;
|
||||||
|
case SAMPLE_RATE:
|
||||||
|
mSourceEventBroadcaster.broadcast(SourceEvent.sampleRateChange(getTunerController().getSampleRate()));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the listener to receive source events
|
||||||
|
*/
|
||||||
|
public void addSourceEventListener(Listener<SourceEvent> listener)
|
||||||
|
{
|
||||||
|
mSourceEventBroadcaster.addListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the listener from receiving source events
|
||||||
|
*/
|
||||||
|
public void removeSourceEventListener(Listener<SourceEvent> listener)
|
||||||
|
{
|
||||||
|
mSourceEventBroadcaster.removeListener(listener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014,2015 Dennis Sheirer
|
* Copyright (C) 2014-2017 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 License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,32 +14,21 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package source.tuner;
|
package source.tuner;
|
||||||
|
|
||||||
public class TunerChannel implements Comparable<TunerChannel>
|
public class TunerChannel implements Comparable<TunerChannel>
|
||||||
{
|
{
|
||||||
private Type mType;
|
|
||||||
private long mFrequency;
|
private long mFrequency;
|
||||||
private int mBandwidth;
|
private int mBandwidth;
|
||||||
|
|
||||||
public TunerChannel( Type type, long frequency, int bandwidth )
|
public TunerChannel(long frequency, int bandwidth)
|
||||||
{
|
{
|
||||||
mType = type;
|
|
||||||
mFrequency = frequency;
|
mFrequency = frequency;
|
||||||
mBandwidth = bandwidth;
|
mBandwidth = bandwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType()
|
|
||||||
{
|
|
||||||
return mType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType( Type type )
|
|
||||||
{
|
|
||||||
mType = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getFrequency()
|
public long getFrequency()
|
||||||
{
|
{
|
||||||
return mFrequency;
|
return mFrequency;
|
||||||
@@ -99,24 +88,6 @@ public class TunerChannel implements Comparable<TunerChannel>
|
|||||||
@Override
|
@Override
|
||||||
public int compareTo(TunerChannel otherLock)
|
public int compareTo(TunerChannel otherLock)
|
||||||
{
|
{
|
||||||
if( this.equals( otherLock ) )
|
return Long.compare(getFrequency(), otherLock.getFrequency());
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if( mFrequency < otherLock.getFrequency() )
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Type
|
|
||||||
{
|
|
||||||
LOCKED, //Use for decoding channels, so that they cannot be tuned out of range
|
|
||||||
TRAFFIC, //Like locked, but for temporary allocated traffic channels
|
|
||||||
TUNABLE; //Tunable -- can be tuned out of range
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,11 +32,10 @@ import sample.complex.ComplexBuffer;
|
|||||||
import sample.real.IOverflowListener;
|
import sample.real.IOverflowListener;
|
||||||
import source.ComplexSource;
|
import source.ComplexSource;
|
||||||
import source.SourceException;
|
import source.SourceException;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.ISourceEventListener;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
import source.ISourceEventProvider;
|
||||||
import source.tuner.frequency.IFrequencyChangeListener;
|
import source.SourceEvent;
|
||||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
import source.ISourceEventProcessor;
|
||||||
import source.tuner.frequency.IFrequencyChangeProvider;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -46,7 +45,7 @@ import java.util.concurrent.ScheduledFuture;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public class TunerChannelSource extends ComplexSource implements IFrequencyChangeProcessor, Listener<ComplexBuffer>
|
public class TunerChannelSource extends ComplexSource implements ISourceEventProcessor, Listener<ComplexBuffer>
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(TunerChannelSource.class);
|
private final static Logger mLog = LoggerFactory.getLogger(TunerChannelSource.class);
|
||||||
|
|
||||||
@@ -66,7 +65,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
private Oscillator mMixer;
|
private Oscillator mMixer;
|
||||||
private ComplexPrimeCICDecimate mDecimationFilter;
|
private ComplexPrimeCICDecimate mDecimationFilter;
|
||||||
private Listener<ComplexBuffer> mListener;
|
private Listener<ComplexBuffer> mListener;
|
||||||
private IFrequencyChangeProcessor mFrequencyChangeProcessor;
|
private ISourceEventProcessor mFrequencyChangeProcessor;
|
||||||
private DownstreamProcessor mDownstreamFrequencyEventProcessor = new DownstreamProcessor();
|
private DownstreamProcessor mDownstreamFrequencyEventProcessor = new DownstreamProcessor();
|
||||||
private ScheduledFuture<?> mTaskHandle;
|
private ScheduledFuture<?> mTaskHandle;
|
||||||
|
|
||||||
@@ -100,7 +99,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
{
|
{
|
||||||
mTuner = tuner;
|
mTuner = tuner;
|
||||||
mTunerChannel = tunerChannel;
|
mTunerChannel = tunerChannel;
|
||||||
mTuner.getTunerController().addListener((IFrequencyChangeProcessor) this);
|
mTuner.getTunerController().addListener((ISourceEventProcessor) this);
|
||||||
mTunerFrequency = mTuner.getTunerController().getFrequency();
|
mTunerFrequency = mTuner.getTunerController().getFrequency();
|
||||||
|
|
||||||
mBuffer = new OverflowableTransferQueue<>(BUFFER_MAX_CAPACITY, BUFFER_OVERFLOW_RESET_THRESHOLD);
|
mBuffer = new OverflowableTransferQueue<>(BUFFER_MAX_CAPACITY, BUFFER_OVERFLOW_RESET_THRESHOLD);
|
||||||
@@ -111,8 +110,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
mMixer = new Oscillator(frequencyOffset, mTuner.getTunerController().getSampleRate());
|
mMixer = new Oscillator(frequencyOffset, mTuner.getTunerController().getSampleRate());
|
||||||
|
|
||||||
/* Fire a sample rate change event to setup the decimation chain */
|
/* Fire a sample rate change event to setup the decimation chain */
|
||||||
frequencyChanged(new FrequencyChangeEvent(Event.NOTIFICATION_SAMPLE_RATE_CHANGE,
|
process(SourceEvent.sampleRateChange(mTuner.getTunerController().getSampleRate()));
|
||||||
mTuner.getTunerController().getSampleRate()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,7 +200,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
updateMixerFrequencyOffset();
|
updateMixerFrequencyOffset();
|
||||||
|
|
||||||
mDownstreamFrequencyEventProcessor.broadcast(
|
mDownstreamFrequencyEventProcessor.broadcast(
|
||||||
new FrequencyChangeEvent( Event.NOTIFICATION_CHANNEL_FREQUENCY_CORRECTION_CHANGE, mChannelFrequencyCorrection));
|
SourceEvent.channelFrequencyCorrectionChange(mChannelFrequencyCorrection));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tuner getTuner()
|
public Tuner getTuner()
|
||||||
@@ -224,7 +222,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFrequencyChangeListener(IFrequencyChangeProcessor processor)
|
public void setFrequencyChangeListener(ISourceEventProcessor processor)
|
||||||
{
|
{
|
||||||
mFrequencyChangeProcessor = processor;
|
mFrequencyChangeProcessor = processor;
|
||||||
}
|
}
|
||||||
@@ -250,12 +248,12 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
* frequency correction events received from the channel consumer/listener
|
* frequency correction events received from the channel consumer/listener
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void frequencyChanged(FrequencyChangeEvent event) throws SourceException
|
public void process(SourceEvent event) throws SourceException
|
||||||
{
|
{
|
||||||
// Echo the event to the registered event listener
|
// Echo the event to the registered event listener
|
||||||
if(mFrequencyChangeProcessor != null)
|
if(mFrequencyChangeProcessor != null)
|
||||||
{
|
{
|
||||||
mFrequencyChangeProcessor.frequencyChanged(event);
|
mFrequencyChangeProcessor.process(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(event.getEvent())
|
switch(event.getEvent())
|
||||||
@@ -320,36 +318,36 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements IFrequencyChangeProvider to enable this source to broadcast frequency change events to downstream
|
* Implements ISourceEventProvider to enable this source to broadcast frequency change events to downstream
|
||||||
* listeners.
|
* listeners.
|
||||||
*
|
*
|
||||||
* @param listener to receive downstream events
|
* @param listener to receive downstream events
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
public void setSourceEventListener(Listener<SourceEvent> listener)
|
||||||
{
|
{
|
||||||
mDownstreamFrequencyEventProcessor.setFrequencyChangeListener(listener);
|
mDownstreamFrequencyEventProcessor.setSourceEventListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements IFrequencyChangeProvider to remove the frequency change listener from receiving down-stream frequency
|
* Implements ISourceEventProvider to remove the frequency change listener from receiving down-stream frequency
|
||||||
* change events.
|
* change events.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void removeFrequencyChangeListener()
|
public void removeSourceEventListener()
|
||||||
{
|
{
|
||||||
mDownstreamFrequencyEventProcessor.removeFrequencyChangeListener();
|
mDownstreamFrequencyEventProcessor.removeSourceEventListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements IFrequencyChangeListener to receive frequency change events containing requests from downstream
|
* Implements ISourceEventListener to receive frequency change events containing requests from downstream
|
||||||
* listeners to change frequency values.
|
* listeners to change frequency values.
|
||||||
* @return listener
|
* @return listener
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
public Listener<SourceEvent> getSourceEventListener()
|
||||||
{
|
{
|
||||||
return mDownstreamFrequencyEventProcessor.getFrequencyChangeListener();
|
return mDownstreamFrequencyEventProcessor.getSourceEventListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -358,17 +356,17 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
* notified of any frequency or sample rate change events and will also be able to request frequency correction
|
* notified of any frequency or sample rate change events and will also be able to request frequency correction
|
||||||
* updates.
|
* updates.
|
||||||
*/
|
*/
|
||||||
public class DownstreamProcessor implements IFrequencyChangeListener, IFrequencyChangeProvider,
|
public class DownstreamProcessor implements ISourceEventListener, ISourceEventProvider,
|
||||||
Listener<FrequencyChangeEvent>
|
Listener<SourceEvent>
|
||||||
{
|
{
|
||||||
//Listener to receive downstream events
|
//Listener to receive downstream events
|
||||||
private Listener<FrequencyChangeEvent> mListener;
|
private Listener<SourceEvent> mListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcasts the frequency change event to the downstream frequency change listener
|
* Broadcasts the frequency change event to the downstream frequency change listener
|
||||||
* @param event to broadcast
|
* @param event to broadcast
|
||||||
*/
|
*/
|
||||||
public void broadcast(FrequencyChangeEvent event)
|
public void broadcast(SourceEvent event)
|
||||||
{
|
{
|
||||||
if(mListener != null)
|
if(mListener != null)
|
||||||
{
|
{
|
||||||
@@ -384,7 +382,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
long frequency = getFrequency();
|
long frequency = getFrequency();
|
||||||
broadcast(new FrequencyChangeEvent(Event.NOTIFICATION_FREQUENCY_CHANGE, frequency));
|
broadcast(SourceEvent.frequencyChange(frequency));
|
||||||
}
|
}
|
||||||
catch(SourceException se)
|
catch(SourceException se)
|
||||||
{
|
{
|
||||||
@@ -400,7 +398,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Note: downstream sample rate is currently a fixed value -- it will change in the future
|
//Note: downstream sample rate is currently a fixed value -- it will change in the future
|
||||||
broadcast(new FrequencyChangeEvent(Event.NOTIFICATION_SAMPLE_RATE_CHANGE, getSampleRate()));
|
broadcast(SourceEvent.sampleRateChange(getSampleRate()));
|
||||||
}
|
}
|
||||||
catch(SourceException se)
|
catch(SourceException se)
|
||||||
{
|
{
|
||||||
@@ -413,7 +411,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
* @param listener to receive events
|
* @param listener to receive events
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
public void setSourceEventListener(Listener<SourceEvent> listener)
|
||||||
{
|
{
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
}
|
}
|
||||||
@@ -422,7 +420,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
* Removes the downstream listener from receiving frequency change events.
|
* Removes the downstream listener from receiving frequency change events.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void removeFrequencyChangeListener()
|
public void removeSourceEventListener()
|
||||||
{
|
{
|
||||||
mListener = null;
|
mListener = null;
|
||||||
}
|
}
|
||||||
@@ -431,7 +429,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
* Listener for receiving frequency change events from downstream components
|
* Listener for receiving frequency change events from downstream components
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
public Listener<SourceEvent> getSourceEventListener()
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -441,7 +439,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
* @param event to process
|
* @param event to process
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void receive(FrequencyChangeEvent event)
|
public void receive(SourceEvent event)
|
||||||
{
|
{
|
||||||
switch(event.getEvent())
|
switch(event.getEvent())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import source.SourceException;
|
import source.SourceException;
|
||||||
import source.tuner.configuration.TunerConfiguration;
|
import source.tuner.configuration.TunerConfiguration;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
import source.SourceEvent.Event;
|
||||||
import source.tuner.frequency.FrequencyController;
|
import source.tuner.frequency.FrequencyController;
|
||||||
import source.tuner.frequency.FrequencyController.Tunable;
|
import source.tuner.frequency.FrequencyController.Tunable;
|
||||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
import source.ISourceEventProcessor;
|
||||||
|
|
||||||
public abstract class TunerController implements Tunable, IFrequencyChangeProcessor
|
public abstract class TunerController implements Tunable, ISourceEventProcessor
|
||||||
{
|
{
|
||||||
private final static Logger mLog =
|
private final static Logger mLog =
|
||||||
LoggerFactory.getLogger( TunerController.class );
|
LoggerFactory.getLogger( TunerController.class );
|
||||||
@@ -79,7 +79,7 @@ public abstract class TunerController implements Tunable, IFrequencyChangeProces
|
|||||||
* Responds to requests to set the frequency
|
* Responds to requests to set the frequency
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void frequencyChanged( FrequencyChangeEvent event ) throws SourceException
|
public void process(SourceEvent event ) throws SourceException
|
||||||
{
|
{
|
||||||
if( event.getEvent() == Event.REQUEST_FREQUENCY_CHANGE )
|
if( event.getEvent() == Event.REQUEST_FREQUENCY_CHANGE )
|
||||||
{
|
{
|
||||||
@@ -381,7 +381,7 @@ public abstract class TunerController implements Tunable, IFrequencyChangeProces
|
|||||||
* Note: this is normally used by the Tuner. Any additional listeners can
|
* Note: this is normally used by the Tuner. Any additional listeners can
|
||||||
* be registered on the tuner.
|
* be registered on the tuner.
|
||||||
*/
|
*/
|
||||||
public void addListener( IFrequencyChangeProcessor processor )
|
public void addListener( ISourceEventProcessor processor )
|
||||||
{
|
{
|
||||||
mFrequencyController.addListener( processor );
|
mFrequencyController.addListener( processor );
|
||||||
}
|
}
|
||||||
@@ -389,7 +389,7 @@ public abstract class TunerController implements Tunable, IFrequencyChangeProces
|
|||||||
/**
|
/**
|
||||||
* Removes the frequency change listener
|
* Removes the frequency change listener
|
||||||
*/
|
*/
|
||||||
public void removeListener( IFrequencyChangeProcessor processor )
|
public void removeListener( ISourceEventProcessor processor )
|
||||||
{
|
{
|
||||||
mFrequencyController.removeFrequencyChangeProcessor( processor );
|
mFrequencyController.removeFrequencyChangeProcessor( processor );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import gui.editor.Editor;
|
|||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import source.config.SourceConfigTuner;
|
import source.config.SourceConfigTuner;
|
||||||
import source.config.SourceConfiguration;
|
import source.config.SourceConfiguration;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent;
|
||||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
import source.ISourceEventProcessor;
|
||||||
import controller.channel.Channel;
|
import controller.channel.Channel;
|
||||||
|
|
||||||
public class TunerSourceEditor extends Editor<Channel>
|
public class TunerSourceEditor extends Editor<Channel>
|
||||||
@@ -41,10 +41,10 @@ public class TunerSourceEditor extends Editor<Channel>
|
|||||||
setLayout( new MigLayout( "insets 0 0 0 0", "[left]", "" ) );
|
setLayout( new MigLayout( "insets 0 0 0 0", "[left]", "" ) );
|
||||||
mFrequencyControl = new JFrequencyControl();
|
mFrequencyControl = new JFrequencyControl();
|
||||||
mFrequencyControl.setEnabled( false );
|
mFrequencyControl.setEnabled( false );
|
||||||
mFrequencyControl.addListener( new IFrequencyChangeProcessor()
|
mFrequencyControl.addListener( new ISourceEventProcessor()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void frequencyChanged( FrequencyChangeEvent event )
|
public void process(SourceEvent event )
|
||||||
{
|
{
|
||||||
setModified( true );
|
setModified( true );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,128 +0,0 @@
|
|||||||
package source.tuner.frequency;
|
|
||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2016 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/>
|
|
||||||
******************************************************************************/
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
|
|
||||||
import module.Module;
|
|
||||||
import sample.Listener;
|
|
||||||
import sample.real.RealBuffer;
|
|
||||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
|
||||||
|
|
||||||
public class DCTrackingFrequencyControl extends Module
|
|
||||||
implements Listener<RealBuffer>, IFrequencyChangeProvider
|
|
||||||
{
|
|
||||||
private static float COARSE_THRESHOLD = 0.1f;
|
|
||||||
private static float LOOP_GAIN = 0.1f;
|
|
||||||
private static float COARSE_GAIN = 1000.0f;
|
|
||||||
private static float FINE_GAIN = 100.0f;
|
|
||||||
private int mErrorCorrection = 0;
|
|
||||||
private int mMaximumFrequencyCorrection = 0;
|
|
||||||
private Listener<FrequencyChangeEvent> mListener;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DC offset Automatic Frequency Control. Monitors DC bias present in an FM
|
|
||||||
* demodulated audio stream and issues automatic frequency corrections to
|
|
||||||
* maintain the DC bias close to zero.
|
|
||||||
*
|
|
||||||
* @param maximum - maximum allowable (+/-) frequency correction value.
|
|
||||||
*/
|
|
||||||
public DCTrackingFrequencyControl( int maximum )
|
|
||||||
{
|
|
||||||
mMaximumFrequencyCorrection = maximum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose()
|
|
||||||
{
|
|
||||||
mListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive( RealBuffer buffer )
|
|
||||||
{
|
|
||||||
double sum = 0.0d;
|
|
||||||
|
|
||||||
for( float sample: buffer.getSamples() )
|
|
||||||
{
|
|
||||||
sum += sample;
|
|
||||||
}
|
|
||||||
|
|
||||||
float mean = (float)( sum / (double)buffer.getSamples().length );
|
|
||||||
|
|
||||||
float adjustment = 0.0f;
|
|
||||||
|
|
||||||
if( mean > COARSE_THRESHOLD || mean < - COARSE_THRESHOLD )
|
|
||||||
{
|
|
||||||
adjustment = mean * COARSE_GAIN;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
adjustment = mean * FINE_GAIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
setErrorCorrection( mErrorCorrection + (int)( (float)adjustment * LOOP_GAIN ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setErrorCorrection( int correction )
|
|
||||||
{
|
|
||||||
if( mListener != null )
|
|
||||||
{
|
|
||||||
if( correction > mMaximumFrequencyCorrection )
|
|
||||||
{
|
|
||||||
correction = mMaximumFrequencyCorrection;
|
|
||||||
}
|
|
||||||
else if( correction < -mMaximumFrequencyCorrection )
|
|
||||||
{
|
|
||||||
correction = -mMaximumFrequencyCorrection;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( correction != mErrorCorrection )
|
|
||||||
{
|
|
||||||
mListener.receive( new FrequencyChangeEvent(
|
|
||||||
Event.REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE, correction ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setFrequencyChangeListener( Listener<FrequencyChangeEvent> listener )
|
|
||||||
{
|
|
||||||
mListener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeFrequencyChangeListener()
|
|
||||||
{
|
|
||||||
mListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start( ScheduledExecutorService executor )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reset()
|
|
||||||
{
|
|
||||||
setErrorCorrection( 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
130
src/source/tuner/frequency/DCTrackingSourceControl.java
Normal file
130
src/source/tuner/frequency/DCTrackingSourceControl.java
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* 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 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 source.tuner.frequency;
|
||||||
|
|
||||||
|
import module.Module;
|
||||||
|
import sample.Listener;
|
||||||
|
import sample.real.RealBuffer;
|
||||||
|
import source.ISourceEventProvider;
|
||||||
|
import source.SourceEvent;
|
||||||
|
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
|
public class DCTrackingSourceControl extends Module
|
||||||
|
implements Listener<RealBuffer>, ISourceEventProvider
|
||||||
|
{
|
||||||
|
private static float COARSE_THRESHOLD = 0.1f;
|
||||||
|
private static float LOOP_GAIN = 0.1f;
|
||||||
|
private static float COARSE_GAIN = 1000.0f;
|
||||||
|
private static float FINE_GAIN = 100.0f;
|
||||||
|
private int mErrorCorrection = 0;
|
||||||
|
private int mMaximumFrequencyCorrection = 0;
|
||||||
|
private Listener<SourceEvent> mListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DC offset Automatic Frequency Control. Monitors DC bias present in an FM
|
||||||
|
* demodulated audio stream and issues automatic frequency corrections to
|
||||||
|
* maintain the DC bias close to zero.
|
||||||
|
*
|
||||||
|
* @param maximum - maximum allowable (+/-) frequency correction value.
|
||||||
|
*/
|
||||||
|
public DCTrackingSourceControl(int maximum)
|
||||||
|
{
|
||||||
|
mMaximumFrequencyCorrection = maximum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose()
|
||||||
|
{
|
||||||
|
mListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receive(RealBuffer buffer)
|
||||||
|
{
|
||||||
|
double sum = 0.0d;
|
||||||
|
|
||||||
|
for(float sample : buffer.getSamples())
|
||||||
|
{
|
||||||
|
sum += sample;
|
||||||
|
}
|
||||||
|
|
||||||
|
float mean = (float)(sum / (double)buffer.getSamples().length);
|
||||||
|
|
||||||
|
float adjustment = 0.0f;
|
||||||
|
|
||||||
|
if(mean > COARSE_THRESHOLD || mean < -COARSE_THRESHOLD)
|
||||||
|
{
|
||||||
|
adjustment = mean * COARSE_GAIN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
adjustment = mean * FINE_GAIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
setErrorCorrection(mErrorCorrection + (int)((float)adjustment * LOOP_GAIN));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setErrorCorrection(int correction)
|
||||||
|
{
|
||||||
|
if(mListener != null)
|
||||||
|
{
|
||||||
|
if(correction > mMaximumFrequencyCorrection)
|
||||||
|
{
|
||||||
|
correction = mMaximumFrequencyCorrection;
|
||||||
|
}
|
||||||
|
else if(correction < -mMaximumFrequencyCorrection)
|
||||||
|
{
|
||||||
|
correction = -mMaximumFrequencyCorrection;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(correction != mErrorCorrection)
|
||||||
|
{
|
||||||
|
mListener.receive(SourceEvent.channelFrequencyCorrectionRequest(correction));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSourceEventListener(Listener<SourceEvent> listener)
|
||||||
|
{
|
||||||
|
mListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeSourceEventListener()
|
||||||
|
{
|
||||||
|
mListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(ScheduledExecutorService executor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset()
|
||||||
|
{
|
||||||
|
setErrorCorrection(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package source.tuner.frequency;
|
|
||||||
|
|
||||||
public class FrequencyChangeEvent
|
|
||||||
{
|
|
||||||
public enum Event
|
|
||||||
{
|
|
||||||
NOTIFICATION_FREQUENCY_CHANGE,
|
|
||||||
NOTIFICATION_FREQUENCY_CORRECTION_CHANGE,
|
|
||||||
NOTIFICATION_CHANNEL_FREQUENCY_CORRECTION_CHANGE,
|
|
||||||
NOTIFICATION_SAMPLE_RATE_CHANGE,
|
|
||||||
|
|
||||||
REQUEST_FREQUENCY_CHANGE,
|
|
||||||
REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Event mEvent;
|
|
||||||
private Number mValue;
|
|
||||||
|
|
||||||
public FrequencyChangeEvent( Event event, Number value )
|
|
||||||
{
|
|
||||||
mEvent = event;
|
|
||||||
mValue = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Event getEvent()
|
|
||||||
{
|
|
||||||
return mEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Number getValue()
|
|
||||||
{
|
|
||||||
return mValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
package source.tuner.frequency;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import sample.Listener;
|
|
||||||
import source.SourceException;
|
|
||||||
import source.tuner.hackrf.HackRFTunerEditor;
|
|
||||||
|
|
||||||
public class FrequencyChangeProcessorWrapper
|
|
||||||
implements IFrequencyChangeListener, Listener<FrequencyChangeEvent>
|
|
||||||
{
|
|
||||||
private final static Logger mLog = LoggerFactory.getLogger( FrequencyChangeProcessorWrapper.class );
|
|
||||||
|
|
||||||
private IFrequencyChangeProcessor mProcessor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides IFrequencyChangeListener wrapper for an IFrequencyChangeProcessor
|
|
||||||
*/
|
|
||||||
public FrequencyChangeProcessorWrapper( IFrequencyChangeProcessor handler )
|
|
||||||
{
|
|
||||||
mProcessor = handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive( FrequencyChangeEvent event )
|
|
||||||
{
|
|
||||||
if( mProcessor != null )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mProcessor.frequencyChanged( event );
|
|
||||||
}
|
|
||||||
catch( SourceException se )
|
|
||||||
{
|
|
||||||
mLog.error("Error sending frequency change event to embedded processor", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 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 License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,18 +14,18 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package source.tuner.frequency;
|
package source.tuner.frequency;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import source.ISourceEventProcessor;
|
||||||
import source.InvalidFrequencyException;
|
import source.InvalidFrequencyException;
|
||||||
import source.Source;
|
import source.SourceEvent;
|
||||||
import source.SourceException;
|
import source.SourceException;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class FrequencyController
|
public class FrequencyController
|
||||||
{
|
{
|
||||||
@@ -39,12 +39,9 @@ public class FrequencyController
|
|||||||
private double mFrequencyCorrection = 0d;
|
private double mFrequencyCorrection = 0d;
|
||||||
private int mSampleRate = 0;
|
private int mSampleRate = 0;
|
||||||
|
|
||||||
private ArrayList<IFrequencyChangeProcessor> mProcessors = new ArrayList<>();
|
private ArrayList<ISourceEventProcessor> mProcessors = new ArrayList<>();
|
||||||
|
|
||||||
public FrequencyController( Tunable tunable,
|
public FrequencyController(Tunable tunable, long minFrequency, long maxFrequency, double frequencyCorrection)
|
||||||
long minFrequency,
|
|
||||||
long maxFrequency,
|
|
||||||
double frequencyCorrection )
|
|
||||||
{
|
{
|
||||||
mTunable = tunable;
|
mTunable = tunable;
|
||||||
mMinimumFrequency = minFrequency;
|
mMinimumFrequency = minFrequency;
|
||||||
@@ -80,6 +77,7 @@ public class FrequencyController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set frequency
|
* Set frequency
|
||||||
|
*
|
||||||
* @param frequency in hertz
|
* @param frequency in hertz
|
||||||
* @throws SourceException if tunable doesn't support tuning a corrected
|
* @throws SourceException if tunable doesn't support tuning a corrected
|
||||||
* version of the requested frequency
|
* version of the requested frequency
|
||||||
@@ -142,6 +140,7 @@ public class FrequencyController
|
|||||||
/**
|
/**
|
||||||
* Calculate the tuned frequency by adding frequency correction to the
|
* Calculate the tuned frequency by adding frequency correction to the
|
||||||
* corrected frequency.
|
* corrected frequency.
|
||||||
|
*
|
||||||
* @param correctedFrequency
|
* @param correctedFrequency
|
||||||
*/
|
*/
|
||||||
private long getTunedFrequency(long correctedFrequency)
|
private long getTunedFrequency(long correctedFrequency)
|
||||||
@@ -153,6 +152,7 @@ public class FrequencyController
|
|||||||
/**
|
/**
|
||||||
* Calculate the corrected frequency by subtracting frequency correction
|
* Calculate the corrected frequency by subtracting frequency correction
|
||||||
* from the tuned frequency.
|
* from the tuned frequency.
|
||||||
|
*
|
||||||
* @param tunedFrequency
|
* @param tunedFrequency
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@@ -176,14 +176,13 @@ public class FrequencyController
|
|||||||
setFrequency(mFrequency, true);
|
setFrequency(mFrequency, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
broadcastFrequencyErrorChange();
|
broadcastFrequencyCorrectionChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds listener to receive frequency change events
|
* Adds listener to receive frequency change events
|
||||||
*/
|
*/
|
||||||
//TODO: rename this to addFrequencyChangeProcessor()
|
public void addListener(ISourceEventProcessor processor)
|
||||||
public void addListener( IFrequencyChangeProcessor processor )
|
|
||||||
{
|
{
|
||||||
if(!mProcessors.contains(processor))
|
if(!mProcessors.contains(processor))
|
||||||
{
|
{
|
||||||
@@ -194,7 +193,7 @@ public class FrequencyController
|
|||||||
/**
|
/**
|
||||||
* Removes listener from receiving frequency change events
|
* Removes listener from receiving frequency change events
|
||||||
*/
|
*/
|
||||||
public void removeFrequencyChangeProcessor( IFrequencyChangeProcessor processor )
|
public void removeFrequencyChangeProcessor(ISourceEventProcessor processor)
|
||||||
{
|
{
|
||||||
mProcessors.remove(processor);
|
mProcessors.remove(processor);
|
||||||
}
|
}
|
||||||
@@ -206,17 +205,15 @@ public class FrequencyController
|
|||||||
*/
|
*/
|
||||||
protected void broadcastFrequencyChange() throws SourceException
|
protected void broadcastFrequencyChange() throws SourceException
|
||||||
{
|
{
|
||||||
broadcastFrequencyChangeEvent(
|
broadcast(SourceEvent.frequencyChange(mFrequency));
|
||||||
new FrequencyChangeEvent( Event.NOTIFICATION_FREQUENCY_CHANGE, mFrequency ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcast a frequency error/correction value change
|
* Broadcast a frequency error/correction value change
|
||||||
*/
|
*/
|
||||||
protected void broadcastFrequencyErrorChange() throws SourceException
|
protected void broadcastFrequencyCorrectionChange() throws SourceException
|
||||||
{
|
{
|
||||||
broadcastFrequencyChangeEvent(
|
broadcast(SourceEvent.frequencyCorrectionChange((int)mFrequencyCorrection));
|
||||||
new FrequencyChangeEvent( Event.NOTIFICATION_FREQUENCY_CORRECTION_CHANGE, mFrequencyCorrection ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -224,15 +221,14 @@ public class FrequencyController
|
|||||||
*/
|
*/
|
||||||
protected void broadcastSampleRateChange() throws SourceException
|
protected void broadcastSampleRateChange() throws SourceException
|
||||||
{
|
{
|
||||||
broadcastFrequencyChangeEvent(
|
broadcast(SourceEvent.sampleRateChange(mSampleRate));
|
||||||
new FrequencyChangeEvent( Event.NOTIFICATION_SAMPLE_RATE_CHANGE, mSampleRate ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void broadcastFrequencyChangeEvent( FrequencyChangeEvent event ) throws SourceException
|
public void broadcast(SourceEvent event) throws SourceException
|
||||||
{
|
{
|
||||||
for( IFrequencyChangeProcessor processor: mProcessors )
|
for(ISourceEventProcessor processor : mProcessors)
|
||||||
{
|
{
|
||||||
processor.frequencyChanged( event );
|
processor.process(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 source.tuner.frequency;
|
|
||||||
|
|
||||||
import sample.Listener;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for broadcasting changes to frequency, bandwidth, sample rate,
|
|
||||||
* and actual sample rate values to all registered listeners.
|
|
||||||
*
|
|
||||||
* Note: broadcasted frequency should be the uncorrected, or displayable
|
|
||||||
* frequency value. All frequency correction aspects should be handled within
|
|
||||||
* the device that implements the tuning of the frequency.
|
|
||||||
*/
|
|
||||||
public interface IFrequencyChangeListener
|
|
||||||
{
|
|
||||||
public Listener<FrequencyChangeEvent> getFrequencyChangeListener();
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package source.tuner.frequency;
|
|
||||||
|
|
||||||
import source.SourceException;
|
|
||||||
|
|
||||||
public interface IFrequencyChangeProcessor
|
|
||||||
{
|
|
||||||
public void frequencyChanged( FrequencyChangeEvent event ) throws SourceException;
|
|
||||||
}
|
|
||||||
@@ -37,7 +37,7 @@ import sample.complex.ComplexBuffer;
|
|||||||
import source.ComplexSource;
|
import source.ComplexSource;
|
||||||
import source.IControllableFileSource;
|
import source.IControllableFileSource;
|
||||||
import source.IFrameLocationListener;
|
import source.IFrameLocationListener;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent;
|
||||||
|
|
||||||
public class ComplexWaveSource extends ComplexSource implements IControllableFileSource
|
public class ComplexWaveSource extends ComplexSource implements IControllableFileSource
|
||||||
{
|
{
|
||||||
@@ -58,19 +58,19 @@ public class ComplexWaveSource extends ComplexSource implements IControllableFil
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
public void setSourceEventListener(Listener<SourceEvent> listener)
|
||||||
{
|
{
|
||||||
//Not implemented
|
//Not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeFrequencyChangeListener()
|
public void removeSourceEventListener()
|
||||||
{
|
{
|
||||||
//Not implemented
|
//Not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
public Listener<SourceEvent> getSourceEventListener()
|
||||||
{
|
{
|
||||||
//Not implemented
|
//Not implemented
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import sample.real.RealBuffer;
|
|||||||
import source.IControllableFileSource;
|
import source.IControllableFileSource;
|
||||||
import source.IFrameLocationListener;
|
import source.IFrameLocationListener;
|
||||||
import source.RealSource;
|
import source.RealSource;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent;
|
||||||
|
|
||||||
public class RealWaveSource extends RealSource
|
public class RealWaveSource extends RealSource
|
||||||
implements IControllableFileSource, AutoCloseable
|
implements IControllableFileSource, AutoCloseable
|
||||||
@@ -58,19 +58,19 @@ public class RealWaveSource extends RealSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
public void setSourceEventListener(Listener<SourceEvent> listener)
|
||||||
{
|
{
|
||||||
//Not implemented
|
//Not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeFrequencyChangeListener()
|
public void removeSourceEventListener()
|
||||||
{
|
{
|
||||||
//Not implemented
|
//Not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
public Listener<SourceEvent> getSourceEventListener()
|
||||||
{
|
{
|
||||||
//Not implemented
|
//Not implemented
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ import settings.ColorSettingMenuItem;
|
|||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingChangeListener;
|
import settings.SettingChangeListener;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
import source.SourceEvent.Event;
|
||||||
import spectrum.converter.DFTResultsConverter;
|
import spectrum.converter.DFTResultsConverter;
|
||||||
import spectrum.converter.RealDecibelConverter;
|
import spectrum.converter.RealDecibelConverter;
|
||||||
import spectrum.menu.AveragingItem;
|
import spectrum.menu.AveragingItem;
|
||||||
@@ -90,8 +90,7 @@ public class ChannelSpectrumPanel extends JPanel
|
|||||||
mDFTConverter.addListener( mSpectrumPanel );
|
mDFTConverter.addListener( mSpectrumPanel );
|
||||||
|
|
||||||
/* Set the DFTProcessor to the decimated 24kHz sample rate */
|
/* Set the DFTProcessor to the decimated 24kHz sample rate */
|
||||||
mDFTProcessor.frequencyChanged(
|
mDFTProcessor.process(SourceEvent.sampleRateChange(24000));
|
||||||
new FrequencyChangeEvent( Event.NOTIFICATION_SAMPLE_RATE_CHANGE, 24000 ) );
|
|
||||||
|
|
||||||
initGui();
|
initGui();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ import sample.Buffer;
|
|||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.SampleType;
|
import sample.SampleType;
|
||||||
import sample.complex.ComplexBuffer;
|
import sample.complex.ComplexBuffer;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent;
|
||||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
import source.ISourceEventProcessor;
|
||||||
import spectrum.converter.DFTResultsConverter;
|
import spectrum.converter.DFTResultsConverter;
|
||||||
import util.ThreadPool;
|
import util.ThreadPool;
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
* Processes both complex samples or float samples and dispatches a float array
|
* Processes both complex samples or float samples and dispatches a float array
|
||||||
* of DFT results, using configurable fft size and output dispatch timelines.
|
* of DFT results, using configurable fft size and output dispatch timelines.
|
||||||
*/
|
*/
|
||||||
public class DFTProcessor implements Listener<ComplexBuffer>, IFrequencyChangeProcessor, IDFTWidthChangeProcessor
|
public class DFTProcessor implements Listener<ComplexBuffer>, ISourceEventProcessor, IDFTWidthChangeProcessor
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(DFTProcessor.class);
|
private final static Logger mLog = LoggerFactory.getLogger(DFTProcessor.class);
|
||||||
|
|
||||||
@@ -452,7 +452,7 @@ public class DFTProcessor implements Listener<ComplexBuffer>, IFrequencyChangePr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void frequencyChanged(FrequencyChangeEvent event)
|
public void process(SourceEvent event)
|
||||||
{
|
{
|
||||||
switch(event.getEvent())
|
switch(event.getEvent())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ import settings.Setting;
|
|||||||
import settings.SettingChangeListener;
|
import settings.SettingChangeListener;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import source.tuner.TunerChannel;
|
import source.tuner.TunerChannel;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.SourceEvent;
|
||||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
import source.ISourceEventProcessor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -44,7 +44,7 @@ import java.text.DecimalFormat;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
public class OverlayPanel extends JPanel implements ChannelEventListener, IFrequencyChangeProcessor,
|
public class OverlayPanel extends JPanel implements ChannelEventListener, ISourceEventProcessor,
|
||||||
SettingChangeListener
|
SettingChangeListener
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -635,7 +635,7 @@ public class OverlayPanel extends JPanel implements ChannelEventListener, IFrequ
|
|||||||
* Frequency change event handler
|
* Frequency change event handler
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void frequencyChanged(FrequencyChangeEvent event)
|
public void process(SourceEvent event)
|
||||||
{
|
{
|
||||||
switch(event.getEvent())
|
switch(event.getEvent())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,10 +36,9 @@ import sample.complex.ComplexBuffer;
|
|||||||
import settings.ColorSetting.ColorSettingName;
|
import settings.ColorSetting.ColorSettingName;
|
||||||
import settings.ColorSettingMenuItem;
|
import settings.ColorSettingMenuItem;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
|
import source.ISourceEventProcessor;
|
||||||
|
import source.SourceEvent;
|
||||||
import source.tuner.Tuner;
|
import source.tuner.Tuner;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
|
||||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
|
||||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
|
||||||
import spectrum.OverlayPanel.ChannelDisplay;
|
import spectrum.OverlayPanel.ChannelDisplay;
|
||||||
import spectrum.converter.ComplexDecibelConverter;
|
import spectrum.converter.ComplexDecibelConverter;
|
||||||
import spectrum.converter.DFTResultsConverter;
|
import spectrum.converter.DFTResultsConverter;
|
||||||
@@ -65,7 +64,7 @@ import java.text.DecimalFormat;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
|
||||||
public class SpectralDisplayPanel extends JPanel implements Listener<ComplexBuffer>, IFrequencyChangeProcessor, IDFTWidthChangeProcessor
|
public class SpectralDisplayPanel extends JPanel implements Listener<ComplexBuffer>, ISourceEventProcessor, IDFTWidthChangeProcessor
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -223,7 +222,7 @@ public class SpectralDisplayPanel extends JPanel implements Listener<ComplexBuff
|
|||||||
*
|
*
|
||||||
* @param zoom level, 0 - 6.
|
* @param zoom level, 0 - 6.
|
||||||
* @param frequency under the mouse to maintain while zooming
|
* @param frequency under the mouse to maintain while zooming
|
||||||
* @param xAxisOffset where to maintain the frequency under the mouse
|
* @param windowOffset where to maintain the frequency under the mouse
|
||||||
*/
|
*/
|
||||||
public void setZoom(int zoom, long frequency, double windowOffset)
|
public void setZoom(int zoom, long frequency, double windowOffset)
|
||||||
{
|
{
|
||||||
@@ -392,10 +391,10 @@ public class SpectralDisplayPanel extends JPanel implements Listener<ComplexBuff
|
|||||||
/**
|
/**
|
||||||
* Receives frequency change events -- primarily from tuner components.
|
* Receives frequency change events -- primarily from tuner components.
|
||||||
*/
|
*/
|
||||||
public void frequencyChanged(FrequencyChangeEvent event)
|
public void process(SourceEvent event)
|
||||||
{
|
{
|
||||||
mOverlayPanel.frequencyChanged(event);
|
mOverlayPanel.process(event);
|
||||||
mDFTProcessor.frequencyChanged(event);
|
mDFTProcessor.process(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -431,13 +430,9 @@ public class SpectralDisplayPanel extends JPanel implements Listener<ComplexBuff
|
|||||||
|
|
||||||
//Fire frequency and sample rate change events so that the spectrum
|
//Fire frequency and sample rate change events so that the spectrum
|
||||||
//and overlay panels can synchronize
|
//and overlay panels can synchronize
|
||||||
frequencyChanged(new FrequencyChangeEvent(
|
process(SourceEvent.frequencyChange(mTuner.getTunerController().getFrequency()));
|
||||||
Event.NOTIFICATION_FREQUENCY_CHANGE,
|
|
||||||
mTuner.getTunerController().getFrequency()));
|
|
||||||
|
|
||||||
frequencyChanged(new FrequencyChangeEvent(
|
process(SourceEvent.sampleRateChange(mTuner.getTunerController().getSampleRate()));
|
||||||
Event.NOTIFICATION_SAMPLE_RATE_CHANGE,
|
|
||||||
mTuner.getTunerController().getSampleRate()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user