Compare commits

...

40 Commits

Author SHA1 Message Date
Denny
fbc6e508bd Increments build to 0.3.0-beta10 2017-04-14 07:46:18 -04:00
Denny Sheirer
f9b6e67b00 Merge pull request #240 from DSheirer/234-long-alias-names-cause-audio-label-to-wrap
Long alias names cause audio label to wrap
2017-03-31 01:13:17 +00:00
Denny
a628800a71 Resolves #234 - updates the miglayout layout manager to allow jlabel text strings to be automatically truncated (with ellipses) when the alias name is too long. 2017-03-30 21:12:06 -04:00
Denny
25f71a76c4 Resolves #234 - hard codes alias name truncation when name exceeds 33 characters in length. 2017-03-30 20:03:48 -04:00
Denny
5fe8ccd478 Resolves #234 - change the order of assigning an icon and alias text to the audio panel in an attempt to prevent the audio channel panel from wrapping to the next line when the text is too long to display. 2017-03-30 19:52:35 -04:00
Denny Sheirer
069f951a86 Merge pull request #239 from DSheirer/228-traffic-channel-allocation-for-do-not-monitor
Traffic channel manager now allocates traffic channels for do not monitor aliases
2017-03-30 23:27:38 +00:00
Denny
dab6df7836 Resolves #228 - traffic channel manager now allocates traffic channels even when the alias is marked as do not monitor 2017-03-30 19:26:35 -04:00
Denny Sheirer
89da46b63c Merge pull request #238 from DSheirer/235-lojack-decoder-error-on-construction
Resolves error on constructing a LoJack decoder state.
2017-03-30 23:19:29 +00:00
Denny
5f2ce2a9f2 Resolves #235 - fixes error on constructing a LoJack decoder state. 2017-03-30 19:18:39 -04:00
Denny Sheirer
7a0b377971 Merge pull request #232 from DSheirer/229-p25-phase2-event-duplicates
Resolves #229 - duplicate P25 TDMA call events.
2017-03-23 21:52:47 +00:00
Denny
5dbe0ecce3 Resolves #229 - duplicate P25 TDMA call events. 2017-03-23 21:48:52 +00:00
Denny Sheirer
6647c581a6 Merge pull request #231 from DSheirer/230-p25-tdma-frequency-bands
P25 Phase II TDMA frequency bands are now displayed in details summary
2017-03-23 21:01:58 +00:00
Denny
a2ab5bfa95 Resolves #230 - P25 Phase II TDMA frequency bands are now displayed in the channel details summary. 2017-03-23 20:55:42 +00:00
Denny
ed486440b8 Merge remote-tracking branch 'origin/master' 2017-03-12 11:33:17 -04:00
Denny
13464e01fc Updates build to 0.3.0 Beta 9 2017-03-12 11:33:04 -04:00
Denny Sheirer
ea46a8b0e8 Merge pull request #225 from DSheirer/222-spectral-display-of-frequency-correction-offset
Frequency change event handling in the processing chain
2017-03-11 17:03:34 +00:00
Denny
d510c34356 Adds frequency change event listener handler to LSM decoder. 2017-03-11 12:01:45 -05:00
Denny
ae8a44caed Removes cic cleanup filter from processing chain. 2017-03-11 11:53:12 -05:00
Denny
1aa85a86ca Resolves issue with channel frequency correction events not being broadcast within the processing chain and rendering in the spectral display. 2017-03-11 10:16:08 -05:00
Denny Sheirer
17539d4d55 Merge pull request #224 from DSheirer/223-now-playing-frequency-format
Now Playing frequency display formatting
2017-03-11 11:14:58 +00:00
Denny
1db1d28390 Resolves issue with frequency display formating in the Now Playing window. 2017-03-11 06:13:59 -05:00
Denny Sheirer
37a941e904 Merge pull request #219 from DSheirer/218-audio-priority-
Resolves issue with audio playback allowing higher priority audio to preempt lower priority audio
2017-03-05 12:34:09 +00:00
Denny
57f6655824 Resolves issue where higher priority audio was not preempting lower priority audio. 2017-03-05 07:32:42 -05:00
Denny Sheirer
4cd8f8209f Merge pull request #216 from DSheirer/215-audio-recording-handles-part-2
215 audio recording handles part 2
2017-03-03 15:49:24 +00:00
Denny
61bfef5798 Incrementing build to version 0.3.0 beta8 2017-03-03 10:44:50 -05:00
Denny
ef172a04c6 Cleanup - removed synchronized blocks since the buffer processor thread is the only thread managing recorders. 2017-03-03 10:04:21 -05:00
Denny
a877afcceb Updates buffer processing in recorder manager so that we're not blocking any of the decoding channel producer threads that are trying to push audio packets to the recorder manager. Adds an overflowable packet queue and services the queue once a second followed by an idle recorder check (and disposal). 2017-03-03 10:01:32 -05:00
Denny
980ad72d4d Incrementing build to 0.3.0 beta7 2017-03-03 06:01:09 -05:00
Denny Sheirer
9b746cc032 Merge pull request #215 from DSheirer/198-audio-recorder-handles-left-open
Resolves issue audio recorders left open
2017-03-03 10:58:08 +00:00
Denny
f51ae0b5da Resolves issue with periodic instances of audio recorders not being shutdown correctly. Adds recorder monitor as a fail-safe to automatically shutdown recorders that don't receive an end-call indication. 2017-03-03 05:56:32 -05:00
Denny Sheirer
561078e9bf Merge pull request #214 from DSheirer/210-playlist-saving-all-times
Resolves issue with the playlist saving all of the time
2017-03-03 00:34:25 +00:00
Denny
e052b01f9b Resolves issue with the playlist saving all of the time due to audio streaming broadcast events. 2017-03-02 19:33:10 -05:00
Denny
09cf4fcfd7 Resolves issue with empty string list models in channel editor 2017-02-26 10:29:14 -05:00
Denny
5e731d0e9f Resolves issue with alias list and group combo box value editing. 2017-02-26 06:51:58 -05:00
Denny Sheirer
670a02b0ba Merge pull request #209 from DSheirer/153-cursor-frequency-artifacts
Resolves issue with spectral display rendering artifacts
2017-02-26 10:48:59 +00:00
Denny
9ef156b061 Resolves issue with spectral display rendering artifacts from cursor frequency readout when accessing menu items directly above the spectral display. 2017-02-26 05:47:26 -05:00
Denny
d9cf1b19f3 Removes assert() usage throughout project and replaces with Validate from apache commons. 2017-02-25 16:03:35 -05:00
Denny
a4a339b505 Resolves issue with FCD2 tuner frequency. 2017-02-25 14:58:51 -05:00
Denny
119370c46e Resolves issue with FCD2 tuner frequency. 2017-02-25 14:57:25 -05:00
Denny
4eb66e6045 Updated readme file with screen shot and link to new Version 0.3.0 user's manual. 2017-02-25 06:18:59 -05:00
57 changed files with 3210 additions and 2776 deletions

View File

@@ -2,18 +2,10 @@
A cross-platform java application for decoding, monitoring, recording and streaming trunked mobile and related radio protocols using Software Defined Radios (SDR). A cross-platform java application for decoding, monitoring, recording and streaming trunked mobile and related radio protocols using Software Defined Radios (SDR).
* [Getting Started](https://github.com/DSheirer/sdrtrunk/wiki/GettingStarted) * [Getting Started](https://github.com/DSheirer/sdrtrunk/wiki/GettingStarted)
* [User's Manual](https://github.com/DSheirer/sdrtrunk/wiki/UserManual) * [User's Manual Version 0.2.0](https://github.com/DSheirer/sdrtrunk/wiki/UserManual)
* [User's Manual Version 0.3.0](https://github.com/DSheirer/sdrtrunk/wiki/UserManual_Version0.3.0)
* [Download](https://github.com/DSheirer/sdrtrunk/releases) * [Download](https://github.com/DSheirer/sdrtrunk/releases)
* [Support](https://groups.google.com/forum/#!forum/sdrtrunk) * [Support](https://groups.google.com/forum/#!forum/sdrtrunk)
![](https://github.com/DSheirer/sdrtrunk/wiki/images/SDRTrunk_application.png) ![sdrtrunk Application Overview - Version 0.3.0](https://github.com/DSheirer/sdrtrunk/wiki/images/ApplicationOverview_V0.3.0.png)
<script> **Figure 1:** sdrtrunk **Version 0.3.0** Application Screenshot
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-67489234-1', 'auto');
ga('send', 'pageview');
</script>

View File

@@ -7,7 +7,7 @@
<property name="major" value="0"/> <property name="major" value="0"/>
<property name="minor" value="3"/> <property name="minor" value="3"/>
<property name="patch" value="0"/> <property name="patch" value="0"/>
<property name="release" value="-beta6"/> <property name="release" value="-beta10"/>
<property name="filename" value="sdrtrunk_${major}.${minor}.${patch}${release}"/> <property name="filename" value="sdrtrunk_${major}.${minor}.${patch}${release}"/>
<!-- Build properties --> <!-- Build properties -->

View File

@@ -40,10 +40,11 @@ public class AliasNameEditor extends Editor<Alias>
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static ComboBoxModel<String> EMPTY_MODEL = new DefaultComboBoxModel<>(); private static ComboBoxModel<String> EMPTY_LIST_MODEL = new DefaultComboBoxModel<>();
private static ComboBoxModel<String> EMPTY_GROUP_MODEL = new DefaultComboBoxModel<>();
private JComboBox<String> mListCombo = new JComboBox<>(EMPTY_MODEL); private JComboBox<String> mListCombo = new JComboBox<>(EMPTY_LIST_MODEL);
private JComboBox<String> mGroupCombo = new JComboBox<>(EMPTY_MODEL); private JComboBox<String> mGroupCombo = new JComboBox<>(EMPTY_GROUP_MODEL);
private JComboBox<Icon> mIconCombo; private JComboBox<Icon> mIconCombo;
private JTextField mName; private JTextField mName;
private JButton mButtonColor; private JButton mButtonColor;
@@ -110,7 +111,7 @@ public class AliasNameEditor extends Editor<Alias>
if(groups.isEmpty()) if(groups.isEmpty())
{ {
mGroupCombo.setModel(EMPTY_MODEL); mGroupCombo.setModel(EMPTY_GROUP_MODEL);
} }
else else
{ {
@@ -238,7 +239,7 @@ public class AliasNameEditor extends Editor<Alias>
if(listNames.isEmpty()) if(listNames.isEmpty())
{ {
mListCombo.setModel(EMPTY_MODEL); mListCombo.setModel(EMPTY_LIST_MODEL);
} }
else else
{ {
@@ -253,7 +254,7 @@ public class AliasNameEditor extends Editor<Alias>
if(groupNames.isEmpty()) if(groupNames.isEmpty())
{ {
mGroupCombo.setModel(EMPTY_MODEL); mGroupCombo.setModel(EMPTY_GROUP_MODEL);
} }
else else
{ {
@@ -285,8 +286,8 @@ public class AliasNameEditor extends Editor<Alias>
} }
else else
{ {
mListCombo.setModel(EMPTY_MODEL); mListCombo.setModel(EMPTY_LIST_MODEL);
mGroupCombo.setModel(EMPTY_MODEL); mGroupCombo.setModel(EMPTY_GROUP_MODEL);
mName.setText(null); mName.setText(null);
mButtonColor.setBackground(getBackground()); mButtonColor.setBackground(getBackground());

View File

@@ -18,6 +18,8 @@
******************************************************************************/ ******************************************************************************/
package alias.id; package alias.id;
import org.apache.commons.lang3.Validate;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class WildcardID implements Comparable<WildcardID> public class WildcardID implements Comparable<WildcardID>
@@ -45,7 +47,7 @@ public class WildcardID implements Comparable<WildcardID>
*/ */
public WildcardID(String value) public WildcardID(String value)
{ {
assert(value != null && value.contains(WILDCARD) && value.length() < 10); Validate.isTrue(value != null && value.contains(WILDCARD) && value.length() < 10);
mValue = value; mValue = value;

View File

@@ -90,7 +90,8 @@ public class AudioChannelPanel extends JPanel
private void init() private void init()
{ {
setLayout(new MigLayout("align center center, insets 0 0 0 0", "[][][align right]0[grow,fill]", "")); setLayout(new MigLayout("align center center, insets 0 0 0 0",
"[][][align right]0[grow,fill]", ""));
setBackground(mBackgroundColor); setBackground(mBackgroundColor);
mMutedLabel.setFont(mFont); mMutedLabel.setFont(mFont);
@@ -109,7 +110,7 @@ public class AudioChannelPanel extends JPanel
mTo.setFont(mFont); mTo.setFont(mFont);
mTo.setForeground(mValueColor); mTo.setForeground(mValueColor);
add(mTo); add(mTo,"wmin 10lp");
} }
@Override @Override
@@ -159,29 +160,39 @@ public class AudioChannelPanel extends JPanel
* does not occur on the Swing event thread -- wrap any calls to this * does not occur on the Swing event thread -- wrap any calls to this
* method with an event thread call. * method with an event thread call.
*/ */
private void updateLabel(JLabel valueLabel, String value, JLabel aliasLabel, Alias alias) private void updateLabel(JLabel textLabel, String value, JLabel iconLabel, Alias alias)
{ {
if(value != null) if(value != null)
{ {
if(alias != null) if(alias != null)
{ {
valueLabel.setText(alias.getName()); iconLabel.setIcon(mIconManager.getIcon(alias.getIconName(), 18));
aliasLabel.setIcon(mIconManager.getIcon(alias.getIconName(), 18));
}
else
{
valueLabel.setText(value);
aliasLabel.setIcon(null);
}
}
else
{
valueLabel.setText("-----");
aliasLabel.setIcon(null);
}
}
String aliasName = alias.getName();
//Truncate label if length exceeds 33 characters - hack!
if(aliasName.length() > 33)
{
textLabel.setText(aliasName.substring(0,30) + "...");
}
else
{
textLabel.setText(aliasName);
}
}
else
{
iconLabel.setIcon(null);
textLabel.setText(value);
}
}
else
{
iconLabel.setIcon(null);
textLabel.setText("-----");
}
}
/** /**
* Processes audio metadata to update this panel's display values * Processes audio metadata to update this panel's display values

View File

@@ -33,8 +33,7 @@ public class AudioChannelsPanel extends JPanel
public AudioChannelsPanel(IconManager iconManager, SettingsManager settingsManager, IAudioController controller) public AudioChannelsPanel(IconManager iconManager, SettingsManager settingsManager, IAudioController controller)
{ {
// setLayout(new MigLayout("insets 0 0 0 0", "[][grow,fill][][grow,fill]", "[grow,fill]")); setLayout(new MigLayout("insets 0 0 0 0", "[][sg abc,grow,fill][][sg abc,grow,fill]", "[grow,fill]"));
setLayout(new MigLayout("insets 0 0 0 0", "[][sg,grow,fill][][sg,grow,fill]", "[grow,fill]"));
setBackground(Color.BLACK); setBackground(Color.BLACK);
@@ -44,7 +43,7 @@ public class AudioChannelsPanel extends JPanel
for(int x = 0; x < outputs.size(); x++) for(int x = 0; x < outputs.size(); x++)
{ {
add(new AudioChannelPanel(iconManager, settingsManager, outputs.get(x)), "growx"); add(new AudioChannelPanel(iconManager, settingsManager, outputs.get(x)));
if(x < outputs.size() - 1) if(x < outputs.size() - 1)
{ {

View File

@@ -86,6 +86,9 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
loadSettings(); loadSettings();
} }
/**
* Loads the saved mixer configuration or a default configuration for audio playback.
*/
private void loadSettings() private void loadSettings()
{ {
MixerChannelConfiguration configuration = null; MixerChannelConfiguration configuration = null;
@@ -132,6 +135,9 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
} }
} }
/**
* Creates a default audio playback configuration with a mono audio playback channel.
*/
private MixerChannelConfiguration getDefaultConfiguration() private MixerChannelConfiguration getDefaultConfiguration()
{ {
/* Use the system default mixer and mono channel as default startup */ /* Use the system default mixer and mono channel as default startup */
@@ -161,6 +167,9 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
mAudioOutputConnections.clear(); mAudioOutputConnections.clear();
} }
/**
* Primary ingest point for audio produced by all decoding channels, for distribution to audio playback devices.
*/
@Override @Override
public synchronized void receive(AudioPacket packet) public synchronized void receive(AudioPacket packet)
{ {
@@ -176,11 +185,11 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
for(AudioOutputConnection connection : mAudioOutputConnections) for(AudioOutputConnection connection : mAudioOutputConnections)
{ {
if(connection.isInactive() && if(connection.isInactive() && mChannelConnectionMap.containsKey(connection.getChannelMetadataID()))
mChannelConnectionMap.containsKey(connection.getChannelMetadataID()))
{ {
mChannelConnectionMap.remove(connection.getChannelMetadataID()); mChannelConnectionMap.remove(connection.getChannelMetadataID());
connection.disconnect(); connection.disconnect();
mAvailableConnectionCount++;
changed = true; changed = true;
} }
} }
@@ -192,7 +201,7 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
} }
/** /**
* Identifies the lowest priority channel connection * Identifies the lowest priority channel connection where the a higher value indicates a lower priority.
*/ */
private void updateLowestPriorityAssignment() private void updateLowestPriorityAssignment()
{ {
@@ -201,19 +210,32 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
for(AudioOutputConnection connection : mAudioOutputConnections) for(AudioOutputConnection connection : mAudioOutputConnections)
{ {
if(connection.isConnected() && if(connection.isConnected() &&
(mLowestPriorityConnection == null || mLowestPriorityConnection.getPriority() > connection.getPriority())) (mLowestPriorityConnection == null || mLowestPriorityConnection.getPriority() < connection.getPriority()))
{ {
mLowestPriorityConnection = connection; mLowestPriorityConnection = connection;
} }
} }
} }
/**
* Configures audio playback to use the configuration specified in the entry argument.
*
* @param entry to use in configuring the audio playback setup.
* @throws AudioException if there is an error
*/
@Override @Override
public void setMixerChannelConfiguration(MixerChannelConfiguration entry) throws AudioException public void setMixerChannelConfiguration(MixerChannelConfiguration entry) throws AudioException
{ {
setMixerChannelConfiguration(entry, true); setMixerChannelConfiguration(entry, true);
} }
/**
* Configures audio playback to use the configuration specified in the entry argument.
*
* @param entry to use in configuring the audio playback setup.
* @param saveSettings to save the audio playback configuration settings in the properties file.
* @throws AudioException if there is an error
*/
public void setMixerChannelConfiguration(MixerChannelConfiguration entry, boolean saveSettings) throws AudioException public void setMixerChannelConfiguration(MixerChannelConfiguration entry, boolean saveSettings) throws AudioException
{ {
if(entry != null && (entry.getMixerChannel() == MixerChannel.MONO || entry.getMixerChannel() == MixerChannel.STEREO)) if(entry != null && (entry.getMixerChannel() == MixerChannel.MONO || entry.getMixerChannel() == MixerChannel.STEREO))
@@ -266,9 +288,8 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
} }
/** /**
* Clears all channel assignments and terminates all audio outputs in * Clears all channel assignments and terminates all audio outputs in preparation for complete shutdown or change
* preparation for complete shutdown or change to another mixer/channel * to another mixer/channel configuration
* configuration
*/ */
private void disposeCurrentConfiguration() private void disposeCurrentConfiguration()
{ {
@@ -288,12 +309,18 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
mLowestPriorityConnection = null; mLowestPriorityConnection = null;
} }
/**
* Current audio playback mixer channel configuration setting.
*/
@Override @Override
public MixerChannelConfiguration getMixerChannelConfiguration() throws AudioException public MixerChannelConfiguration getMixerChannelConfiguration() throws AudioException
{ {
return mMixerChannelConfiguration; return mMixerChannelConfiguration;
} }
/**
* List of audio outputs available for the current mixer channel configuration
*/
@Override @Override
public List<AudioOutput> getAudioOutputs() public List<AudioOutput> getAudioOutputs()
{ {
@@ -311,12 +338,18 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
return outputs; return outputs;
} }
/**
* Adds an audio event listener to receive audio event notifications.
*/
@Override @Override
public void addControllerListener(Listener<AudioEvent> listener) public void addControllerListener(Listener<AudioEvent> listener)
{ {
mControllerBroadcaster.addListener(listener); mControllerBroadcaster.addListener(listener);
} }
/**
* Removes an audio event listener from receiving audio event notifications.
*/
@Override @Override
public void removeControllerListener(Listener<AudioEvent> listener) public void removeControllerListener(Listener<AudioEvent> listener)
{ {
@@ -324,16 +357,15 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
} }
/** /**
* Returns an audio output connection for the packet if one is * Returns an audio output connection for the packet if one is available, or overrides an existing lower priority
* available, or overrides an existing lower priority connection. * connection. Returns null if no connection is available for the audio packet.
* Returns null if no connection is available for the audio packet.
* *
* @param packet from a source * @param audioPacket from a decoding channel source
* @return an audio output connection or null * @return an audio output connection or null
*/ */
private AudioOutputConnection getConnection(AudioPacket packet) private AudioOutputConnection getConnection(AudioPacket audioPacket)
{ {
int channelMetadataID = packet.getMetadata().getMetadataID(); int channelMetadataID = audioPacket.getMetadata().getMetadataID();
//Use an existing connection //Use an existing connection
if(mChannelConnectionMap.containsKey(channelMetadataID)) if(mChannelConnectionMap.containsKey(channelMetadataID))
@@ -341,37 +373,35 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
return mChannelConnectionMap.get(channelMetadataID); return mChannelConnectionMap.get(channelMetadataID);
} }
//Connect to and use an available connection //Connect to an unused, available connection
if(mAvailableConnectionCount > 0) if(mAvailableConnectionCount > 0)
{ {
for(AudioOutputConnection connection : mAudioOutputConnections) for(AudioOutputConnection connection : mAudioOutputConnections)
{ {
if(connection.isDisconnected()) if(connection.isDisconnected())
{ {
connection.connect(channelMetadataID); connection.connect(channelMetadataID, audioPacket.getMetadata().getAudioPriority());
mChannelConnectionMap.put(channelMetadataID, connection); mChannelConnectionMap.put(channelMetadataID, connection);
mAvailableConnectionCount--;
return connection; return connection;
} }
} }
} }
//Preempt an existing connection and connect it to this higher priority source //Preempt an existing lower priority connection and connect when this is a higher priority packet
else //Check for a channel priority override else
{ {
int priority = packet.getMetadata().getAudioPriority(); int priority = audioPacket.getMetadata().getAudioPriority();
if(mLowestPriorityConnection != null &&
priority < mLowestPriorityConnection.getPriority())
{
AudioOutputConnection connection = mLowestPriorityConnection; AudioOutputConnection connection = mLowestPriorityConnection;
if(connection != null && priority < connection.getPriority())
{
mChannelConnectionMap.remove(connection.getChannelMetadataID()); mChannelConnectionMap.remove(connection.getChannelMetadataID());
connection.connect(channelMetadataID); connection.connect(channelMetadataID, priority);
mChannelConnectionMap.put(channelMetadataID, connection); mChannelConnectionMap.put(channelMetadataID, connection);
updateLowestPriorityAssignment();
return connection; return connection;
} }
} }
@@ -494,9 +524,11 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
* Connects this assignment to the indicated source so that audio * Connects this assignment to the indicated source so that audio
* packets from this source can be sent to the audio output * packets from this source can be sent to the audio output
*/ */
public void connect(int source) public void connect(int source, int priority)
{ {
mChannelMetadataID = source; mChannelMetadataID = source;
mPriority = priority;
updateLowestPriorityAssignment();
mAudioOutput.updateTimestamp(); mAudioOutput.updateTimestamp();
} }

View File

@@ -21,6 +21,7 @@ package audio.broadcast.shoutcast.v2;
import audio.broadcast.BroadcastConfiguration; import audio.broadcast.BroadcastConfiguration;
import audio.broadcast.BroadcastFormat; import audio.broadcast.BroadcastFormat;
import audio.broadcast.BroadcastServerType; import audio.broadcast.BroadcastServerType;
import org.apache.commons.lang3.Validate;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
@@ -90,7 +91,7 @@ public class ShoutcastV2Configuration extends BroadcastConfiguration
*/ */
public void setStreamID(int streamID) public void setStreamID(int streamID)
{ {
assert(1 <= streamID && streamID <= Integer.MAX_VALUE); Validate.isTrue(1 <= streamID && streamID <= Integer.MAX_VALUE);
mStreamID = streamID; mStreamID = streamID;
} }

View File

@@ -18,6 +18,8 @@
******************************************************************************/ ******************************************************************************/
package audio.broadcast.shoutcast.v2.ultravox; package audio.broadcast.shoutcast.v2.ultravox;
import org.apache.commons.lang3.Validate;
public class NegotiateMaxPayloadSize extends UltravoxMessage public class NegotiateMaxPayloadSize extends UltravoxMessage
{ {
/** /**
@@ -47,8 +49,8 @@ public class NegotiateMaxPayloadSize extends UltravoxMessage
*/ */
public void setMaximumPayloadSize(int desiredMaximum, int minimum) public void setMaximumPayloadSize(int desiredMaximum, int minimum)
{ {
assert(desiredMaximum <= 16377); Validate.isTrue(desiredMaximum <= 16377);
assert(minimum <= 16377); Validate.isTrue(minimum <= 16377);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(desiredMaximum).append(":").append(minimum); sb.append(desiredMaximum).append(":").append(minimum);

View File

@@ -19,6 +19,7 @@
package audio.broadcast.shoutcast.v2.ultravox; package audio.broadcast.shoutcast.v2.ultravox;
import bits.BinaryMessage; import bits.BinaryMessage;
import org.apache.commons.lang3.Validate;
import java.util.Arrays; import java.util.Arrays;
@@ -154,7 +155,7 @@ public abstract class UltravoxMessage
*/ */
public void setSendQueuePriority(int priority) public void setSendQueuePriority(int priority)
{ {
assert(0 <= priority && priority <= 7); Validate.isTrue(0 <= priority && priority <= 7);
mMessage.setInt(priority, SEND_QUEUE_PRIORITY); mMessage.setInt(priority, SEND_QUEUE_PRIORITY);
} }

View File

@@ -22,6 +22,7 @@ import java.util.BitSet;
import java.util.logging.LogManager; import java.util.logging.LogManager;
import edac.CRC; import edac.CRC;
import org.apache.commons.lang3.Validate;
public class BinaryMessage extends BitSet public class BinaryMessage extends BitSet
{ {
@@ -456,7 +457,7 @@ public class BinaryMessage extends BitSet
*/ */
public byte getByte(int index) public byte getByte(int index)
{ {
assert((index + 7) <= size()); Validate.isTrue((index + 7) <= size());
int value = 0; int value = 0;
@@ -481,7 +482,7 @@ public class BinaryMessage extends BitSet
*/ */
public void setByte(int index, byte value) public void setByte(int index, byte value)
{ {
assert((index + 8) <= size()); Validate.isTrue((index + 8) <= size());
int mask = 0x80; int mask = 0x80;

View File

@@ -17,6 +17,8 @@
******************************************************************************/ ******************************************************************************/
package bits; package bits;
import org.apache.commons.lang3.Validate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -39,7 +41,7 @@ public class MultiSyncPatternMatcher
public MultiSyncPatternMatcher( int syncSize ) public MultiSyncPatternMatcher( int syncSize )
{ {
assert( syncSize < 64 ); Validate.isTrue(syncSize < 64);
//Setup a bit mask of all ones the length of the sync pattern //Setup a bit mask of all ones the length of the sync pattern
mMask = (long)( ( Math.pow( 2, syncSize ) ) - 1 ); mMask = (long)( ( Math.pow( 2, syncSize ) ) - 1 );

View File

@@ -32,7 +32,7 @@ import java.util.Map;
public class ChannelMetadataModel extends AbstractTableModel implements Listener<MutableMetadataChangeEvent> public class ChannelMetadataModel extends AbstractTableModel implements Listener<MutableMetadataChangeEvent>
{ {
private final DecimalFormat FREQUENCY_FORMATTER = new DecimalFormat( "#.0000" ); private final DecimalFormat FREQUENCY_FORMATTER = new DecimalFormat( "#.00000" );
public static final int COLUMN_STATE = 0; public static final int COLUMN_STATE = 0;
public static final int COLUMN_DECODER = 1; public static final int COLUMN_DECODER = 1;

View File

@@ -26,6 +26,7 @@ import controller.channel.ChannelUtils;
import icon.IconManager; import icon.IconManager;
import module.ProcessingChain; import module.ProcessingChain;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import properties.SystemProperties; import properties.SystemProperties;
@@ -140,7 +141,7 @@ public class ChannelMetadataPanel extends JPanel implements ListSelectionListene
public AliasedValueCellRenderer(Attribute attribute) public AliasedValueCellRenderer(Attribute attribute)
{ {
assert(attribute != null); Validate.isTrue(attribute != null);
mAttribute = attribute; mAttribute = attribute;
setHorizontalAlignment(JLabel.CENTER); setHorizontalAlignment(JLabel.CENTER);
} }

View File

@@ -36,14 +36,19 @@ 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.tuner.frequency.IFrequencyChangeListener;
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;
public class ChannelState extends Module implements ICallEventProvider, IDecoderStateEventListener, public class ChannelState extends Module implements ICallEventProvider, IDecoderStateEventListener,
IDecoderStateEventProvider, ISquelchStateProvider, IAttributeChangeRequestListener, IOverflowListener IDecoderStateEventProvider, IFrequencyChangeListener, ISquelchStateProvider, IAttributeChangeRequestListener,
IOverflowListener
{ {
private final static Logger mLog = LoggerFactory.getLogger(ChannelState.class); private final static Logger mLog = LoggerFactory.getLogger(ChannelState.class);
@@ -61,6 +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 boolean mSquelchLocked = false; private boolean mSquelchLocked = false;
private boolean mSelected = false; private boolean mSelected = false;
@@ -189,6 +195,17 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
mStateMonitor = null; mStateMonitor = null;
} }
@Override
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
{
if(mFrequencyChangeListener == null)
{
mFrequencyChangeListener = new FrequencyChangeListener();
}
return mFrequencyChangeListener;
}
private boolean isStandardChannel() private boolean isStandardChannel()
{ {
return mChannelType == ChannelType.STANDARD; return mChannelType == ChannelType.STANDARD;
@@ -532,6 +549,23 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
broadcast(mTrafficChannelCallEvent); broadcast(mTrafficChannelCallEvent);
} }
/**
* Listener to receive frequency change events and rebroadcast them to the decoder states
*/
public class FrequencyChangeListener implements Listener<FrequencyChangeEvent>
{
@Override
public void receive(FrequencyChangeEvent frequencyChangeEvent)
{
if(frequencyChangeEvent.getEvent() == NOTIFICATION_FREQUENCY_CHANGE)
{
long frequency = frequencyChangeEvent.getValue().longValue();
broadcast(new DecoderStateEvent(this, Event.SOURCE_FREQUENCY, getState(), frequency));
}
}
}
/** /**
* DecoderStateEvent receiver wrapper * DecoderStateEvent receiver wrapper
*/ */

View File

@@ -63,13 +63,11 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
private Listener<CallEvent> mCallEventListener; private Listener<CallEvent> mCallEventListener;
private ChannelModel mChannelModel; private ChannelModel mChannelModel;
private ChannelProcessingManager mChannelProcessingManager;
private DecodeConfiguration mDecodeConfiguration; private DecodeConfiguration mDecodeConfiguration;
private RecordConfiguration mRecordConfiguration; private RecordConfiguration mRecordConfiguration;
private String mSystem; private String mSystem;
private String mSite; private String mSite;
private String mAliasListName; private String mAliasListName;
private CallEvent mPreviousDoNotMonitorCallEvent;
/** /**
* Monitors call events and allocates traffic decoder channels in response * Monitors call events and allocates traffic decoder channels in response
@@ -77,7 +75,6 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
* traffic channel allocations. * traffic channel allocations.
* *
* @param channelModel containing channels currently in use * @param channelModel containing channels currently in use
* @param channelProcessingManager
* @param decodeConfiguration - decoder configuration to use for each * @param decodeConfiguration - decoder configuration to use for each
* traffic channel allocation. * traffic channel allocation.
* @param recordConfiguration - recording options for each traffic channel * @param recordConfiguration - recording options for each traffic channel
@@ -88,7 +85,6 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
* in the pool * in the pool
*/ */
public TrafficChannelManager(ChannelModel channelModel, public TrafficChannelManager(ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
DecodeConfiguration decodeConfiguration, DecodeConfiguration decodeConfiguration,
RecordConfiguration recordConfiguration, RecordConfiguration recordConfiguration,
String system, String system,
@@ -97,7 +93,6 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
int trafficChannelPoolSize) int trafficChannelPoolSize)
{ {
mChannelModel = channelModel; mChannelModel = channelModel;
mChannelProcessingManager = channelProcessingManager;
mDecodeConfiguration = decodeConfiguration; mDecodeConfiguration = decodeConfiguration;
mRecordConfiguration = recordConfiguration; mRecordConfiguration = recordConfiguration;
mSystem = system; mSystem = system;
@@ -120,7 +115,6 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
mCallEventListener = null; mCallEventListener = null;
mDecodeConfiguration = null; mDecodeConfiguration = null;
mPreviousDoNotMonitorCallEvent = null;
} }
/** /**
@@ -197,21 +191,7 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
long frequency = callEvent.getFrequency(); long frequency = callEvent.getFrequency();
/* Check the from/to aliases for do not monitor priority */ if(frequency > 0)
if(isDoNotMonitor(callEvent))
{
callEvent.setCallEventType(CallEventType.CALL_DO_NOT_MONITOR);
if(isSameCallEvent(mPreviousDoNotMonitorCallEvent, callEvent))
{
return;
}
else
{
mPreviousDoNotMonitorCallEvent = callEvent;
}
}
else if(frequency > 0)
{ {
Channel channel = getChannel(callEvent.getChannel(), new TunerChannel(Type.TRAFFIC, Channel channel = getChannel(callEvent.getChannel(), new TunerChannel(Type.TRAFFIC,
frequency, mDecodeConfiguration.getDecoderType().getChannelBandwidth())); frequency, mDecodeConfiguration.getDecoderType().getChannelBandwidth()));
@@ -330,31 +310,6 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
return false; return false;
} }
/**
* Checks for aliases that contain a do not follow/process priority.
*
* @param event
* @return - true if there is an alias that has a do not process alias id
*/
private boolean isDoNotMonitor(CallEvent event)
{
Alias to = event.getToIDAlias();
if(to != null && to.hasCallPriority() && to.getCallPriority() == Priority.DO_NOT_MONITOR)
{
return true;
}
Alias from = event.getFromIDAlias();
if(from != null && from.hasCallPriority() && from.getCallPriority() == Priority.DO_NOT_MONITOR)
{
return true;
}
return false;
}
@Override @Override
public Listener<DecoderStateEvent> getDecoderStateListener() public Listener<DecoderStateEvent> getDecoderStateListener()
{ {

View File

@@ -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,15 +14,11 @@
* *
* 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 controller.channel; package controller.channel;
import javax.xml.bind.annotation.XmlAttribute; import controller.config.Configuration;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlTransient;
import module.decode.DecoderFactory; import module.decode.DecoderFactory;
import module.decode.DecoderType; import module.decode.DecoderType;
import module.decode.config.AuxDecodeConfiguration; import module.decode.config.AuxDecodeConfiguration;
@@ -31,6 +27,7 @@ import module.log.EventLogType;
import module.log.config.EventLogConfiguration; import module.log.config.EventLogConfiguration;
import record.RecorderType; import record.RecorderType;
import record.config.RecordConfiguration; import record.config.RecordConfiguration;
import sample.Listener;
import source.SourceType; import source.SourceType;
import source.config.SourceConfigFactory; import source.config.SourceConfigFactory;
import source.config.SourceConfigRecording; import source.config.SourceConfigRecording;
@@ -40,15 +37,24 @@ import source.tuner.TunerChannel;
import source.tuner.TunerChannel.Type; import source.tuner.TunerChannel.Type;
import source.tuner.frequency.FrequencyChangeEvent; import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.FrequencyChangeEvent.Event; import source.tuner.frequency.FrequencyChangeEvent.Event;
import source.tuner.frequency.IFrequencyChangeProcessor;
import controller.config.Configuration; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlTransient;
@XmlSeeAlso({Configuration.class}) @XmlSeeAlso({Configuration.class})
@XmlRootElement(name = "channel") @XmlRootElement(name = "channel")
public class Channel extends Configuration implements IFrequencyChangeProcessor public class Channel extends Configuration implements Listener<FrequencyChangeEvent>
{ {
// Standard channels are persisted and traffic channels are temporary // Standard channels are persisted and traffic channels are temporary
public enum ChannelType { STANDARD, TRAFFIC }; public enum ChannelType
{
STANDARD, TRAFFIC
}
;
// Static unique channel identifier tracking // Static unique channel identifier tracking
@@ -278,7 +284,7 @@ public class Channel extends Configuration implements IFrequencyChangeProcessor
* Note: this method is package private and is intended to be managed * Note: this method is package private and is intended to be managed
* by a co-package central processing manager * by a co-package central processing manager
* *
* @see controller.ChannelProcessingManager * @see controller.channel.ChannelProcessingManager
*/ */
void setEnabled(boolean enabled) void setEnabled(boolean enabled)
{ {
@@ -436,8 +442,7 @@ public class Channel extends Configuration implements IFrequencyChangeProcessor
{ {
TunerChannel tunerChannel = getTunerChannel(); TunerChannel tunerChannel = getTunerChannel();
return tunerChannel != null && return tunerChannel != null && tunerChannel.overlaps(minimum, maximum);
tunerChannel.overlaps( minimum, maximum );
} }
/** /**
@@ -447,7 +452,7 @@ public class Channel extends Configuration implements IFrequencyChangeProcessor
* be used to visually show in the spectral display. * be used to visually show in the spectral display.
*/ */
@Override @Override
public void frequencyChanged( FrequencyChangeEvent event ) public void receive(FrequencyChangeEvent event)
{ {
if(event.getEvent() == Event.NOTIFICATION_CHANNEL_FREQUENCY_CORRECTION_CHANGE) if(event.getEvent() == Event.NOTIFICATION_CHANNEL_FREQUENCY_CORRECTION_CHANGE)
{ {
@@ -455,9 +460,21 @@ public class Channel extends Configuration implements IFrequencyChangeProcessor
} }
} }
/**
* Current channel frequency correction value (when this channel is processing)
* @return
*/
@XmlTransient @XmlTransient
public int getChannelFrequencyCorrection() public int getChannelFrequencyCorrection()
{ {
return mChannelFrequencyCorrection; return mChannelFrequencyCorrection;
} }
/**
* Resets frequency correction value to 0
*/
public void resetFrequencyCorrection()
{
mChannelFrequencyCorrection = 0;
}
} }

View File

@@ -231,7 +231,7 @@ public class ChannelProcessingManager implements ChannelEventListener
if(processingChain == null) if(processingChain == null)
{ {
processingChain = new ProcessingChain(channel.getName(), channel.getChannelType()); processingChain = new ProcessingChain(channel.getChannelType());
/* Register global listeners */ /* Register global listeners */
for(Listener<AudioPacket> listener : mAudioPacketListeners) for(Listener<AudioPacket> listener : mAudioPacketListeners)
@@ -244,6 +244,9 @@ public class ChannelProcessingManager implements ChannelEventListener
processingChain.addMessageListener(listener); processingChain.addMessageListener(listener);
} }
//Register channel to receive frequency correction events to show in the spectral display (hack!)
processingChain.addFrequencyChangeListener(channel);
/* Processing Modules */ /* Processing Modules */
List<Module> modules = DecoderFactory.getModules(mChannelModel, mChannelMapModel, this, List<Module> modules = DecoderFactory.getModules(mChannelModel, mChannelMapModel, this,
mAliasModel, channel, processingChain.getChannelState().getMutableMetadata()); mAliasModel, channel, processingChain.getChannelState().getMutableMetadata());
@@ -347,6 +350,9 @@ public class ChannelProcessingManager implements ChannelEventListener
processingChain.removeRecordingModules(); processingChain.removeRecordingModules();
//Deregister channel from receive frequency correction events to show in the spectral display (hack!)
processingChain.removeFrequencyChangeListener(channel);
channel.resetFrequencyCorrection();
mChannelModel.broadcast(new ChannelEvent(channel, Event.NOTIFICATION_PROCESSING_STOP)); mChannelModel.broadcast(new ChannelEvent(channel, Event.NOTIFICATION_PROCESSING_STOP));

View File

@@ -17,34 +17,29 @@
******************************************************************************/ ******************************************************************************/
package controller.channel; package controller.channel;
import alias.AliasModel;
import gui.editor.Editor; import gui.editor.Editor;
import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.miginfocom.swing.MigLayout;
import alias.AliasModel;
public class NameConfigurationEditor extends Editor<Channel> implements DocumentListener public class NameConfigurationEditor extends Editor<Channel> implements DocumentListener
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final static Logger mLog = LoggerFactory.getLogger(NameConfigurationEditor.class); private final static Logger mLog = LoggerFactory.getLogger(NameConfigurationEditor.class);
private static ComboBoxModel<String> EMPTY_MODEL = new DefaultComboBoxModel<>(); private static ComboBoxModel<String> EMPTY_SYSTEM_MODEL = new DefaultComboBoxModel<>();
private static ComboBoxModel<String> EMPTY_SITE_MODEL = new DefaultComboBoxModel<>();
private static ComboBoxModel<String> EMPTY_ALIAS_LIST_MODEL = new DefaultComboBoxModel<>();
private AliasModel mAliasModel; private AliasModel mAliasModel;
private ChannelModel mChannelModel; private ChannelModel mChannelModel;
@@ -73,7 +68,7 @@ public class NameConfigurationEditor extends Editor<Channel> implements Document
add(new JLabel("Name:")); add(new JLabel("Name:"));
add(mChannelName); add(mChannelName);
mSystemNameCombo = new JComboBox<>( EMPTY_MODEL ); mSystemNameCombo = new JComboBox<>(EMPTY_SYSTEM_MODEL);
mSystemNameCombo.setEnabled(false); mSystemNameCombo.setEnabled(false);
mSystemNameCombo.setEditable(true); mSystemNameCombo.setEditable(true);
mSystemNameCombo.addActionListener(new ActionListener() mSystemNameCombo.addActionListener(new ActionListener()
@@ -96,12 +91,13 @@ public class NameConfigurationEditor extends Editor<Channel> implements Document
if(sites.isEmpty()) if(sites.isEmpty())
{ {
mSiteNameCombo.setModel( EMPTY_MODEL ); mSiteNameCombo.setModel(EMPTY_SITE_MODEL);
} }
else else
{ {
mSiteNameCombo.setModel(new DefaultComboBoxModel<String>( mSiteNameCombo.setModel(new DefaultComboBoxModel<String>(
sites.toArray( new String[ sites.size() ] ) ) );; sites.toArray(new String[sites.size()])));
;
} }
mSiteNameCombo.setSelectedItem(getItem().getSite()); mSiteNameCombo.setSelectedItem(getItem().getSite());
@@ -114,7 +110,7 @@ public class NameConfigurationEditor extends Editor<Channel> implements Document
add(new JLabel("System:")); add(new JLabel("System:"));
add(mSystemNameCombo); add(mSystemNameCombo);
mAliasListCombo = new JComboBox<String>(); mAliasListCombo = new JComboBox<String>(EMPTY_ALIAS_LIST_MODEL);
mAliasListCombo.setEnabled(false); mAliasListCombo.setEnabled(false);
mAliasListCombo.setEditable(true); mAliasListCombo.setEditable(true);
mAliasListCombo.addActionListener(new ActionListener() mAliasListCombo.addActionListener(new ActionListener()
@@ -129,7 +125,7 @@ public class NameConfigurationEditor extends Editor<Channel> implements Document
add(new JLabel("Alias List:")); add(new JLabel("Alias List:"));
add(mAliasListCombo); add(mAliasListCombo);
mSiteNameCombo = new JComboBox<>( EMPTY_MODEL ); mSiteNameCombo = new JComboBox<>(EMPTY_SITE_MODEL);
mSiteNameCombo.setEnabled(false); mSiteNameCombo.setEnabled(false);
mSiteNameCombo.setEditable(true); mSiteNameCombo.setEditable(true);
mSiteNameCombo.addActionListener(new ActionListener() mSiteNameCombo.addActionListener(new ActionListener()
@@ -203,12 +199,13 @@ public class NameConfigurationEditor extends Editor<Channel> implements Document
if(systems.isEmpty()) if(systems.isEmpty())
{ {
mSystemNameCombo.setModel( EMPTY_MODEL ); mSystemNameCombo.setModel(EMPTY_SYSTEM_MODEL);
} }
else else
{ {
mSystemNameCombo.setModel(new DefaultComboBoxModel<String>( mSystemNameCombo.setModel(new DefaultComboBoxModel<String>(
systems.toArray( new String[ systems.size() ] ) ) );; systems.toArray(new String[systems.size()])));
;
} }
mSystemNameCombo.setSelectedItem(channel.getSystem()); mSystemNameCombo.setSelectedItem(channel.getSystem());
@@ -217,12 +214,13 @@ public class NameConfigurationEditor extends Editor<Channel> implements Document
if(sites.isEmpty()) if(sites.isEmpty())
{ {
mSiteNameCombo.setModel( EMPTY_MODEL ); mSiteNameCombo.setModel(EMPTY_SITE_MODEL);
} }
else else
{ {
mSiteNameCombo.setModel(new DefaultComboBoxModel<String>( mSiteNameCombo.setModel(new DefaultComboBoxModel<String>(
sites.toArray( new String[ sites.size() ] ) ) );; sites.toArray(new String[sites.size()])));
;
} }
if(channel.getSite() != null) if(channel.getSite() != null)

View File

@@ -19,6 +19,7 @@ package dsp.filter;
import java.util.ArrayList; import java.util.ArrayList;
import org.apache.commons.lang3.Validate;
import sample.real.RealSampleListener; import sample.real.RealSampleListener;
public class FloatFIRFilter implements RealSampleListener public class FloatFIRFilter implements RealSampleListener
@@ -139,7 +140,7 @@ public class FloatFIRFilter implements RealSampleListener
private void generateIndexMap( int size ) private void generateIndexMap( int size )
{ {
//Ensure we have an odd size //Ensure we have an odd size
assert( size % 2 == 1 ); Validate.isTrue(size % 2 == 1);
mIndexMap = new int[ size ][ size ]; mIndexMap = new int[ size ][ size ];

View File

@@ -19,6 +19,7 @@ package dsp.filter;
import java.util.ArrayList; import java.util.ArrayList;
import org.apache.commons.lang3.Validate;
import sample.real.RealSampleListener; import sample.real.RealSampleListener;
public class FloatHalfBandFilter implements RealSampleListener public class FloatHalfBandFilter implements RealSampleListener
@@ -149,7 +150,7 @@ public class FloatHalfBandFilter implements RealSampleListener
private void generateIndexMap( int size ) private void generateIndexMap( int size )
{ {
//Ensure we have an odd size //Ensure we have an odd size
assert( size % 2 == 1 ); Validate.isTrue(size % 2 == 1);
int mapWidth = ( ( size + 1 ) / 2 ) + 1; int mapWidth = ( ( size + 1 ) / 2 ) + 1;

View File

@@ -19,6 +19,7 @@ package dsp.filter;
import java.util.ArrayList; import java.util.ArrayList;
import org.apache.commons.lang3.Validate;
import sample.real.RealSampleListener; import sample.real.RealSampleListener;
public class FloatHalfBandNoDecimateFilter implements RealSampleListener public class FloatHalfBandNoDecimateFilter implements RealSampleListener
@@ -139,7 +140,7 @@ public class FloatHalfBandNoDecimateFilter implements RealSampleListener
private void generateIndexMap( int size ) private void generateIndexMap( int size )
{ {
//Ensure we have an odd size //Ensure we have an odd size
assert( size % 2 == 1 ); Validate.isTrue(size % 2 == 1);
int mapWidth = ( ( size + 1 ) / 2 ) + 1; int mapWidth = ( ( size + 1 ) / 2 ) + 1;

View File

@@ -1,6 +1,6 @@
/******************************************************************************* /*******************************************************************************
* SDR Trunk * sdrtrunk
* Copyright (C) 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,22 +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 dsp.filter.cic; package dsp.filter.cic;
import java.util.ArrayList;
import java.util.List;
import sample.Listener;
import sample.complex.ComplexBuffer;
import sample.complex.ComplexSampleListener;
import sample.complex.ComplexToComplexBufferAssembler;
import sample.decimator.ComplexDecimator;
import dsp.filter.FilterFactory; import dsp.filter.FilterFactory;
import dsp.filter.Filters; import dsp.filter.Filters;
import dsp.filter.Window.WindowType; import dsp.filter.Window.WindowType;
import dsp.filter.fir.complex.ComplexFIRFilter_CB_CB; import dsp.filter.fir.complex.ComplexFIRFilter_CB_CB;
import dsp.filter.halfband.complex.HalfBandFilter_CB_CB; import dsp.filter.halfband.complex.HalfBandFilter_CB_CB;
import org.apache.commons.lang3.Validate;
import sample.Listener;
import sample.complex.ComplexBuffer;
import sample.complex.ComplexSampleListener;
import sample.complex.ComplexToComplexBufferAssembler;
import sample.decimator.ComplexDecimator;
import java.util.ArrayList;
import java.util.List;
public class ComplexPrimeCICDecimate implements Listener<ComplexBuffer> public class ComplexPrimeCICDecimate implements Listener<ComplexBuffer>
{ {
@@ -67,7 +69,7 @@ public class ComplexPrimeCICDecimate implements Listener<ComplexBuffer>
public ComplexPrimeCICDecimate(int decimation, int order, public ComplexPrimeCICDecimate(int decimation, int order,
int passFrequency, int attenuation, WindowType windowType) int passFrequency, int attenuation, WindowType windowType)
{ {
assert( decimation <= 700 ); Validate.isTrue(decimation <= 700);
List<Integer> stageSizes = getPrimeFactors(decimation); List<Integer> stageSizes = getPrimeFactors(decimation);
@@ -366,8 +368,11 @@ public class ComplexPrimeCICDecimate implements Listener<ComplexBuffer>
attenuation, attenuation,
windowType), 0.4f); windowType), 0.4f);
mAssembler.setListener( mCleanupFilter ); //Bypassing the CIC cleanup filter for now
mCleanupFilter.setListener( mHalfBandFilter ); mAssembler.setListener(mHalfBandFilter);
// mAssembler.setListener( mCleanupFilter );
// mCleanupFilter.setListener( mHalfBandFilter );
} }
public void dispose() public void dispose()

View File

@@ -20,6 +20,7 @@ package dsp.filter.cic;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -81,7 +82,7 @@ public class RealPrimeCICDecimate
public RealPrimeCICDecimate( int decimation, int order, int passFrequency, public RealPrimeCICDecimate( int decimation, int order, int passFrequency,
int attenuation, WindowType windowType, int outputBufferSize ) int attenuation, WindowType windowType, int outputBufferSize )
{ {
assert( decimation <= 700 ); Validate.isTrue(decimation <= 700);
mOutputBufferSize = outputBufferSize; mOutputBufferSize = outputBufferSize;

View File

@@ -17,6 +17,8 @@
******************************************************************************/ ******************************************************************************/
package dsp.filter.halfband.real; package dsp.filter.halfband.real;
import org.apache.commons.lang3.Validate;
public class HalfBandFilter public class HalfBandFilter
{ {
private float[] mBuffer; private float[] mBuffer;
@@ -122,7 +124,7 @@ public class HalfBandFilter
private void generateIndexMap( int size ) private void generateIndexMap( int size )
{ {
//Ensure we have an odd size //Ensure we have an odd size
assert( size % 2 == 1 ); Validate.isTrue(size % 2 == 1);
int mapWidth = ( ( size + 1 ) / 2 ) + 1; int mapWidth = ( ( size + 1 ) / 2 ) + 1;

View File

@@ -1,5 +1,6 @@
package dsp.filter.interpolator; package dsp.filter.interpolator;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -31,7 +32,7 @@ public class RealInterpolator extends Interpolator
public float filter( float[] samples, int offset, float mu ) public float filter( float[] samples, int offset, float mu )
{ {
/* Ensure we have enough samples in the array */ /* Ensure we have enough samples in the array */
assert( samples.length >= offset + 7 ); Validate.isTrue(samples.length >= offset + 7);
/* Identify the filter bank that corresponds to mu */ /* Identify the filter bank that corresponds to mu */
int index = (int)( NSTEPS * mu ); int index = (int)( NSTEPS * mu );

View File

@@ -18,6 +18,7 @@
******************************************************************************/ ******************************************************************************/
package dsp.filter.polyphase; package dsp.filter.polyphase;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -53,7 +54,7 @@ public class PolyphaseFIRInterpolatingFilter
public PolyphaseFIRInterpolatingFilter( double[] coefficients, int interpolation ) public PolyphaseFIRInterpolatingFilter( double[] coefficients, int interpolation )
{ {
/* Ensure coefficients are an integral multiple of the interpolation factor */ /* Ensure coefficients are an integral multiple of the interpolation factor */
assert( coefficients.length % interpolation == 0 ); Validate.isTrue(coefficients.length % interpolation == 0);
mTaps = coefficients; mTaps = coefficients;

View File

@@ -17,6 +17,7 @@
******************************************************************************/ ******************************************************************************/
package dsp.gain; package dsp.gain;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -49,7 +50,7 @@ public class DirectGainControl implements GainController, RealSampleListener
*/ */
public DirectGainControl( float gain, float minimum, float maximum, float increment ) public DirectGainControl( float gain, float minimum, float maximum, float increment )
{ {
assert( minimum > 0 ); Validate.isTrue(minimum > 0);
mDefaultGain = gain; mDefaultGain = gain;
mGain = gain; mGain = gain;

View File

@@ -1,21 +1,38 @@
/*******************************************************************************
* 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 instrument; package instrument;
import controller.channel.Channel.ChannelType;
import instrument.tap.Tap; import instrument.tap.Tap;
import instrument.tap.TapGroup; import instrument.tap.TapGroup;
import java.util.ArrayList;
import java.util.List;
import module.Module; import module.Module;
import module.ProcessingChain; import module.ProcessingChain;
import source.Source; import source.Source;
import controller.channel.Channel.ChannelType;
import java.util.ArrayList;
import java.util.List;
public class InstrumentableProcessingChain extends ProcessingChain implements Instrumentable public class InstrumentableProcessingChain extends ProcessingChain implements Instrumentable
{ {
public InstrumentableProcessingChain() public InstrumentableProcessingChain()
{ {
super( "instrumented", ChannelType.STANDARD ); super(ChannelType.STANDARD);
} }
public void setSource(Source source) throws IllegalStateException public void setSource(Source source) throws IllegalStateException

View File

@@ -108,7 +108,6 @@ public class ProcessingChain implements IChannelEventListener
private Broadcaster<RealBuffer> mUnFilteredRealBufferBroadcaster = new Broadcaster<>(); private Broadcaster<RealBuffer> mUnFilteredRealBufferBroadcaster = new Broadcaster<>();
private Broadcaster<SquelchState> mSquelchStateBroadcaster = new Broadcaster<>(); private Broadcaster<SquelchState> mSquelchStateBroadcaster = new Broadcaster<>();
private String mName;
private AtomicBoolean mRunning = new AtomicBoolean(); private AtomicBoolean mRunning = new AtomicBoolean();
protected Source mSource; protected Source mSource;
@@ -120,13 +119,10 @@ public class ProcessingChain implements IChannelEventListener
/** /**
* Creates a processing chain for managing a set of modules * Creates a processing chain for managing a set of modules
* *
* @param name for thread pool naming each thread
* @param channelType * @param channelType
*/ */
public ProcessingChain(String name, ChannelType channelType) public ProcessingChain(ChannelType channelType)
{ {
mName = name;
mChannelState = new ChannelState(channelType); mChannelState = new ChannelState(channelType);
addModule(mChannelState); addModule(mChannelState);
@@ -211,6 +207,8 @@ public class ProcessingChain implements IChannelEventListener
} }
mSource = source; mSource = source;
addModule(mSource);
} }
/** /**
@@ -557,25 +555,6 @@ public class ProcessingChain implements IChannelEventListener
+ "sample type - cannot start processing chain"); + "sample type - cannot start processing chain");
} }
/* If this is a tuner source, broadcast the frequency to all
* of the decoder state's and start the samples flowing */
if(mSource instanceof TunerChannelSource)
{
TunerChannelSource tcs = (TunerChannelSource) mSource;
try
{
long frequency = tcs.getFrequency();
mDecoderStateEventBroadcaster.broadcast(
new DecoderStateEvent(this, Event.SOURCE_FREQUENCY, State.IDLE, frequency));
}
catch(SourceException e)
{
mLog.error("Error getting frequency from tuner channel source", e);
}
}
/* Start each of the modules */ /* Start each of the modules */
for(Module module : mModules) for(Module module : mModules)
{ {
@@ -588,8 +567,6 @@ public class ProcessingChain implements IChannelEventListener
mLog.error("Error starting module", e); mLog.error("Error starting module", e);
} }
} }
mSource.start(ThreadPool.SCHEDULED);
} }
else else
{ {
@@ -606,9 +583,16 @@ public class ProcessingChain implements IChannelEventListener
{ {
if(mRunning.compareAndSet(true, false)) if(mRunning.compareAndSet(true, false))
{ {
/* Stop each of the modules */
for(Module module : mModules)
{
module.stop();
}
if(mSource != null) if(mSource != null)
{ {
mSource.stop(); removeModule(mSource);
mSource.setOverflowListener(null); mSource.setOverflowListener(null);
switch(mSource.getSampleType()) switch(mSource.getSampleType())
@@ -629,11 +613,6 @@ public class ProcessingChain implements IChannelEventListener
mSource = null; mSource = null;
} }
/* Stop each of the modules */
for(Module module : mModules)
{
module.stop();
}
} }
} }
@@ -760,6 +739,24 @@ public class ProcessingChain implements IChannelEventListener
mMessageBroadcaster.removeListener(listener); mMessageBroadcaster.removeListener(listener);
} }
/**
* Adds the listener to receive frequency change events from the processing chain
* @param listener to receive events
*/
public void addFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
{
mFrequencyChangeEventBroadcaster.addListener(listener);
}
/**
* Removes the listener from receiving frequency change events
* @param listener to remove
*/
public void removeFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
{
mFrequencyChangeEventBroadcaster.removeListener(listener);
}
/** /**
* Adds the listener to receive call events from all modules. * Adds the listener to receive call events from all modules.
*/ */

View File

@@ -222,7 +222,7 @@ public class DecoderFactory
if(channelType == ChannelType.STANDARD) if(channelType == ChannelType.STANDARD)
{ {
modules.add(new TrafficChannelManager(channelModel, channelProcessingManager, decodeConfig, modules.add(new TrafficChannelManager(channelModel, decodeConfig,
channel.getRecordConfiguration(), channel.getSystem(), channel.getSite(), channel.getRecordConfiguration(), channel.getSystem(), channel.getSite(),
(aliasList != null ? aliasList.getName() : null), mptConfig.getTrafficChannelPoolSize())); (aliasList != null ? aliasList.getName() : null), mptConfig.getTrafficChannelPoolSize()));
} }
@@ -263,7 +263,7 @@ public class DecoderFactory
if(channelType == ChannelType.STANDARD) if(channelType == ChannelType.STANDARD)
{ {
modules.add(new TrafficChannelManager(channelModel, channelProcessingManager, decodeConfig, modules.add(new TrafficChannelManager(channelModel, decodeConfig,
channel.getRecordConfiguration(), channel.getSystem(), channel.getSite(), channel.getRecordConfiguration(), channel.getSystem(), channel.getSite(),
(aliasList != null ? aliasList.getName() : null), p25Config.getTrafficChannelPoolSize())); (aliasList != null ? aliasList.getName() : null), p25Config.getTrafficChannelPoolSize()));
} }

View File

@@ -54,7 +54,7 @@ public class LJ1200DecoderState extends DecoderState
super(aliasList); super(aliasList);
mAddressAttribute = new AliasedStringAttributeMonitor(Attribute.SECONDARY_ADDRESS_TO, mAddressAttribute = new AliasedStringAttributeMonitor(Attribute.SECONDARY_ADDRESS_TO,
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.LOJACK); getAttributeChangeRequestListener(), getAliasList(), AliasIDType.SITE);
} }
@Override @Override

View File

@@ -9,19 +9,19 @@ import instrument.tap.stream.FloatTap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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.tuner.frequency.FrequencyChangeEvent; import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.FrequencyChangeEvent.Event; import source.tuner.frequency.FrequencyChangeEvent.Event;
import source.tuner.frequency.IFrequencyChangeListener; import source.tuner.frequency.IFrequencyChangeListener;
import dsp.gain.DirectGainControl; import dsp.gain.DirectGainControl;
public class C4FMSymbolFilter implements Listener<RealBuffer>, public class C4FMSymbolFilter implements Listener<RealBuffer>, IFrequencyChangeListener, RealSampleProvider, Instrumentable
IFrequencyChangeListener,
RealSampleProvider,
Instrumentable
{ {
private static final float TAPS[][] = private static final float TAPS[][] =
{ {
@@ -198,8 +198,7 @@ public class C4FMSymbolFilter implements Listener<RealBuffer>,
private RealSampleListener mListener; private RealSampleListener mListener;
private DirectGainControl mGainController = private DirectGainControl mGainController = new DirectGainControl( 15.0f, 0.1f, 35.0f, 0.3f );
new DirectGainControl( 15.0f, 0.1f, 35.0f, 0.3f );
private int mFrequencyAdjustmentRequested = 0; private int mFrequencyAdjustmentRequested = 0;
private int mFrequencyCorrection = 0; private int mFrequencyCorrection = 0;
@@ -258,8 +257,7 @@ public class C4FMSymbolFilter implements Listener<RealBuffer>,
correction = -mFrequencyCorrectionMaximum; correction = -mFrequencyCorrectionMaximum;
} }
broadcast( new FrequencyChangeEvent( broadcast( new FrequencyChangeEvent(Event.REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE, correction ) );
Event.REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE, correction ) );
mFrequencyAdjustmentRequested = 0; mFrequencyAdjustmentRequested = 0;
} }
@@ -452,6 +450,10 @@ public class C4FMSymbolFilter implements Listener<RealBuffer>,
} }
} }
/**
* Broadcasts a frequency change event to the registered listener
* @param event
*/
public void broadcast( FrequencyChangeEvent event ) public void broadcast( FrequencyChangeEvent event )
{ {
if( mFrequencyChangeListener != null ) if( mFrequencyChangeListener != null )
@@ -460,6 +462,10 @@ public class C4FMSymbolFilter implements Listener<RealBuffer>,
} }
} }
/**
* Sets the listener for frequency change events.
* @param listener
*/
public void setFrequencyChangeListener( Listener<FrequencyChangeEvent> listener ) public void setFrequencyChangeListener( Listener<FrequencyChangeEvent> listener )
{ {
mFrequencyChangeListener = listener; mFrequencyChangeListener = listener;

View File

@@ -4,8 +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.tuner.frequency.IFrequencyChangeProvider;
public abstract class P25Decoder extends Decoder implements Instrumentable public abstract class P25Decoder extends Decoder implements IFrequencyChangeListener, IFrequencyChangeProvider, Instrumentable
{ {
private P25MessageProcessor mMessageProcessor; private P25MessageProcessor mMessageProcessor;

View File

@@ -315,6 +315,8 @@ public class P25DecoderState extends DecoderState
*/ */
public void registerCallEvent(P25CallEvent event) public void registerCallEvent(P25CallEvent event)
{ {
String channel = event.getChannel();
if(mChannelCallMap.containsKey(event.getChannel())) if(mChannelCallMap.containsKey(event.getChannel()))
{ {
P25CallEvent previousEvent = mChannelCallMap.remove(event.getChannel()); P25CallEvent previousEvent = mChannelCallMap.remove(event.getChannel());
@@ -1557,6 +1559,7 @@ public class P25DecoderState extends DecoderState
break; break;
case IDENTIFIER_UPDATE_NON_VUHF: case IDENTIFIER_UPDATE_NON_VUHF:
case IDENTIFIER_UPDATE_VHF_UHF_BANDS: case IDENTIFIER_UPDATE_VHF_UHF_BANDS:
case IDENTIFIER_UPDATE_TDMA:
IdentifierUpdate iu = (IdentifierUpdate)tsbk; IdentifierUpdate iu = (IdentifierUpdate)tsbk;
if(!mBands.containsKey(iu.getIdentifier())) if(!mBands.containsKey(iu.getIdentifier()))
@@ -2735,6 +2738,7 @@ public class P25DecoderState extends DecoderState
else else
{ {
StringBuilder details = new StringBuilder(); StringBuilder details = new StringBuilder();
details.append(pgvcg.isTDMAChannel() ? "TDMA " : "");
details.append(pgvcg.isEmergency() ? "EMERGENCY " : ""); details.append(pgvcg.isEmergency() ? "EMERGENCY " : "");
details.append("PRI:").append(pgvcg.getPriority()); details.append("PRI:").append(pgvcg.getPriority());
details.append(pgvcg.isEncryptedChannel() ? " ENCRYPTED" : ""); details.append(pgvcg.isEncryptedChannel() ? " ENCRYPTED" : "");
@@ -2742,7 +2746,7 @@ public class P25DecoderState extends DecoderState
P25CallEvent event = new P25CallEvent.Builder(CallEventType.PATCH_GROUP_CALL) P25CallEvent event = new P25CallEvent.Builder(CallEventType.PATCH_GROUP_CALL)
.aliasList(getAliasList()) .aliasList(getAliasList())
.channel(channel + (pgvcg.isTDMAChannel() ? " TDMA" : "")) .channel(channel)
.details(details.toString()) .details(details.toString())
.frequency(pgvcg.getDownlinkFrequency()) .frequency(pgvcg.getDownlinkFrequency())
.from(from) .from(from)
@@ -2775,8 +2779,9 @@ public class P25DecoderState extends DecoderState
{ {
P25CallEvent event = new P25CallEvent.Builder(CallEventType.PATCH_GROUP_CALL) P25CallEvent event = new P25CallEvent.Builder(CallEventType.PATCH_GROUP_CALL)
.aliasList(getAliasList()) .aliasList(getAliasList())
.channel(channel + (gvcgu.isTDMAChannel1() ? " TDMA" : "")) .channel(channel)
.details((gvcgu.isEncrypted() ? "ENCRYPTED " : "")) .details((gvcgu.isTDMAChannel1() ? "TDMA " : "") +
(gvcgu.isEncrypted() ? "ENCRYPTED " : ""))
.frequency(gvcgu.getDownlinkFrequency1()) .frequency(gvcgu.getDownlinkFrequency1())
.to(to) .to(to)
.build(); .build();
@@ -2801,8 +2806,9 @@ public class P25DecoderState extends DecoderState
{ {
P25CallEvent event = new P25CallEvent.Builder(CallEventType.PATCH_GROUP_CALL) P25CallEvent event = new P25CallEvent.Builder(CallEventType.PATCH_GROUP_CALL)
.aliasList(getAliasList()) .aliasList(getAliasList())
.channel(channel2 + (gvcgu.isTDMAChannel2() ? " TDMA" : "")) .channel(channel2)
.details((gvcgu.isEncrypted() ? "ENCRYPTED " : "")) .details((gvcgu.isTDMAChannel2() ? "TDMA " : "") +
(gvcgu.isEncrypted() ? "ENCRYPTED " : ""))
.frequency(gvcgu.getDownlinkFrequency2()) .frequency(gvcgu.getDownlinkFrequency2())
.to(to2) .to(to2)
.build(); .build();
@@ -2866,6 +2872,7 @@ public class P25DecoderState extends DecoderState
else else
{ {
StringBuilder details = new StringBuilder(); StringBuilder details = new StringBuilder();
details.append(gdcg.isTDMAChannel() ? "TDMA " : "");
details.append(gdcg.isEmergency() ? "EMERGENCY " : ""); details.append(gdcg.isEmergency() ? "EMERGENCY " : "");
details.append("PRI:").append(gdcg.getPriority()).append(" "); details.append("PRI:").append(gdcg.getPriority()).append(" ");
details.append(gdcg.isEncryptedChannel() ? "ENCRYPTED " : ""); details.append(gdcg.isEncryptedChannel() ? "ENCRYPTED " : "");
@@ -2873,7 +2880,7 @@ public class P25DecoderState extends DecoderState
P25CallEvent event = new P25CallEvent.Builder(CallEventType.DATA_CALL) P25CallEvent event = new P25CallEvent.Builder(CallEventType.DATA_CALL)
.aliasList(getAliasList()) .aliasList(getAliasList())
.channel(channel + (gdcg.isTDMAChannel() ? " TDMA" : "")) .channel(channel)
.details(details.toString()) .details(details.toString())
.frequency(gdcg.getDownlinkFrequency()) .frequency(gdcg.getDownlinkFrequency())
.from(from) .from(from)
@@ -2904,6 +2911,7 @@ public class P25DecoderState extends DecoderState
else else
{ {
StringBuilder details = new StringBuilder(); StringBuilder details = new StringBuilder();
details.append(gvcg.isTDMAChannel() ? "TDMA " : "");
details.append(gvcg.isEmergency() ? "EMERGENCY " : ""); details.append(gvcg.isEmergency() ? "EMERGENCY " : "");
details.append("PRI:").append(gvcg.getPriority()).append(" "); details.append("PRI:").append(gvcg.getPriority()).append(" ");
details.append(gvcg.isEncryptedChannel() ? "ENCRYPTED " : ""); details.append(gvcg.isEncryptedChannel() ? "ENCRYPTED " : "");
@@ -2911,7 +2919,7 @@ public class P25DecoderState extends DecoderState
P25CallEvent event = new P25CallEvent.Builder(CallEventType.GROUP_CALL) P25CallEvent event = new P25CallEvent.Builder(CallEventType.GROUP_CALL)
.aliasList(getAliasList()) .aliasList(getAliasList())
.channel(channel + (gvcg.isTDMAChannel() ? " TDMA" : "")) .channel(channel)
.details(details.toString()) .details(details.toString())
.frequency(gvcg.getDownlinkFrequency()) .frequency(gvcg.getDownlinkFrequency())
.from(from) .from(from)
@@ -2928,8 +2936,7 @@ public class P25DecoderState extends DecoderState
} }
break; break;
case GROUP_VOICE_CHANNEL_GRANT_UPDATE: case GROUP_VOICE_CHANNEL_GRANT_UPDATE:
GroupVoiceChannelGrantUpdate gvcgu = GroupVoiceChannelGrantUpdate gvcgu = (GroupVoiceChannelGrantUpdate)message;
(GroupVoiceChannelGrantUpdate)message;
channel = gvcgu.getChannel1(); channel = gvcgu.getChannel1();
from = null; from = null;
@@ -2942,6 +2949,7 @@ public class P25DecoderState extends DecoderState
else else
{ {
StringBuilder details = new StringBuilder(); StringBuilder details = new StringBuilder();
details.append(gvcgu.isTDMAChannel() ? "TDMA " : "");
details.append(gvcgu.isEmergency() ? "EMERGENCY " : ""); details.append(gvcgu.isEmergency() ? "EMERGENCY " : "");
details.append("PRI:").append(gvcgu.getPriority()).append(" "); details.append("PRI:").append(gvcgu.getPriority()).append(" ");
details.append(gvcgu.isEncryptedChannel() ? "ENCRYPTED " : ""); details.append(gvcgu.isEncryptedChannel() ? "ENCRYPTED " : "");
@@ -2949,7 +2957,7 @@ public class P25DecoderState extends DecoderState
P25CallEvent event = new P25CallEvent.Builder(CallEventType.GROUP_CALL) P25CallEvent event = new P25CallEvent.Builder(CallEventType.GROUP_CALL)
.aliasList(getAliasList()) .aliasList(getAliasList())
.channel(gvcgu.getChannel1() + (gvcgu.isTDMAChannel1() ? " TDMA" : "")) .channel(gvcgu.getChannel1())
.details(details.toString()) .details(details.toString())
.frequency(gvcgu.getDownlinkFrequency1()) .frequency(gvcgu.getDownlinkFrequency1())
.from(from) .from(from)
@@ -2977,6 +2985,7 @@ public class P25DecoderState extends DecoderState
else else
{ {
StringBuilder details = new StringBuilder(); StringBuilder details = new StringBuilder();
details.append(gvcgu.isTDMAChannel() ? "TDMA " : "");
details.append(gvcgu.isEmergency() ? "EMERGENCY " : ""); details.append(gvcgu.isEmergency() ? "EMERGENCY " : "");
details.append("PRI:").append(gvcgu.getPriority()).append(" "); details.append("PRI:").append(gvcgu.getPriority()).append(" ");
details.append(gvcgu.isEncryptedChannel() ? "ENCRYPTED " : ""); details.append(gvcgu.isEncryptedChannel() ? "ENCRYPTED " : "");
@@ -2984,7 +2993,7 @@ public class P25DecoderState extends DecoderState
P25CallEvent event2 = new P25CallEvent.Builder(CallEventType.GROUP_CALL) P25CallEvent event2 = new P25CallEvent.Builder(CallEventType.GROUP_CALL)
.aliasList(getAliasList()) .aliasList(getAliasList())
.channel(gvcgu.getChannel2() + (gvcgu.isTDMAChannel2() ? " TDMA" : "")) .channel(gvcgu.getChannel2())
.details(details.toString()) .details(details.toString())
.frequency(gvcgu.getDownlinkFrequency2()) .frequency(gvcgu.getDownlinkFrequency2())
.to(gvcgu.getGroupAddress2()) .to(gvcgu.getGroupAddress2())
@@ -3016,6 +3025,7 @@ public class P25DecoderState extends DecoderState
else else
{ {
StringBuilder details = new StringBuilder(); StringBuilder details = new StringBuilder();
details.append(gvcgue.isTDMAChannel() ? "TDMA " : "");
details.append(gvcgue.isEmergency() ? "EMERGENCY " : ""); details.append(gvcgue.isEmergency() ? "EMERGENCY " : "");
details.append("PRI:").append(gvcgue.getPriority()).append(" "); details.append("PRI:").append(gvcgue.getPriority()).append(" ");
details.append(gvcgue.isEncryptedChannel() ? "ENCRYPTED " : ""); details.append(gvcgue.isEncryptedChannel() ? "ENCRYPTED " : "");
@@ -3023,7 +3033,7 @@ public class P25DecoderState extends DecoderState
P25CallEvent event = new P25CallEvent.Builder(CallEventType.GROUP_CALL) P25CallEvent event = new P25CallEvent.Builder(CallEventType.GROUP_CALL)
.aliasList(getAliasList()) .aliasList(getAliasList())
.channel(channel + (gvcgue.isTDMAChannel() ? " TDMA" : "")) .channel(channel)
.details(details.toString()) .details(details.toString())
.frequency(gvcgue.getDownlinkFrequency()) .frequency(gvcgue.getDownlinkFrequency())
.from(from) .from(from)
@@ -3053,6 +3063,7 @@ public class P25DecoderState extends DecoderState
else else
{ {
StringBuilder details = new StringBuilder(); StringBuilder details = new StringBuilder();
details.append(idcg.isTDMAChannel() ? "TDMA " : "");
details.append(idcg.isEmergency() ? "EMERGENCY " : ""); details.append(idcg.isEmergency() ? "EMERGENCY " : "");
details.append("PRI:").append(idcg.getPriority()).append(" "); details.append("PRI:").append(idcg.getPriority()).append(" ");
details.append(idcg.isEncryptedChannel() ? "ENCRYPTED " : ""); details.append(idcg.isEncryptedChannel() ? "ENCRYPTED " : "");
@@ -3060,7 +3071,7 @@ public class P25DecoderState extends DecoderState
P25CallEvent event = new P25CallEvent.Builder(CallEventType.DATA_CALL) P25CallEvent event = new P25CallEvent.Builder(CallEventType.DATA_CALL)
.aliasList(getAliasList()) .aliasList(getAliasList())
.channel(channel + (idcg.isTDMAChannel() ? " TDMA" : "")) .channel(channel)
.details(details.toString()) .details(details.toString())
.frequency(idcg.getDownlinkFrequency()) .frequency(idcg.getDownlinkFrequency())
.from(from) .from(from)
@@ -3090,13 +3101,14 @@ public class P25DecoderState extends DecoderState
else else
{ {
StringBuilder details = new StringBuilder(); StringBuilder details = new StringBuilder();
details.append(sdcg.isTDMAChannel() ? "TDMA " : "");
details.append(sdcg.isEmergency() ? "EMERGENCY " : ""); details.append(sdcg.isEmergency() ? "EMERGENCY " : "");
details.append(sdcg.isEncryptedChannel() ? "ENCRYPTED " : ""); details.append(sdcg.isEncryptedChannel() ? "ENCRYPTED " : "");
details.append(sdcg.getSessionMode().name()); details.append(sdcg.getSessionMode().name());
P25CallEvent event = new P25CallEvent.Builder(CallEventType.DATA_CALL) P25CallEvent event = new P25CallEvent.Builder(CallEventType.DATA_CALL)
.aliasList(getAliasList()) .aliasList(getAliasList())
.channel(channel + (sdcg.isTDMAChannel() ? " TDMA" : "")) .channel(channel)
.details(details.toString()) .details(details.toString())
.frequency(sdcg.getDownlinkFrequency()) .frequency(sdcg.getDownlinkFrequency())
.from(from) .from(from)
@@ -3128,6 +3140,7 @@ public class P25DecoderState extends DecoderState
else else
{ {
StringBuilder details = new StringBuilder(); StringBuilder details = new StringBuilder();
details.append(tivcg.isTDMAChannel() ? "TDMA " : "");
details.append(tivcg.isEmergency() ? "EMERGENCY " : ""); details.append(tivcg.isEmergency() ? "EMERGENCY " : "");
details.append("PRI:").append(tivcg.getPriority()).append(" "); details.append("PRI:").append(tivcg.getPriority()).append(" ");
details.append(tivcg.isEncryptedChannel() ? "ENCRYPTED " : ""); details.append(tivcg.isEncryptedChannel() ? "ENCRYPTED " : "");
@@ -3137,7 +3150,7 @@ public class P25DecoderState extends DecoderState
P25CallEvent event = new P25CallEvent.Builder( P25CallEvent event = new P25CallEvent.Builder(
CallEventType.TELEPHONE_INTERCONNECT) CallEventType.TELEPHONE_INTERCONNECT)
.aliasList(getAliasList()) .aliasList(getAliasList())
.channel(channel + (tivcg.isTDMAChannel() ? " TDMA" : "")) .channel(channel)
.details(details.toString()) .details(details.toString())
.frequency(tivcg.getDownlinkFrequency()) .frequency(tivcg.getDownlinkFrequency())
.from(from) .from(from)
@@ -3170,6 +3183,7 @@ public class P25DecoderState extends DecoderState
else else
{ {
StringBuilder details = new StringBuilder(); StringBuilder details = new StringBuilder();
details.append(tivcgu.isTDMAChannel() ? "TDMA " : "");
details.append(tivcgu.isEmergency() ? "EMERGENCY " : ""); details.append(tivcgu.isEmergency() ? "EMERGENCY " : "");
details.append("PRI:").append(tivcgu.getPriority()).append(" "); details.append("PRI:").append(tivcgu.getPriority()).append(" ");
details.append(tivcgu.isEncryptedChannel() ? "ENCRYPTED " : ""); details.append(tivcgu.isEncryptedChannel() ? "ENCRYPTED " : "");
@@ -3179,7 +3193,7 @@ public class P25DecoderState extends DecoderState
P25CallEvent event = new P25CallEvent.Builder( P25CallEvent event = new P25CallEvent.Builder(
CallEventType.TELEPHONE_INTERCONNECT) CallEventType.TELEPHONE_INTERCONNECT)
.aliasList(getAliasList()) .aliasList(getAliasList())
.channel(channel + (tivcgu.isTDMAChannel() ? " TDMA" : "")) .channel(channel)
.details(details.toString()) .details(details.toString())
.frequency(tivcgu.getDownlinkFrequency()) .frequency(tivcgu.getDownlinkFrequency())
.from(from) .from(from)
@@ -3209,6 +3223,7 @@ public class P25DecoderState extends DecoderState
else else
{ {
StringBuilder details = new StringBuilder(); StringBuilder details = new StringBuilder();
details.append(uuvcg.isTDMAChannel() ? "TDMA " : "");
details.append(uuvcg.isEmergency() ? "EMERGENCY " : ""); details.append(uuvcg.isEmergency() ? "EMERGENCY " : "");
details.append("PRI:").append(uuvcg.getPriority()).append(" "); details.append("PRI:").append(uuvcg.getPriority()).append(" ");
details.append(uuvcg.isEncryptedChannel() ? " ENCRYPTED " : ""); details.append(uuvcg.isEncryptedChannel() ? " ENCRYPTED " : "");
@@ -3217,7 +3232,7 @@ public class P25DecoderState extends DecoderState
P25CallEvent event = new P25CallEvent.Builder( P25CallEvent event = new P25CallEvent.Builder(
CallEventType.UNIT_TO_UNIT_CALL) CallEventType.UNIT_TO_UNIT_CALL)
.aliasList(getAliasList()) .aliasList(getAliasList())
.channel(channel + (uuvcg.isTDMAChannel() ? " TDMA" : "")) .channel(channel)
.details(details.toString()) .details(details.toString())
.frequency(uuvcg.getDownlinkFrequency()) .frequency(uuvcg.getDownlinkFrequency())
.from(from) .from(from)
@@ -3247,6 +3262,7 @@ public class P25DecoderState extends DecoderState
else else
{ {
StringBuilder details = new StringBuilder(); StringBuilder details = new StringBuilder();
details.append(uuvcgu.isTDMAChannel() ? "TDMA " : "");
details.append(uuvcgu.isEmergency() ? "EMERGENCY " : ""); details.append(uuvcgu.isEmergency() ? "EMERGENCY " : "");
details.append("PRI:").append(uuvcgu.getPriority()).append(" "); details.append("PRI:").append(uuvcgu.getPriority()).append(" ");
details.append(uuvcgu.isEncryptedChannel() ? "ENCRYPTED " : ""); details.append(uuvcgu.isEncryptedChannel() ? "ENCRYPTED " : "");
@@ -3255,7 +3271,7 @@ public class P25DecoderState extends DecoderState
P25CallEvent event = new P25CallEvent.Builder( P25CallEvent event = new P25CallEvent.Builder(
CallEventType.UNIT_TO_UNIT_CALL) CallEventType.UNIT_TO_UNIT_CALL)
.aliasList(getAliasList()) .aliasList(getAliasList())
.channel(channel + (uuvcgu.isTDMAChannel() ? " TDMA" : "")) .channel(channel)
.details(details.toString()) .details(details.toString())
.frequency(uuvcgu.getDownlinkFrequency()) .frequency(uuvcgu.getDownlinkFrequency())
.from(from) .from(from)

View File

@@ -689,8 +689,7 @@ public class P25MessageFramer implements Listener<Dibit>
private LSMDemodulator mDemodulator; private LSMDemodulator mDemodulator;
private double mCorrection; private double mCorrection;
public CostasPhaseErrorDetector( FrameSync frameSync, public CostasPhaseErrorDetector( FrameSync frameSync, LSMDemodulator demodulator, double correction )
LSMDemodulator demodulator, double correction )
{ {
super( frameSync.getSync() ); super( frameSync.getSync() );

View File

@@ -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,6 +14,7 @@
* *
* 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 module.decode.p25; package module.decode.p25;
@@ -41,8 +42,7 @@ import dsp.filter.FilterFactory;
import dsp.filter.Window.WindowType; import dsp.filter.Window.WindowType;
import dsp.filter.fir.real.RealFIRFilter_RB_RB; import dsp.filter.fir.real.RealFIRFilter_RB_RB;
public class P25_C4FMDecoder extends P25Decoder public class P25_C4FMDecoder extends P25Decoder implements IFilteredRealBufferListener
implements IFrequencyChangeListener, IFrequencyChangeProvider,IFilteredRealBufferListener
{ {
private final static Logger mLog = LoggerFactory.getLogger( P25_C4FMDecoder.class ); private final static Logger mLog = LoggerFactory.getLogger( P25_C4FMDecoder.class );

View File

@@ -42,6 +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;
public class P25_LSMDecoder extends P25Decoder implements IComplexBufferListener public class P25_LSMDecoder extends P25Decoder implements IComplexBufferListener
{ {
@@ -56,8 +57,7 @@ public class P25_LSMDecoder extends P25Decoder implements IComplexBufferListener
private List<TapGroup> mAvailableTaps; private List<TapGroup> mAvailableTaps;
private ComplexFIRFilter_CB_CB mBasebandFilter; private ComplexFIRFilter_CB_CB mBasebandFilter;
private ComplexBufferToStreamConverter mStreamConverter = private ComplexBufferToStreamConverter mStreamConverter = new ComplexBufferToStreamConverter();
new ComplexBufferToStreamConverter();
private ComplexFeedForwardGainControl mAGC = private ComplexFeedForwardGainControl mAGC =
new ComplexFeedForwardGainControl( 32 ); new ComplexFeedForwardGainControl( 32 );
private LSMDemodulator mLSMDemodulator = new LSMDemodulator(); private LSMDemodulator mLSMDemodulator = new LSMDemodulator();
@@ -108,6 +108,29 @@ public class P25_LSMDecoder extends P25Decoder implements IComplexBufferListener
mMessageFramer = null; mMessageFramer = null;
} }
@Override
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
{
}
@Override
public void removeFrequencyChangeListener()
{
}
@Override
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
{
return new Listener<FrequencyChangeEvent>()
{
@Override
public void receive(FrequencyChangeEvent frequencyChangeEvent)
{
//Ignored
}
};
}
@Override @Override
public Listener<ComplexBuffer> getComplexBufferListener() public Listener<ComplexBuffer> getComplexBufferListener()
{ {

View File

@@ -41,7 +41,7 @@ public class IdentifierUpdateTDMA extends IdentifierUpdate
sb.append( " ID:" + getIdentifier() ); sb.append( " ID:" + getIdentifier() );
sb.append( " BASE:" + getBaseFrequency() ); sb.append( " BASE:" + getBaseFrequency() );
sb.append( " BW:" + getBandwidth() ); sb.append( " BANDWIDTH:" + getBandwidth() );
sb.append( " SPACING:" + getChannelSpacing() ); sb.append( " SPACING:" + getChannelSpacing() );
sb.append( " OFFSET:" + getTransmitOffset() ); sb.append( " OFFSET:" + getTransmitOffset() );
sb.append( " TYPE:" + getChannelType().toString() ); sb.append( " TYPE:" + getChannelType().toString() );
@@ -137,7 +137,7 @@ public class IdentifierUpdateTDMA extends IdentifierUpdate
sb.append( mAccessType.name() ); sb.append( mAccessType.name() );
sb.append( " BANDWIDTH:" + mBandwidth ); sb.append( " BANDWIDTH:" + mBandwidth );
sb.append( " SLOT/CARRIER:" + mSlotsPerCarrier ); sb.append( " TIMESLOTS PER CARRIER:" + mSlotsPerCarrier );
sb.append( " VOCODER:" + mVocoder.name() ); sb.append( " VOCODER:" + mVocoder.name() );
return sb.toString(); return sb.toString();

View File

@@ -89,6 +89,7 @@ public class PlaylistManager implements ChannelEventListener
@Override @Override
public void receive(AliasEvent t) public void receive(AliasEvent t)
{ {
//Save the playlist for all alias events
schedulePlaylistSave(); schedulePlaylistSave();
} }
}); });
@@ -98,6 +99,7 @@ public class PlaylistManager implements ChannelEventListener
@Override @Override
public void receive(ChannelMapEvent t) public void receive(ChannelMapEvent t)
{ {
//Save the playlist for all channel map events
schedulePlaylistSave(); schedulePlaylistSave();
} }
}); });
@@ -107,7 +109,23 @@ public class PlaylistManager implements ChannelEventListener
@Override @Override
public void receive(BroadcastEvent broadcastEvent) public void receive(BroadcastEvent broadcastEvent)
{ {
switch(broadcastEvent.getEvent())
{
case CONFIGURATION_ADD:
case CONFIGURATION_CHANGE:
case CONFIGURATION_DELETE:
schedulePlaylistSave(); schedulePlaylistSave();
break;
case BROADCASTER_ADD:
case BROADCASTER_QUEUE_CHANGE:
case BROADCASTER_STATE_CHANGE:
case BROADCASTER_STREAMED_COUNT_CHANGE:
case BROADCASTER_AGED_OFF_COUNT_CHANGE:
case BROADCASTER_DELETE:
default:
//Do nothing
break;
}
} }
}); });
} }

View File

@@ -25,39 +25,97 @@ import properties.SystemProperties;
import record.wave.ComplexBufferWaveRecorder; import record.wave.ComplexBufferWaveRecorder;
import record.wave.RealBufferWaveRecorder; import record.wave.RealBufferWaveRecorder;
import sample.Listener; import sample.Listener;
import sample.OverflowableTransferQueue;
import sample.real.IOverflowListener;
import util.ThreadPool; import util.ThreadPool;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
public class RecorderManager implements Listener<AudioPacket> public class RecorderManager implements Listener<AudioPacket>
{ {
private static final Logger mLog = LoggerFactory.getLogger(RecorderManager.class); private static final Logger mLog = LoggerFactory.getLogger(RecorderManager.class);
public static final int AUDIO_SAMPLE_RATE = 8000; public static final int AUDIO_SAMPLE_RATE = 8000;
public static final long IDLE_RECORDER_REMOVAL_THRESHOLD = 6000; //6 seconds
private Map<String,RealBufferWaveRecorder> mRecorders = new HashMap<>(); private Map<String,RealBufferWaveRecorder> mRecorders = new HashMap<>();
private OverflowableTransferQueue<AudioPacket> mAudioPacketQueue = new OverflowableTransferQueue<>(1000, 100);
private ScheduledFuture<?> mBufferProcessorFuture;
private boolean mCanStartNewRecorders = true; private boolean mCanStartNewRecorders = true;
/** /**
* Manages all audio recording for all processing channels. Reconstructs audio streams and distributes channel * Audio recording manager. Monitors stream of audio packets produced by decoding channels and automatically starts
* audio to each of the recorders, starting and stopping the recorders as needed. * audio recorders when the channel's metadata designates a call as recordable. Routes call audio to each recorder
* based on audio packet metadata. Recorders are shutdown when the channel sends an end-call audio packet
* indicating that the call is complete. A separate recording monitor periodically checks for idled recorders to
* be stopped for cases when the channel fails to send an end-call audio packet.
*/ */
public RecorderManager() public RecorderManager()
{ {
mAudioPacketQueue.setOverflowListener(new IOverflowListener()
{
@Override
public void sourceOverflow(boolean overflow)
{
if(overflow)
{
mLog.warn("overflow - audio packets will be dropped until recording catches up");
}
else
{
mLog.info("audio recorder packet processing has returned to normal");
}
}
});
mBufferProcessorFuture = ThreadPool.SCHEDULED.scheduleAtFixedRate(new BufferProcessor(), 0,
1, TimeUnit.SECONDS);
} }
/**
* Prepares this class for shutdown
*/
public void dispose() public void dispose()
{ {
if(mBufferProcessorFuture != null)
{
mBufferProcessorFuture.cancel(true);
}
} }
/**
* Primary ingest point for audio packets from all decoding channels
* @param audioPacket to process
*/
@Override @Override
public void receive(AudioPacket audioPacket) public void receive(AudioPacket audioPacket)
{ {
if(audioPacket.hasMetadata() && if(audioPacket.hasMetadata() && audioPacket.getMetadata().isRecordable())
audioPacket.getMetadata().isRecordable()) {
mAudioPacketQueue.offer(audioPacket);
}
}
/**
* Process any queued audio buffers and dispatch them to the audio recorders
*/
private void processBuffers()
{
List<AudioPacket> audioPackets = new ArrayList<>();
mAudioPacketQueue.drainTo(audioPackets, 50);
while(!audioPackets.isEmpty())
{
for(AudioPacket audioPacket: audioPackets)
{ {
String identifier = audioPacket.getMetadata().getUniqueIdentifier(); String identifier = audioPacket.getMetadata().getUniqueIdentifier();
@@ -107,6 +165,30 @@ public class RecorderManager implements Listener<AudioPacket>
} }
} }
} }
audioPackets.clear();
mAudioPacketQueue.drainTo(audioPackets, 50);
}
}
/**
* Removes recorders that have not received any new audio buffers in the last 6 seconds.
*/
private void removeIdleRecorders()
{
Iterator<Map.Entry<String,RealBufferWaveRecorder>> it = mRecorders.entrySet().iterator();
while(it.hasNext())
{
Map.Entry<String,RealBufferWaveRecorder> entry = it.next();
if(entry.getValue().getLastBufferReceived() + IDLE_RECORDER_REMOVAL_THRESHOLD < System.currentTimeMillis())
{
mLog.info("Removing idle recorder [" + entry.getKey() + "]");
it.remove();
entry.getValue().stop();
}
}
} }
/** /**
@@ -150,4 +232,18 @@ public class RecorderManager implements Listener<AudioPacket>
return new ComplexBufferWaveRecorder(AUDIO_SAMPLE_RATE, sb.toString()); return new ComplexBufferWaveRecorder(AUDIO_SAMPLE_RATE, sb.toString());
} }
/**
* Processes queued audio packets and distributes to each of the audio recorders. Removes any idle recorders
* that have not been updated according to an idle threshold period
*/
public class BufferProcessor implements Runnable
{
@Override
public void run()
{
processBuffers();
removeIdleRecorders();
}
}
} }

View File

@@ -18,6 +18,7 @@
******************************************************************************/ ******************************************************************************/
package record.wave; package record.wave;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import sample.ConversionUtils; import sample.ConversionUtils;
@@ -58,7 +59,7 @@ public class MonoWaveReader implements AutoCloseable
*/ */
public MonoWaveReader(Path path, boolean realTime) throws IOException public MonoWaveReader(Path path, boolean realTime) throws IOException
{ {
assert( path != null ); Validate.isTrue(path != null);
mPath = path; mPath = path;
mRealTime = realTime; mRealTime = realTime;

View File

@@ -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,9 +14,20 @@
* *
* 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 record.wave; package record.wave;
import module.Module;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sample.ConversionUtils;
import sample.Listener;
import sample.real.IFilteredRealBufferListener;
import sample.real.RealBuffer;
import util.TimeStamp;
import javax.sound.sampled.AudioFormat;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@@ -26,27 +37,13 @@ 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;
import javax.sound.sampled.AudioFormat;
import module.Module;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sample.ConversionUtils;
import sample.Listener;
import sample.real.IFilteredRealBufferListener;
import sample.real.RealBuffer;
import util.TimeStamp;
/** /**
* WAVE audio recorder module for recording real sample buffers to a wave file * WAVE audio recorder module for recording real sample buffers to a wave file
*/ */
public class RealBufferWaveRecorder extends Module public class RealBufferWaveRecorder extends Module
implements IFilteredRealBufferListener, Listener<RealBuffer> implements IFilteredRealBufferListener, Listener<RealBuffer>
{ {
private final static Logger mLog = private final static Logger mLog = LoggerFactory.getLogger(RealBufferWaveRecorder.class);
LoggerFactory.getLogger( RealBufferWaveRecorder.class );
private WaveWriter mWriter; private WaveWriter mWriter;
private String mFilePrefix; private String mFilePrefix;
@@ -55,8 +52,7 @@ public class RealBufferWaveRecorder extends Module
private BufferProcessor mBufferProcessor; private BufferProcessor mBufferProcessor;
private ScheduledFuture<?> mProcessorHandle; private ScheduledFuture<?> mProcessorHandle;
private LinkedBlockingQueue<RealBuffer> mBuffers = private LinkedBlockingQueue<RealBuffer> mBuffers = new LinkedBlockingQueue<>(500);
new LinkedBlockingQueue<>( 500 );
private long mLastBufferReceived; private long mLastBufferReceived;
private AtomicBoolean mRunning = new AtomicBoolean(); private AtomicBoolean mRunning = new AtomicBoolean();
@@ -72,6 +68,14 @@ public class RealBufferWaveRecorder extends Module
mFilePrefix = filePrefix; mFilePrefix = filePrefix;
} }
/**
* Indicates if the recorder is currently running.
*/
public boolean isRunning()
{
return mRunning.get();
}
/** /**
* Timestamp of when the latest buffer was received by this recorder * Timestamp of when the latest buffer was received by this recorder
*/ */
@@ -107,8 +111,7 @@ public class RealBufferWaveRecorder extends Module
mWriter = new WaveWriter(mAudioFormat, mFile); mWriter = new WaveWriter(mAudioFormat, mFile);
/* Schedule the processor to run every 500 milliseconds */ /* Schedule the processor to run every 500 milliseconds */
mProcessorHandle = executor.scheduleAtFixedRate( mProcessorHandle = executor.scheduleAtFixedRate(mBufferProcessor, 0, 500, TimeUnit.MILLISECONDS);
mBufferProcessor, 0, 500, TimeUnit.MILLISECONDS );
} }
catch(IOException io) catch(IOException io)
{ {
@@ -119,10 +122,23 @@ public class RealBufferWaveRecorder extends Module
public void stop() public void stop()
{ {
/* Signal the buffer processor to end with a poison pill */ if(mRunning.compareAndSet(true, false))
receive( new PoisonPill() ); {
try
{
write();
mRunning.set( false ); if(mWriter != null)
{
mWriter.close();
mWriter = null;
}
}
catch(IOException ioe)
{
mLog.error("Error writing final audio buffers to recording during shutdown", ioe);
}
}
} }
@Override @Override
@@ -134,9 +150,7 @@ public class RealBufferWaveRecorder extends Module
if(!success) if(!success)
{ {
mLog.error( "recorder buffer overflow - purging [" + mLog.error("recorder buffer overflow - purging [" + mFile.toFile().getAbsolutePath() + "]");
mFile.toFile().getAbsolutePath() + "]" );
mBuffers.clear(); mBuffers.clear();
} }
@@ -161,50 +175,28 @@ public class RealBufferWaveRecorder extends Module
{ {
} }
/**
* Writes all audio currently in the queue to the file
* @throws IOException if there are any errors writing the audio
*/
private void write() throws IOException
{
RealBuffer buffer = mBuffers.poll();
while(buffer != null)
{
mWriter.write(ConversionUtils.convertToSigned16BitSamples(buffer));
buffer = mBuffers.poll();
}
}
public class BufferProcessor implements Runnable public class BufferProcessor implements Runnable
{ {
public void run() public void run()
{ {
try try
{ {
RealBuffer buffer = mBuffers.poll(); write();
while( buffer != null )
{
if( buffer instanceof PoisonPill )
{
buffer = null;
mBuffers.clear();
if( mWriter != null )
{
try
{
mWriter.close();
}
catch( IOException io )
{
mLog.error( "Error stopping complex wave recorder [" +
getFile() + "]", io );
}
}
if( mProcessorHandle != null )
{
mProcessorHandle.cancel( true );
}
mProcessorHandle = null;
mWriter = null;
mFile = null;
}
else
{
mWriter.write( ConversionUtils.convertToSigned16BitSamples( buffer ) );
buffer = mBuffers.poll();
}
}
} }
catch(IOException ioe) catch(IOException ioe)
{ {
@@ -212,20 +204,8 @@ public class RealBufferWaveRecorder extends Module
mBuffers.clear(); mBuffers.clear();
stop(); stop();
mLog.error( "IOException while trying to write to the wave " mLog.error("IO Exception while trying to write to the wave writer", ioe);
+ "writer", ioe );
} }
} }
} }
/**
* This is used as a sentinel value to signal the buffer processor to end
*/
public class PoisonPill extends RealBuffer
{
public PoisonPill()
{
super( new float[ 1 ] );
}
}
} }

View File

@@ -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,9 +14,12 @@
* *
* 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 record.wave; package record.wave;
import org.apache.commons.lang3.Validate;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
@@ -32,10 +35,7 @@ import javax.sound.sampled.AudioFormat;
public class WaveWriter implements AutoCloseable public class WaveWriter implements AutoCloseable
{ {
// private final static Logger mLog = LoggerFactory.getLogger( WaveWriter.class ); private static final Pattern FILENAME_PATTERN = Pattern.compile( "(.*_)(\\d+)(\\.wav)" );
private static final Pattern FILENAME_PATTERN =
Pattern.compile( "(.*_)(\\d+)(\\.wav)" );
public static final long MAX_WAVE_SIZE = 2l * (long)Integer.MAX_VALUE; public static final long MAX_WAVE_SIZE = 2l * (long)Integer.MAX_VALUE;
private AudioFormat mAudioFormat; private AudioFormat mAudioFormat;
@@ -56,11 +56,10 @@ public class WaveWriter implements AutoCloseable
* @param maxSize - maximum file size ( range: 1 - 4,294,967,294 bytes ) * @param maxSize - maximum file size ( range: 1 - 4,294,967,294 bytes )
* @throws IOException - if there are any IO issues * @throws IOException - if there are any IO issues
*/ */
public WaveWriter( AudioFormat format, Path file, long maxSize ) public WaveWriter( AudioFormat format, Path file, long maxSize ) throws IOException
throws IOException
{ {
assert( format != null ); Validate.isTrue(format != null);
assert( file != null ); Validate.isTrue( file != null );
mAudioFormat = format; mAudioFormat = format;
mFile = file; mFile = file;
@@ -100,15 +99,11 @@ public class WaveWriter implements AutoCloseable
while( Files.exists( mFile ) ) while( Files.exists( mFile ) )
{ {
mFile = Paths.get( mFile.toFile().getAbsolutePath() mFile = Paths.get( mFile.toFile().getAbsolutePath().replace( ".wav", "_" + version + ".wav" ) );
.replace( ".wav", "_" + version + ".wav" ) );
version++; version++;
} }
Files.createFile( mFile ); mFileChannel = (FileChannel.open( mFile, StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW ) );
mFileChannel = (FileChannel.open( mFile, StandardOpenOption.WRITE ) );
ByteBuffer header = WaveUtils.getWaveHeader( mAudioFormat ); ByteBuffer header = WaveUtils.getWaveHeader( mAudioFormat );
@@ -127,6 +122,15 @@ public class WaveWriter implements AutoCloseable
{ {
mFileChannel.force( true ); mFileChannel.force( true );
mFileChannel.close(); mFileChannel.close();
mFileChannel = null;
}
@Override
protected void finalize() throws IOException
{
mFileChannel.force( true );
mFileChannel.close();
mFileChannel = null;
} }
/** /**

View File

@@ -58,6 +58,11 @@ public class Broadcaster<T> implements Listener<T>
public void addListener( Listener<T> listener ) public void addListener( Listener<T> listener )
{ {
if(listener == null)
{
throw new IllegalArgumentException("Listener cannot be null");
}
mListeners.add( listener ); mListeners.add( listener );
} }

View File

@@ -20,6 +20,7 @@ package sample.adapter;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import org.apache.commons.lang3.Validate;
import source.mixer.MixerChannel; import source.mixer.MixerChannel;
/** /**
@@ -34,7 +35,7 @@ public class ChannelShortAdapter implements ISampleAdapter
public ChannelShortAdapter( MixerChannel channel ) public ChannelShortAdapter( MixerChannel channel )
{ {
/* Only use with LEFT/RIGHT channels */ /* Only use with LEFT/RIGHT channels */
assert( channel != MixerChannel.MONO ); Validate.isTrue(channel != MixerChannel.MONO);
mMixerChannel = channel; mMixerChannel = channel;
} }

View File

@@ -17,6 +17,7 @@
******************************************************************************/ ******************************************************************************/
package sample.complex; package sample.complex;
import org.apache.commons.lang3.Validate;
import sample.Listener; import sample.Listener;
/** /**
@@ -32,7 +33,7 @@ public class ComplexToComplexBufferAssembler implements ComplexSampleListener
public ComplexToComplexBufferAssembler( int bufferSize ) public ComplexToComplexBufferAssembler( int bufferSize )
{ {
assert( bufferSize % 2 == 0 ); Validate.isTrue(bufferSize % 2 == 0);
mBufferSize = bufferSize; mBufferSize = bufferSize;
mBuffer = new float[ mBufferSize ]; mBuffer = new float[ mBufferSize ];

View File

@@ -20,11 +20,13 @@ 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 public abstract class Source extends Module implements IFrequencyChangeListener, IFrequencyChangeProvider
{ {
protected SampleType mSampleType; protected SampleType mSampleType;
protected IOverflowListener mOverflowListener; protected IOverflowListener mOverflowListener;

View File

@@ -36,11 +36,11 @@ 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;
public class RealMixerSource extends RealSource public class RealMixerSource extends RealSource
{ {
private final static Logger mLog = private final static Logger mLog = LoggerFactory.getLogger( RealMixerSource.class );
LoggerFactory.getLogger( RealMixerSource.class );
private long mFrequency = 0; private long mFrequency = 0;
private int mBufferSize = 16384; private int mBufferSize = 16384;
@@ -48,13 +48,11 @@ public class RealMixerSource extends RealSource
private BufferReader mBufferReader = new BufferReader(); private BufferReader mBufferReader = new BufferReader();
private TargetDataLine mTargetDataLine; private TargetDataLine mTargetDataLine;
private AudioFormat mAudioFormat; private AudioFormat mAudioFormat;
private String mDisplayName;
private int mBytesPerFrame = 0; private int mBytesPerFrame = 0;
private ISampleAdapter mSampleAdapter; private ISampleAdapter mSampleAdapter;
private AutomaticGainControl mAGC = new AutomaticGainControl(); private AutomaticGainControl mAGC = new AutomaticGainControl();
CopyOnWriteArrayList<Listener<RealBuffer>> mSampleListeners = CopyOnWriteArrayList<Listener<RealBuffer>> mSampleListeners = new CopyOnWriteArrayList<Listener<RealBuffer>>();
new CopyOnWriteArrayList<Listener<RealBuffer>>();
/** /**
* Real Mixer Source - constructs a reader on the mixer/sound card target * Real Mixer Source - constructs a reader on the mixer/sound card target
@@ -81,6 +79,25 @@ public class RealMixerSource extends RealSource
mSampleAdapter = sampleAdapter; mSampleAdapter = sampleAdapter;
} }
@Override
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
{
//Not implemented
}
@Override
public void removeFrequencyChangeListener()
{
//Not implemented
}
@Override
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
{
//Not implemented
return null;
}
@Override @Override
public void reset() public void reset()
{ {
@@ -133,23 +150,15 @@ public class RealMixerSource extends RealSource
* buffer, otherwise send him a copy of the buffer */ * buffer, otherwise send him a copy of the buffer */
if( it.hasNext() ) if( it.hasNext() )
{ {
// next.receive( mAGC.process( samples.copyOf() ) );
next.receive( samples.copyOf() ); next.receive( samples.copyOf() );
} }
else else
{ {
// next.receive( mAGC.process( samples ) );
next.receive( samples ); next.receive( samples );
} }
} }
} }
@Override
public String toString()
{
return mDisplayName;
}
public int getSampleRate() public int getSampleRate()
{ {
if( mTargetDataLine != null ) if( mTargetDataLine != null )

View File

@@ -34,7 +34,9 @@ import source.ComplexSource;
import source.SourceException; import source.SourceException;
import source.tuner.frequency.FrequencyChangeEvent; import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.FrequencyChangeEvent.Event; import source.tuner.frequency.FrequencyChangeEvent.Event;
import source.tuner.frequency.IFrequencyChangeListener;
import source.tuner.frequency.IFrequencyChangeProcessor; import source.tuner.frequency.IFrequencyChangeProcessor;
import source.tuner.frequency.IFrequencyChangeProvider;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -65,6 +67,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
private ComplexPrimeCICDecimate mDecimationFilter; private ComplexPrimeCICDecimate mDecimationFilter;
private Listener<ComplexBuffer> mListener; private Listener<ComplexBuffer> mListener;
private IFrequencyChangeProcessor mFrequencyChangeProcessor; private IFrequencyChangeProcessor mFrequencyChangeProcessor;
private DownstreamProcessor mDownstreamFrequencyEventProcessor = new DownstreamProcessor();
private ScheduledFuture<?> mTaskHandle; private ScheduledFuture<?> mTaskHandle;
private long mTunerFrequency = 0; private long mTunerFrequency = 0;
@@ -75,7 +78,6 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
private AtomicBoolean mRunning = new AtomicBoolean(); private AtomicBoolean mRunning = new AtomicBoolean();
private boolean mExpended = false; private boolean mExpended = false;
private int mCount;
/** /**
* Provides a Digital Drop Channel (DDC) to decimate the IQ output from a * Provides a Digital Drop Channel (DDC) to decimate the IQ output from a
@@ -109,7 +111,8 @@ 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, mTuner.getTunerController().getSampleRate())); frequencyChanged(new FrequencyChangeEvent(Event.NOTIFICATION_SAMPLE_RATE_CHANGE,
mTuner.getTunerController().getSampleRate()));
} }
/** /**
@@ -131,6 +134,10 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
if(mRunning.compareAndSet(false, true)) if(mRunning.compareAndSet(false, true))
{ {
//Broadcast current frequency and sample rate settings so all downstream components are aware
mDownstreamFrequencyEventProcessor.broadcastCurrentFrequency();
mDownstreamFrequencyEventProcessor.broadcastCurrentSampleRate();
//Schedule the decimation task to run every 9 ms (111 iterations/second), an odd periodicity relative //Schedule the decimation task to run every 9 ms (111 iterations/second), an odd periodicity relative
//to the inbound periodicity of 20 ms, to attempt to avoid thread queue contention //to the inbound periodicity of 20 ms, to attempt to avoid thread queue contention
mTaskHandle = executor.scheduleAtFixedRate(mDecimationProcessor, 0, 9, TimeUnit.MILLISECONDS); mTaskHandle = executor.scheduleAtFixedRate(mDecimationProcessor, 0, 9, TimeUnit.MILLISECONDS);
@@ -184,6 +191,20 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
} }
} }
/**
* Changes the frequency correction value and broadcasts the change to the registered downstream listener.
* @param correction current frequency correction value.
*/
private void setFrequencyCorrection(int correction)
{
mChannelFrequencyCorrection = correction;
updateMixerFrequencyOffset();
mDownstreamFrequencyEventProcessor.broadcast(
new FrequencyChangeEvent( Event.NOTIFICATION_CHANNEL_FREQUENCY_CORRECTION_CHANGE, mChannelFrequencyCorrection));
}
public Tuner getTuner() public Tuner getTuner()
{ {
return mTuner; return mTuner;
@@ -242,21 +263,25 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
case NOTIFICATION_FREQUENCY_CHANGE: case NOTIFICATION_FREQUENCY_CHANGE:
mTunerFrequency = event.getValue().longValue(); mTunerFrequency = event.getValue().longValue();
updateMixerFrequencyOffset(); updateMixerFrequencyOffset();
break;
case REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE:
mChannelFrequencyCorrection = event.getValue().intValue();
updateMixerFrequencyOffset(); //Reset frequency correction so that downstream components can recalculate the value
setFrequencyCorrection(0);
if(mFrequencyChangeProcessor != null)
{
mFrequencyChangeProcessor.frequencyChanged(new FrequencyChangeEvent(
Event.NOTIFICATION_CHANNEL_FREQUENCY_CORRECTION_CHANGE, mChannelFrequencyCorrection));
}
break; break;
case NOTIFICATION_SAMPLE_RATE_CHANGE: case NOTIFICATION_SAMPLE_RATE_CHANGE:
int sampleRate = event.getValue().intValue(); int sampleRate = event.getValue().intValue();
setSampleRate(sampleRate);
break;
default:
break;
}
}
/**
* Updates the sample rate to the requested value and notifies any downstream components of the change
* @param sampleRate to set
*/
private void setSampleRate(int sampleRate)
{
if(mTunerSampleRate != sampleRate) if(mTunerSampleRate != sampleRate)
{ {
mMixer.setSampleRate(sampleRate); mMixer.setSampleRate(sampleRate);
@@ -269,10 +294,8 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
mDecimationFilter.setListener(mListener); mDecimationFilter.setListener(mListener);
mTunerSampleRate = sampleRate; mTunerSampleRate = sampleRate;
}
break; mDownstreamFrequencyEventProcessor.broadcastCurrentSampleRate();
default:
break;
} }
} }
@@ -282,10 +305,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
*/ */
private void updateMixerFrequencyOffset() private void updateMixerFrequencyOffset()
{ {
long offset = mTunerFrequency - long offset = mTunerFrequency - mTunerChannel.getFrequency() - mChannelFrequencyCorrection;
mTunerChannel.getFrequency() -
mChannelFrequencyCorrection;
mMixer.setFrequency(offset); mMixer.setFrequency(offset);
} }
@@ -299,6 +319,140 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
return mTunerChannel.getFrequency(); return mTunerChannel.getFrequency();
} }
/**
* Implements IFrequencyChangeProvider to enable this source to broadcast frequency change events to downstream
* listeners.
*
* @param listener to receive downstream events
*/
@Override
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
{
mDownstreamFrequencyEventProcessor.setFrequencyChangeListener(listener);
}
/**
* Implements IFrequencyChangeProvider to remove the frequency change listener from receiving down-stream frequency
* change events.
*/
@Override
public void removeFrequencyChangeListener()
{
mDownstreamFrequencyEventProcessor.removeFrequencyChangeListener();
}
/**
* Implements IFrequencyChangeListener to receive frequency change events containing requests from downstream
* listeners to change frequency values.
* @return listener
*/
@Override
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
{
return mDownstreamFrequencyEventProcessor.getFrequencyChangeListener();
}
/**
* Managers frequency change requests and notifications from/to any downstream component. Downstream
* components are those that receive samples from this tuner channel source. These downstream components will be
* notified of any frequency or sample rate change events and will also be able to request frequency correction
* updates.
*/
public class DownstreamProcessor implements IFrequencyChangeListener, IFrequencyChangeProvider,
Listener<FrequencyChangeEvent>
{
//Listener to receive downstream events
private Listener<FrequencyChangeEvent> mListener;
/**
* Broadcasts the frequency change event to the downstream frequency change listener
* @param event to broadcast
*/
public void broadcast(FrequencyChangeEvent event)
{
if(mListener != null)
{
mListener.receive(event);
}
}
/**
* Broadcasts the current frequency of this tuner channel source to the downstream listener
*/
public void broadcastCurrentFrequency()
{
try
{
long frequency = getFrequency();
broadcast(new FrequencyChangeEvent(Event.NOTIFICATION_FREQUENCY_CHANGE, frequency));
}
catch(SourceException se)
{
mLog.error("Error obtaining frequency from tuner to broadcast downstream");
}
}
/**
* Broadcasts the current decimated sample rate of this tuner channel source
*/
public void broadcastCurrentSampleRate()
{
try
{
//Note: downstream sample rate is currently a fixed value -- it will change in the future
broadcast(new FrequencyChangeEvent(Event.NOTIFICATION_SAMPLE_RATE_CHANGE, getSampleRate()));
}
catch(SourceException se)
{
mLog.error("Error obtaining sample rate from tuner to broadcast downstream");
}
}
/**
* Sets the downstream listener to receive frequency change events from this tuner channel source
* @param listener to receive events
*/
@Override
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
{
mListener = listener;
}
/**
* Removes the downstream listener from receiving frequency change events.
*/
@Override
public void removeFrequencyChangeListener()
{
mListener = null;
}
/**
* Listener for receiving frequency change events from downstream components
*/
@Override
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
{
return this;
}
/**
* Processes frequency change events from downstream components.
* @param event to process
*/
@Override
public void receive(FrequencyChangeEvent event)
{
switch(event.getEvent())
{
//Frequency correction requests are the only change requests supported from downstream components
case REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE:
setFrequencyCorrection(event.getValue().intValue());
break;
}
}
}
/** /**
* Decimates an inbound buffer of I/Q samples from the source down to the * Decimates an inbound buffer of I/Q samples from the source down to the
* standard 48000 channel sample rate * standard 48000 channel sample rate

View File

@@ -113,7 +113,16 @@ public class FCD2TunerController extends FCDTunerController
FCD2TunerConfiguration fcd2 = (FCD2TunerConfiguration)config; FCD2TunerConfiguration fcd2 = (FCD2TunerConfiguration)config;
setFrequencyCorrection(fcd2.getFrequencyCorrection()); setFrequencyCorrection(fcd2.getFrequencyCorrection());
setFrequency(fcd2.getFrequency());
long frequency = MINIMUM_TUNABLE_FREQUENCY;
if(fcd2.getFrequency() >= MINIMUM_TUNABLE_FREQUENCY &&
fcd2.getFrequency() <= MAXIMUM_TUNABLE_FREQUENCY)
{
frequency = fcd2.getFrequency();
}
setFrequency(frequency);
setLNAGain(fcd2.getGainLNA()); setLNAGain(fcd2.getGainLNA());
setMixerGain(fcd2.getGainMixer()); setMixerGain(fcd2.getGainMixer());

View File

@@ -1,9 +1,30 @@
/*******************************************************************************
* 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; package source.tuner.frequency;
import sample.Listener; import sample.Listener;
/**
* Provider of Frequency Change Events
*/
public interface IFrequencyChangeProvider public interface IFrequencyChangeProvider
{ {
public void setFrequencyChangeListener( Listener<FrequencyChangeEvent> listener ); void setFrequencyChangeListener( Listener<FrequencyChangeEvent> listener );
public void removeFrequencyChangeListener(); void removeFrequencyChangeListener();
} }

View File

@@ -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,6 +14,7 @@
* *
* 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.wave; package source.wave;
@@ -36,6 +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;
public class ComplexWaveSource extends ComplexSource implements IControllableFileSource public class ComplexWaveSource extends ComplexSource implements IControllableFileSource
{ {
@@ -55,6 +57,25 @@ public class ComplexWaveSource extends ComplexSource implements IControllableFil
mFile = file; mFile = file;
} }
@Override
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
{
//Not implemented
}
@Override
public void removeFrequencyChangeListener()
{
//Not implemented
}
@Override
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
{
//Not implemented
return null;
}
@Override @Override
public void reset() public void reset()
{ {

View File

@@ -36,6 +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;
public class RealWaveSource extends RealSource public class RealWaveSource extends RealSource
implements IControllableFileSource, AutoCloseable implements IControllableFileSource, AutoCloseable
@@ -56,6 +57,25 @@ public class RealWaveSource extends RealSource
mFile = file; mFile = file;
} }
@Override
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
{
//Not implemented
}
@Override
public void removeFrequencyChangeListener()
{
//Not implemented
}
@Override
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
{
//Not implemented
return null;
}
@Override @Override
public void reset() public void reset()

View File

@@ -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,31 +14,17 @@
* *
* 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 spectrum; package spectrum;
import java.awt.BasicStroke; import controller.channel.Channel;
import java.awt.Color; import controller.channel.Channel.ChannelType;
import java.awt.Font; import controller.channel.ChannelEvent;
import java.awt.FontMetrics; import controller.channel.ChannelEventListener;
import java.awt.Graphics; import controller.channel.ChannelModel;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.Stroke;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.swing.JPanel;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import settings.ColorSetting; import settings.ColorSetting;
import settings.ColorSetting.ColorSettingName; import settings.ColorSetting.ColorSettingName;
import settings.Setting; import settings.Setting;
@@ -47,34 +33,35 @@ import settings.SettingsManager;
import source.tuner.TunerChannel; import source.tuner.TunerChannel;
import source.tuner.frequency.FrequencyChangeEvent; import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.IFrequencyChangeProcessor; import source.tuner.frequency.IFrequencyChangeProcessor;
import controller.channel.Channel;
import controller.channel.Channel.ChannelType;
import controller.channel.ChannelEvent;
import controller.channel.ChannelEventListener;
import controller.channel.ChannelModel;
public class OverlayPanel extends JPanel import javax.swing.*;
implements ChannelEventListener, import java.awt.*;
IFrequencyChangeProcessor, import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.concurrent.CopyOnWriteArrayList;
public class OverlayPanel extends JPanel implements ChannelEventListener, IFrequencyChangeProcessor,
SettingChangeListener SettingChangeListener
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final static Logger mLog = private final static Logger mLog = LoggerFactory.getLogger(OverlayPanel.class);
LoggerFactory.getLogger( OverlayPanel.class ); private final DecimalFormat PPM_FORMATTER = new DecimalFormat( "#.0" );
private final static RenderingHints RENDERING_HINTS = private final static RenderingHints RENDERING_HINTS = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
new RenderingHints( RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON); RenderingHints.VALUE_ANTIALIAS_ON);
static static
{ {
RENDERING_HINTS.put( RenderingHints.KEY_RENDERING, RENDERING_HINTS.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
RenderingHints.VALUE_RENDER_QUALITY );
} }
private final static BasicStroke DASHED_STROKE = new BasicStroke(0.8f, private final static BasicStroke DASHED_STROKE = new BasicStroke(0.8f, BasicStroke.CAP_BUTT,
BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 5.0f, new float[] {2.0f, 4.0f}, 0.0f); BasicStroke.JOIN_MITER, 5.0f, new float[]{2.0f, 4.0f}, 0.0f);
private static DecimalFormat CURSOR_FORMAT = new DecimalFormat("000.00000"); private static DecimalFormat CURSOR_FORMAT = new DecimalFormat("000.00000");
private long mFrequency = 0; private long mFrequency = 0;
@@ -107,13 +94,13 @@ public class OverlayPanel extends JPanel
private SettingsManager mSettingsManager; private SettingsManager mSettingsManager;
private ChannelModel mChannelModel; private ChannelModel mChannelModel;
/** /**
* Translucent overlay panel for displaying channel configurations, * Translucent overlay panel for displaying channel configurations,
* processing channels, selected channels, frequency labels and lines, and * processing channels, selected channels, frequency labels and lines, and
* a cursor with a frequency readout. * a cursor with a frequency readout.
*/ */
public OverlayPanel( SettingsManager settingsManager, public OverlayPanel(SettingsManager settingsManager, ChannelModel channelModel)
ChannelModel channelModel )
{ {
mSettingsManager = settingsManager; mSettingsManager = settingsManager;
@@ -201,7 +188,6 @@ public class OverlayPanel extends JPanel
* 6 64x Zoom * 6 64x Zoom
* *
* @param zoom level, 0 - 6. * @param zoom level, 0 - 6.
* @param offset into the FFT bins for start zoom window
*/ */
public void setZoom(int zoom) public void setZoom(int zoom)
{ {
@@ -222,18 +208,15 @@ public class OverlayPanel extends JPanel
{ {
mColorChannelConfig = getColor(ColorSettingName.CHANNEL_CONFIG); mColorChannelConfig = getColor(ColorSettingName.CHANNEL_CONFIG);
mColorChannelConfigProcessing = mColorChannelConfigProcessing = getColor(ColorSettingName.CHANNEL_CONFIG_PROCESSING);
getColor( ColorSettingName.CHANNEL_CONFIG_PROCESSING );
mColorChannelConfigSelected = mColorChannelConfigSelected = getColor(ColorSettingName.CHANNEL_CONFIG_SELECTED);
getColor( ColorSettingName.CHANNEL_CONFIG_SELECTED );
mColorSpectrumCursor = getColor(ColorSettingName.SPECTRUM_CURSOR); mColorSpectrumCursor = getColor(ColorSettingName.SPECTRUM_CURSOR);
mColorSpectrumLine = getColor(ColorSettingName.SPECTRUM_LINE); mColorSpectrumLine = getColor(ColorSettingName.SPECTRUM_LINE);
mColorSpectrumBackground = mColorSpectrumBackground = getColor(ColorSettingName.SPECTRUM_BACKGROUND);
getColor( ColorSettingName.SPECTRUM_BACKGROUND );
} }
/** /**
@@ -310,21 +293,23 @@ public class OverlayPanel extends JPanel
{ {
if(mCursorVisible) if(mCursorVisible)
{ {
drawFrequencyLine( graphics, drawFrequencyLine(graphics, mCursorLocation.x, mColorSpectrumCursor);
mCursorLocation.x,
mColorSpectrumCursor );
String frequency = CURSOR_FORMAT.format( String frequency = CURSOR_FORMAT.format(getFrequencyFromAxis(mCursorLocation.getX()) / 1E6D);
getFrequencyFromAxis( mCursorLocation.getX() ) / 1E6D );
graphics.drawString( frequency , FontMetrics fontMetrics = graphics.getFontMetrics(this.getFont());
mCursorLocation.x + 5,
mCursorLocation.y ); Rectangle2D rect = fontMetrics.getStringBounds(frequency, graphics);
if(mCursorLocation.y > rect.getHeight())
{
graphics.drawString(frequency, mCursorLocation.x + 5, mCursorLocation.y);
}
if(mZoom != 0) if(mZoom != 0)
{ {
graphics.drawString( "Zoom: " + (int)Math.pow( 2.0, mZoom ) + "x", graphics.drawString("Zoom: " + (int)Math.pow(2.0, mZoom) + "x", mCursorLocation.x + 17,
mCursorLocation.x + 17, mCursorLocation.y + 11 ); mCursorLocation.y + 11);
} }
} }
} }
@@ -336,8 +321,6 @@ public class OverlayPanel extends JPanel
{ {
Stroke currentStroke = graphics.getStroke(); Stroke currentStroke = graphics.getStroke();
// graphics.setStroke( DASHED_STROKE );
long minFrequency = getMinDisplayFrequency(); long minFrequency = getMinDisplayFrequency();
long maxFrequency = getMaxDisplayFrequency(); long maxFrequency = getMaxDisplayFrequency();
@@ -372,8 +355,6 @@ public class OverlayPanel extends JPanel
frequency += minor; frequency += minor;
} }
// graphics.setStroke( currentStroke );
} }
/** /**
@@ -415,8 +396,7 @@ public class OverlayPanel extends JPanel
{ {
graphics.setColor(color); graphics.setColor(color);
graphics.draw( new Line2D.Double( xaxis, 0.0d, graphics.draw(new Line2D.Double(xaxis, 0.0d, xaxis, getSize().getHeight() - mSpectrumInset));
xaxis, getSize().getHeight() - mSpectrumInset ) );
} }
/** /**
@@ -428,27 +408,45 @@ public class OverlayPanel extends JPanel
graphics.setColor(Color.LIGHT_GRAY); graphics.setColor(Color.LIGHT_GRAY);
graphics.draw( new Line2D.Double( xaxis, height * 0.65d, graphics.draw(new Line2D.Double(xaxis, height * 0.65d, xaxis, height - 1.0d));
xaxis, height - 1.0d ) );
} }
/** /**
* Draws a vertical line at the xaxis * Draws the Automatic Frequency Control (AFC) channel center offset
*/ */
private void drawAFC( Graphics2D graphics, double frequencyAxis, double errorAxis ) private void drawAFC(Graphics2D graphics, double frequencyAxis, double errorAxis, double bandwidth,
int correction, long frequency)
{ {
double height = getSize().getHeight() - mSpectrumInset; double height = getSize().getHeight() - mSpectrumInset;
double lineHeight = height * 0.75d; double verticalAxisTop = height * 0.88d;
double verticalAxisBottom = height * 0.98d;
double halfBandwidth = bandwidth / 2.0;
double errorEdgeStart = errorAxis - halfBandwidth;
double errorEdgeStop = errorAxis + halfBandwidth;
graphics.setColor(Color.YELLOW); graphics.setColor(Color.YELLOW);
//Vertical frequency error line //Horizontal line connecting frequency and error line
graphics.draw( new Line2D.Double( errorAxis, lineHeight, graphics.draw(new Line2D.Double(errorEdgeStart, verticalAxisBottom, errorEdgeStop, verticalAxisBottom));
errorAxis, height - 1.0d ) );
//Horizontal line connecting frequency and error lines //Vertical band edge lines
graphics.draw( new Line2D.Double( frequencyAxis, lineHeight, graphics.draw(new Line2D.Double(errorEdgeStart, verticalAxisTop, errorEdgeStart, verticalAxisBottom));
errorAxis, lineHeight ) ); graphics.draw(new Line2D.Double(errorEdgeStop, verticalAxisTop, errorEdgeStop, verticalAxisBottom));
double ppm = (double)correction / ((double)frequency / 1E6d);
String label = "PPM " + PPM_FORMATTER.format(ppm) ;
FontMetrics fontMetrics = graphics.getFontMetrics(this.getFont());
Rectangle2D rect = fontMetrics.getStringBounds(label, graphics);
//Only render the correction value label if the spacing is large enough
if(rect.getWidth() <= bandwidth && rect.getHeight() * 5 <= height)
{
graphics.drawString(label, (float)(errorEdgeStart + 1.0), (float)(verticalAxisBottom - 2.0));
}
} }
/** /**
@@ -484,8 +482,7 @@ public class OverlayPanel extends JPanel
double offset = xAxis / width; double offset = xAxis / width;
long frequency = getMinDisplayFrequency() + long frequency = getMinDisplayFrequency() + Math.round((double)getDisplayBandwidth() * offset);
Math.round( (double)getDisplayBandwidth() * offset );
if(frequency > (getMaxFrequency())) if(frequency > (getMaxFrequency()))
{ {
@@ -498,9 +495,7 @@ public class OverlayPanel extends JPanel
/** /**
* Draws a frequency label at the x-axis position, at the bottom of the panel * Draws a frequency label at the x-axis position, at the bottom of the panel
*/ */
private void drawFrequencyLabel( Graphics2D graphics, private void drawFrequencyLabel(Graphics2D graphics, double xaxis, long frequency)
double xaxis,
long frequency )
{ {
String label = mLabelSizeMonitor.format(frequency); String label = mLabelSizeMonitor.format(frequency);
@@ -510,8 +505,7 @@ public class OverlayPanel extends JPanel
float xOffset = (float)rect.getWidth() / 2; float xOffset = (float)rect.getWidth() / 2;
graphics.drawString( label, (float)( xaxis - xOffset ), graphics.drawString(label, (float)(xaxis - xOffset), (float)(getSize().getHeight() - 2.0f));
(float)( getSize().getHeight() - 2.0f ) );
} }
@@ -523,8 +517,7 @@ public class OverlayPanel extends JPanel
for(Channel channel : mVisibleChannels) for(Channel channel : mVisibleChannels)
{ {
if(mChannelDisplay == ChannelDisplay.ALL || if(mChannelDisplay == ChannelDisplay.ALL ||
( mChannelDisplay == ChannelDisplay.ENABLED && (mChannelDisplay == ChannelDisplay.ENABLED && channel.getEnabled()))
channel.getEnabled() ) )
{ {
//Choose the correct background color to use //Choose the correct background color to use
if(channel.isSelected()) if(channel.isSelected())
@@ -546,12 +539,10 @@ public class OverlayPanel extends JPanel
{ {
double xAxis = getAxisFromFrequency(tunerChannel.getFrequency()); double xAxis = getAxisFromFrequency(tunerChannel.getFrequency());
double width = (double)( tunerChannel.getBandwidth() ) / double width = (double)(tunerChannel.getBandwidth()) / (double)getDisplayBandwidth() * getSize().getWidth();
(double)getDisplayBandwidth() * getSize().getWidth();
Rectangle2D.Double box = Rectangle2D.Double box =
new Rectangle2D.Double( xAxis - ( width / 2.0d ), new Rectangle2D.Double(xAxis - (width / 2.0d), 0.0d, width, getSize().getHeight() - mSpectrumInset);
0.0d, width, getSize().getHeight() - mSpectrumInset );
//Fill the box with the correct color //Fill the box with the correct color
graphics.fill(box); graphics.fill(box);
@@ -567,30 +558,15 @@ public class OverlayPanel extends JPanel
//Draw the system label and adjust the y-axis position //Draw the system label and adjust the y-axis position
String system = channel.hasSystem() ? channel.getSystem() : " "; String system = channel.hasSystem() ? channel.getSystem() : " ";
yAxis += drawLabel( graphics, yAxis += drawLabel(graphics, system, this.getFont(), xAxis, yAxis, width);
system,
this.getFont(),
xAxis,
yAxis,
width );
//Draw the site label and adjust the y-axis position //Draw the site label and adjust the y-axis position
String site = channel.hasSite() ? channel.getSite() : " "; String site = channel.hasSite() ? channel.getSite() : " ";
yAxis += drawLabel( graphics, yAxis += drawLabel(graphics, site, this.getFont(), xAxis, yAxis, width);
site,
this.getFont(),
xAxis,
yAxis,
width );
//Draw the channel label and adjust the y-axis position //Draw the channel label and adjust the y-axis position
yAxis += drawLabel( graphics, yAxis += drawLabel(graphics, channel.getName(), this.getFont(), xAxis, yAxis, width);
channel.getName(),
this.getFont(),
xAxis,
yAxis,
width );
//Draw the decoder label //Draw the decoder label
drawLabel(graphics, channel.getDecodeConfiguration().getDecoderType().getShortDisplayString(), drawLabel(graphics, channel.getDecodeConfiguration().getDecoderType().getShortDisplayString(),
@@ -609,7 +585,8 @@ public class OverlayPanel extends JPanel
{ {
long error = frequency + correction; long error = frequency + correction;
drawAFC( graphics, frequencyAxis, getAxisFromFrequency( error ) ); drawAFC(graphics, frequencyAxis, getAxisFromFrequency(error), width, correction,
tunerChannel.getFrequency());
} }
} }
} }
@@ -623,8 +600,7 @@ public class OverlayPanel extends JPanel
* *
* @return height of the drawn label * @return height of the drawn label
*/ */
private double drawLabel( Graphics2D graphics, String text, Font font, private double drawLabel(Graphics2D graphics, String text, Font font, double x, double baseY, double maxWidth)
double x, double baseY, double maxWidth )
{ {
FontMetrics fontMetrics = graphics.getFontMetrics(font); FontMetrics fontMetrics = graphics.getFontMetrics(font);
@@ -639,15 +615,11 @@ public class OverlayPanel extends JPanel
*/ */
if(offset > (maxWidth / 2.0d)) if(offset > (maxWidth / 2.0d))
{ {
label.setRect( x - ( maxWidth / 2.0d ), label.setRect(x - (maxWidth / 2.0d), y - label.getHeight(), maxWidth, label.getHeight());
y - label.getHeight(),
maxWidth,
label.getHeight() );
graphics.setClip(label); graphics.setClip(label);
graphics.drawString( text, graphics.drawString(text, (float)(x - (maxWidth / 2.0d)), (float)y);
(float)( x - ( maxWidth / 2.0d ) ), (float)y );
graphics.setClip(null); graphics.setClip(null);
} }
@@ -683,9 +655,7 @@ public class OverlayPanel extends JPanel
* Reset the visible channels list * Reset the visible channels list
*/ */
mVisibleChannels.clear(); mVisibleChannels.clear();
mVisibleChannels.addAll( mVisibleChannels.addAll(mChannelModel.getChannelsInFrequencyRange(getMinFrequency(), getMaxFrequency()));
mChannelModel.getChannelsInFrequencyRange( getMinFrequency(),
getMaxFrequency() ) );
} }
/** /**
@@ -701,8 +671,7 @@ public class OverlayPanel extends JPanel
{ {
case NOTIFICATION_ADD: case NOTIFICATION_ADD:
case NOTIFICATION_PROCESSING_START: case NOTIFICATION_PROCESSING_START:
if( !mVisibleChannels.contains( channel ) && if(!mVisibleChannels.contains(channel) && channel.isWithin(getMinFrequency(), getMaxFrequency()))
channel.isWithin( getMinFrequency(), getMaxFrequency() ) )
{ {
mVisibleChannels.add(channel); mVisibleChannels.add(channel);
} }
@@ -717,14 +686,12 @@ public class OverlayPanel extends JPanel
} }
break; break;
case NOTIFICATION_CONFIGURATION_CHANGE: case NOTIFICATION_CONFIGURATION_CHANGE:
if( mVisibleChannels.contains( channel ) && if(mVisibleChannels.contains(channel) && !channel.isWithin(getMinFrequency(), getMaxFrequency()))
!channel.isWithin( getMinFrequency(), getMaxFrequency() ) )
{ {
mVisibleChannels.remove(channel); mVisibleChannels.remove(channel);
} }
if( !mVisibleChannels.contains( channel ) && if(!mVisibleChannels.contains(channel) && channel.isWithin(getMinFrequency(), getMaxFrequency()))
channel.isWithin( getMinFrequency(), getMaxFrequency() ) )
{ {
mVisibleChannels.add(channel); mVisibleChannels.add(channel);
} }
@@ -796,9 +763,7 @@ public class OverlayPanel extends JPanel
{ {
TunerChannel channel = config.getTunerChannel(); TunerChannel channel = config.getTunerChannel();
if( channel != null && if(channel != null && channel.getMinFrequency() <= frequency && channel.getMaxFrequency() >= frequency)
channel.getMinFrequency() <= frequency &&
channel.getMaxFrequency() >= frequency )
{ {
configs.add(config); configs.add(config);
} }
@@ -808,7 +773,8 @@ public class OverlayPanel extends JPanel
} }
@Override @Override
public void settingDeleted( Setting setting ) { /* not implemented */ } public void settingDeleted(Setting setting)
{ /* not implemented */ }
/** /**
* Calculates correct spacing and format for frequency labels and major/minor * Calculates correct spacing and format for frequency labels and major/minor
@@ -858,9 +824,7 @@ public class OverlayPanel extends JPanel
int maxLabelWidth = fontMetrics.stringWidth(format(getMaxDisplayFrequency())); int maxLabelWidth = fontMetrics.stringWidth(format(getMaxDisplayFrequency()));
double maxLabels = ( (double)OverlayPanel.this.getWidth() * double maxLabels = ((double)OverlayPanel.this.getWidth() * LABEL_FILL_THRESHOLD) / (double)maxLabelWidth;
LABEL_FILL_THRESHOLD ) /
(double)maxLabelWidth;
//Calculate the next smallest base 10 value for the major increment //Calculate the next smallest base 10 value for the major increment
int power = (int)Math.log10((double)getDisplayBandwidth() / maxLabels); int power = (int)Math.log10((double)getDisplayBandwidth() / maxLabels);
@@ -874,9 +838,7 @@ public class OverlayPanel extends JPanel
int labelIncrement = start; int labelIncrement = start;
while( ( (double)getDisplayBandwidth() / while(((double)getDisplayBandwidth() / (double)labelIncrement) < maxLabels && labelIncrement >= minimum)
(double)labelIncrement ) < maxLabels &&
labelIncrement >= minimum )
{ {
labelIncrement /= 2; labelIncrement /= 2;
precision++; precision++;
@@ -930,9 +892,17 @@ public class OverlayPanel extends JPanel
update(); update();
} }
public void componentHidden( ComponentEvent arg0 ) {} public void componentHidden(ComponentEvent arg0)
public void componentMoved( ComponentEvent arg0 ) {} {
public void componentShown( ComponentEvent arg0 ) {} }
public void componentMoved(ComponentEvent arg0)
{
}
public void componentShown(ComponentEvent arg0)
{
}
} }

View File

@@ -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,55 +14,43 @@
* *
* 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 spectrum; package spectrum;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.geom.GeneralPath;
import java.awt.geom.Line2D;
import java.util.Arrays;
import javax.swing.JPanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import settings.ColorSetting;
import settings.ColorSetting.ColorSettingName;
import settings.Setting;
import settings.SettingChangeListener;
import settings.SettingsManager;
import dsp.filter.smoothing.GaussianSmoothingFilter; import dsp.filter.smoothing.GaussianSmoothingFilter;
import dsp.filter.smoothing.NoSmoothingFilter; import dsp.filter.smoothing.NoSmoothingFilter;
import dsp.filter.smoothing.RectangularSmoothingFilter; import dsp.filter.smoothing.RectangularSmoothingFilter;
import dsp.filter.smoothing.SmoothingFilter; import dsp.filter.smoothing.SmoothingFilter;
import dsp.filter.smoothing.SmoothingFilter.SmoothingType; import dsp.filter.smoothing.SmoothingFilter.SmoothingType;
import dsp.filter.smoothing.TriangularSmoothingFilter; import dsp.filter.smoothing.TriangularSmoothingFilter;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import settings.ColorSetting;
import settings.ColorSetting.ColorSettingName;
import settings.Setting;
import settings.SettingChangeListener;
import settings.SettingsManager;
public class SpectrumPanel extends JPanel import javax.swing.*;
implements DFTResultsListener, import java.awt.*;
SettingChangeListener, import java.awt.geom.GeneralPath;
SpectralDisplayAdjuster import java.awt.geom.Line2D;
import java.util.Arrays;
public class SpectrumPanel extends JPanel implements DFTResultsListener, SettingChangeListener, SpectralDisplayAdjuster
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final static Logger mLog = private final static Logger mLog = LoggerFactory.getLogger(SpectrumPanel.class);
LoggerFactory.getLogger( SpectrumPanel.class );
private static final RenderingHints RENDERING_HINTS = private static final RenderingHints RENDERING_HINTS =
new RenderingHints( RenderingHints.KEY_ANTIALIASING, new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
RenderingHints.VALUE_ANTIALIAS_ON );
static static
{ {
RENDERING_HINTS.put( RenderingHints.KEY_RENDERING, RENDERING_HINTS.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
RenderingHints.VALUE_RENDER_QUALITY );
} }
private Color mColorSpectrumBackground; private Color mColorSpectrumBackground;
@@ -86,7 +74,8 @@ public class SpectrumPanel extends JPanel
private float mDBScale; private float mDBScale;
private int mZoom = 0; private int mZoom = 0;
private int mZoomWindowOffset = 0;; private int mZoomWindowOffset = 0;
;
private SettingsManager mSettingsManager; private SettingsManager mSettingsManager;
@@ -277,12 +266,13 @@ public class SpectrumPanel extends JPanel
* 3 8x Zoom * 3 8x Zoom
* 4 16x Zoom * 4 16x Zoom
* 5 32x Zoom * 5 32x Zoom
* 6 64x Zoom
* *
* @param zoom level, 0 - 5. * @param zoom level, 0 - 6.
*/ */
public void setZoom(int zoom) public void setZoom(int zoom)
{ {
assert( 0 <= zoom && zoom <= 5 ); Validate.isTrue(0 <= zoom && zoom <= 6, "Unrecognized Zoom Level: " + zoom);
mZoom = zoom; mZoom = zoom;
} }
@@ -305,7 +295,7 @@ public class SpectrumPanel extends JPanel
*/ */
public void setSampleSize(double sampleSize) public void setSampleSize(double sampleSize)
{ {
assert( 2.0 <= sampleSize && sampleSize <= 32.0 ); Validate.isTrue(2.0 <= sampleSize && sampleSize <= 32.0);
mDBScale = (float)(20.0 * Math.log10(Math.pow(2.0, sampleSize - 1))); mDBScale = (float)(20.0 * Math.log10(Math.pow(2.0, sampleSize - 1)));
} }
@@ -426,7 +416,8 @@ public class SpectrumPanel extends JPanel
} }
@Override @Override
public void settingDeleted( Setting setting ) { /* not implemented */ } public void settingDeleted(Setting setting)
{ /* not implemented */ }
/** /**
* Returns the current inter-bin smoothing setting * Returns the current inter-bin smoothing setting

View File

@@ -18,6 +18,8 @@
******************************************************************************/ ******************************************************************************/
package util; package util;
import org.apache.commons.lang3.Validate;
import java.util.Arrays; import java.util.Arrays;
public class XTEA public class XTEA
@@ -58,7 +60,7 @@ public class XTEA
*/ */
public void setKey(byte[] key) public void setKey(byte[] key)
{ {
assert(key.length == 16); Validate.isTrue(key.length == 16);
int keyInts[] = new int[8]; int keyInts[] = new int[8];
@@ -94,7 +96,7 @@ public class XTEA
*/ */
public byte[] encrypt(byte[] plainText) public byte[] encrypt(byte[] plainText)
{ {
assert(plainText.length == 8); Validate.isTrue(plainText.length == 8);
//Convert the 8 bytes of plaintext to 2 integers //Convert the 8 bytes of plaintext to 2 integers
int result0 = (plainText[3] << 0) & MASK0 | (plainText[2] << 8) & MASK1 | int result0 = (plainText[3] << 0) & MASK0 | (plainText[2] << 8) & MASK1 |