mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-10 23:57:25 -05:00
Compare commits
14 Commits
v0.5.0-bet
...
v0.5.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f67f90e8b0 | ||
|
|
5751c70212 | ||
|
|
4e15c426a8 | ||
|
|
ceda189260 | ||
|
|
fce0ae33e7 | ||
|
|
fc5c6ef841 | ||
|
|
d0033578d5 | ||
|
|
670ec3a097 | ||
|
|
8bfb1d5470 | ||
|
|
46a916a945 | ||
|
|
459e77390a | ||
|
|
f4ab46b79d | ||
|
|
3c58e98788 | ||
|
|
36de81248c |
5
.idea/misc.xml
generated
5
.idea/misc.xml
generated
@@ -1,7 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="liberica-17.0.2-fx" project-jdk-type="JavaSDK">
|
||||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="liberica-18.0.1-fx" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -28,7 +28,7 @@ repositories {
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
|
||||
version = '0.5.0-beta3'
|
||||
version = '0.5.0'
|
||||
sourceCompatibility = '17'
|
||||
|
||||
sourceSets {
|
||||
@@ -86,7 +86,7 @@ dependencies {
|
||||
implementation 'org.usb4java:libusb4java:1.3.0'
|
||||
implementation 'org.usb4java:usb4java:1.3.0'
|
||||
implementation 'org.usb4java:usb4java-javax:1.3.0'
|
||||
implementation 'io.github.dsheirer:libusb4java-darwin-aarch64:1.3.0' //usb4java native lib for OSX M1 cpu
|
||||
implementation 'io.github.dsheirer:libusb4java-darwin-aarch64:1.3.1' //usb4java native lib for OSX M1 cpu
|
||||
implementation 'pl.edu.icm:JLargeArrays:1.6'
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,8 @@ import io.github.dsheirer.audio.broadcast.shoutcast.v1.ShoutcastV1AudioBroadcast
|
||||
import io.github.dsheirer.audio.broadcast.shoutcast.v1.ShoutcastV1Configuration;
|
||||
import io.github.dsheirer.audio.broadcast.shoutcast.v2.ShoutcastV2AudioStreamingBroadcaster;
|
||||
import io.github.dsheirer.audio.broadcast.shoutcast.v2.ShoutcastV2Configuration;
|
||||
import io.github.dsheirer.audio.convert.IAudioConverter;
|
||||
import io.github.dsheirer.audio.convert.ISilenceGenerator;
|
||||
import io.github.dsheirer.audio.convert.InputAudioFormat;
|
||||
import io.github.dsheirer.audio.convert.MP3AudioConverter;
|
||||
import io.github.dsheirer.audio.convert.MP3Setting;
|
||||
import io.github.dsheirer.audio.convert.MP3SilenceGenerator;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
@@ -88,26 +86,6 @@ public class BroadcastFactory
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an audio convert to convert from 8 kHz PCM audio to the specified format
|
||||
*
|
||||
* @param configuration containing the requested output audio format
|
||||
* @return audio convert or null
|
||||
*/
|
||||
public static IAudioConverter getAudioConverter(BroadcastConfiguration configuration, InputAudioFormat inputAudioFormat,
|
||||
MP3Setting mp3Setting)
|
||||
{
|
||||
switch(configuration.getBroadcastFormat())
|
||||
{
|
||||
case MP3:
|
||||
return new MP3AudioConverter(inputAudioFormat, mp3Setting);
|
||||
default:
|
||||
mLog.info("Unrecognized broadcastAudio format: " + configuration.getBroadcastFormat().name());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a broadcastAudio configuration for the specified server type and format
|
||||
*
|
||||
|
||||
@@ -447,28 +447,20 @@ public class BroadcastifyCallBroadcaster extends AbstractAudioBroadcaster<Broadc
|
||||
*/
|
||||
private static String getTo(AudioRecording audioRecording)
|
||||
{
|
||||
List<Identifier> toIdentifiers = audioRecording.getIdentifierCollection().getIdentifiers(Role.TO);
|
||||
Identifier identifier = audioRecording.getIdentifierCollection().getToIdentifier();
|
||||
|
||||
//Format a patch group first, if there are multiples
|
||||
for(Identifier identifier: toIdentifiers)
|
||||
if(identifier instanceof PatchGroupIdentifier patchGroupIdentifier)
|
||||
{
|
||||
if(identifier instanceof PatchGroupIdentifier patchGroupIdentifier)
|
||||
{
|
||||
return format(patchGroupIdentifier);
|
||||
}
|
||||
return format(patchGroupIdentifier);
|
||||
}
|
||||
|
||||
for(Identifier identifier: toIdentifiers)
|
||||
else if(identifier instanceof TalkgroupIdentifier talkgroupIdentifier)
|
||||
{
|
||||
if(identifier instanceof TalkgroupIdentifier talkgroupIdentifier)
|
||||
{
|
||||
return String.valueOf(RadioReferenceDecoder.convertToRadioReferenceTalkgroup(talkgroupIdentifier.getValue(),
|
||||
talkgroupIdentifier.getProtocol()));
|
||||
}
|
||||
else if(identifier instanceof RadioIdentifier radioIdentifier)
|
||||
{
|
||||
return radioIdentifier.getValue().toString();
|
||||
}
|
||||
return String.valueOf(RadioReferenceDecoder.convertToRadioReferenceTalkgroup(talkgroupIdentifier.getValue(),
|
||||
talkgroupIdentifier.getProtocol()));
|
||||
}
|
||||
else if(identifier instanceof RadioIdentifier radioIdentifier)
|
||||
{
|
||||
return radioIdentifier.getValue().toString();
|
||||
}
|
||||
|
||||
return "0";
|
||||
|
||||
@@ -21,17 +21,16 @@ package io.github.dsheirer.audio.convert;
|
||||
import io.github.dsheirer.audio.AudioUtils;
|
||||
import io.github.dsheirer.dsp.filter.resample.RealResampler;
|
||||
import io.github.dsheirer.sample.ConversionUtils;
|
||||
import net.sourceforge.lame.lowlevel.LameEncoder;
|
||||
import net.sourceforge.lame.mp3.Lame;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.sourceforge.lame.lowlevel.LameEncoder;
|
||||
import net.sourceforge.lame.mp3.Lame;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Converts PCM audio packets to Mono, MP3 encoded audio
|
||||
@@ -46,16 +45,20 @@ public class MP3AudioConverter implements IAudioConverter
|
||||
private byte[] mOutputFramesBuffer;
|
||||
private InputAudioFormat mInputAudioFormat;
|
||||
|
||||
private boolean mNormalizeAudio;
|
||||
|
||||
/**
|
||||
* Constructs an instance.
|
||||
*
|
||||
* @param inputAudioFormat for the desired input sample rate and bit size (resampled from default 8 kHz as needed)
|
||||
* @param setting to configure the LAME encoder
|
||||
* @param normalizeAudio to normalize the audio gain prior to encoding
|
||||
*/
|
||||
public MP3AudioConverter(InputAudioFormat inputAudioFormat, MP3Setting setting)
|
||||
public MP3AudioConverter(InputAudioFormat inputAudioFormat, MP3Setting setting, boolean normalizeAudio)
|
||||
{
|
||||
mInputAudioFormat = inputAudioFormat;
|
||||
mEncoder = LameFactory.getLameEncoder(inputAudioFormat, setting);
|
||||
mNormalizeAudio = normalizeAudio;
|
||||
|
||||
//Resampling is only required if desired input sample rate is not system default of 8kHz
|
||||
if(inputAudioFormat != InputAudioFormat.SR_8000 && inputAudioFormat != InputAudioFormat.SR_32_8000)
|
||||
@@ -74,7 +77,11 @@ public class MP3AudioConverter implements IAudioConverter
|
||||
public List<byte[]> convert(List<float[]> audioPackets)
|
||||
{
|
||||
List<byte[]> converted = new ArrayList<>();
|
||||
audioPackets = AudioUtils.normalize(audioPackets);
|
||||
|
||||
if(mNormalizeAudio)
|
||||
{
|
||||
audioPackets = AudioUtils.normalize(audioPackets);
|
||||
}
|
||||
|
||||
if(mResampler != null)
|
||||
{
|
||||
|
||||
@@ -18,11 +18,10 @@
|
||||
*/
|
||||
package io.github.dsheirer.audio.convert;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class MP3SilenceGenerator implements ISilenceGenerator
|
||||
{
|
||||
@@ -40,7 +39,7 @@ public class MP3SilenceGenerator implements ISilenceGenerator
|
||||
public MP3SilenceGenerator(InputAudioFormat inputAudioFormat, MP3Setting setting)
|
||||
{
|
||||
mInputAudioFormat = inputAudioFormat;
|
||||
mMP3AudioConverter = new MP3AudioConverter(inputAudioFormat, setting);
|
||||
mMP3AudioConverter = new MP3AudioConverter(inputAudioFormat, setting, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.github.dsheirer.channel.metadata.ChannelAndMetadata;
|
||||
import io.github.dsheirer.channel.metadata.ChannelMetadata;
|
||||
import io.github.dsheirer.channel.metadata.ChannelMetadataModel;
|
||||
import io.github.dsheirer.controller.channel.event.ChannelStartProcessingRequest;
|
||||
import io.github.dsheirer.controller.channel.event.ChannelStopProcessingRequest;
|
||||
import io.github.dsheirer.controller.channel.event.PreloadDataContent;
|
||||
import io.github.dsheirer.controller.channel.map.ChannelMapModel;
|
||||
import io.github.dsheirer.identifier.Form;
|
||||
@@ -46,12 +47,9 @@ import io.github.dsheirer.source.SourceEvent;
|
||||
import io.github.dsheirer.source.SourceException;
|
||||
import io.github.dsheirer.source.config.SourceConfigTuner;
|
||||
import io.github.dsheirer.source.config.SourceConfigTunerMultipleFrequency;
|
||||
import io.github.dsheirer.source.tuner.channel.TunerChannelSource;
|
||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||
import io.github.dsheirer.util.ThreadPool;
|
||||
import javafx.application.Platform;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -62,6 +60,9 @@ import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import javafx.application.Platform;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Channel processing manager handles all starting and stopping of channel decoding. A processing chain is created
|
||||
@@ -124,7 +125,20 @@ public class ChannelProcessingManager implements Listener<ChannelEvent>
|
||||
*/
|
||||
private boolean isProcessing(Channel channel)
|
||||
{
|
||||
return mProcessingChains.containsKey(channel) && mProcessingChains.get(channel).isProcessing();
|
||||
boolean isProcessing = false;
|
||||
|
||||
mLock.lock();
|
||||
|
||||
try
|
||||
{
|
||||
isProcessing = mProcessingChains.containsKey(channel) && mProcessingChains.get(channel).isProcessing();
|
||||
}
|
||||
finally
|
||||
{
|
||||
mLock.unlock();
|
||||
}
|
||||
|
||||
return isProcessing;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,18 +167,60 @@ public class ChannelProcessingManager implements Listener<ChannelEvent>
|
||||
*/
|
||||
public Channel getChannel(ProcessingChain processingChain)
|
||||
{
|
||||
Channel channel = null;
|
||||
|
||||
if(processingChain != null)
|
||||
{
|
||||
for(Map.Entry<Channel,ProcessingChain> entry : mProcessingChains.entrySet())
|
||||
mLock.lock();
|
||||
|
||||
try
|
||||
{
|
||||
if(entry.getValue() == processingChain)
|
||||
for(Map.Entry<Channel,ProcessingChain> entry : mProcessingChains.entrySet())
|
||||
{
|
||||
return entry.getKey();
|
||||
if(entry.getValue() == processingChain)
|
||||
{
|
||||
channel = entry.getKey();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
mLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the channel associated with the processing chain that is consuming from the tuner channel source
|
||||
* @param tunerChannelSource to find the channel
|
||||
* @return channel
|
||||
*/
|
||||
private Channel getChannel(TunerChannelSource tunerChannelSource)
|
||||
{
|
||||
Channel channel = null;
|
||||
|
||||
mLock.lock();
|
||||
|
||||
try
|
||||
{
|
||||
for(Map.Entry<Channel,ProcessingChain> entry : mProcessingChains.entrySet())
|
||||
{
|
||||
if(entry.getValue().hasSource(tunerChannelSource))
|
||||
{
|
||||
channel = entry.getKey();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
mLock.unlock();
|
||||
}
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,6 +329,28 @@ public class ChannelProcessingManager implements Listener<ChannelEvent>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to stop a channel that is currently processing
|
||||
* @param request with the tuner channel source feeding the channel to be stopped.
|
||||
*/
|
||||
@Subscribe
|
||||
public void stopChannelRequest(ChannelStopProcessingRequest request)
|
||||
{
|
||||
Channel channel = getChannel(request.getTunerChannelSource());
|
||||
|
||||
if(channel != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
stop(channel);
|
||||
}
|
||||
catch(ChannelException ce)
|
||||
{
|
||||
mLog.error("Error stopping channel [" + channel + "]", ce);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the specified channel
|
||||
* @param channel to stop
|
||||
@@ -720,9 +798,7 @@ public class ChannelProcessingManager implements Listener<ChannelEvent>
|
||||
{
|
||||
@Override public void receive(SourceEvent sourceEvent)
|
||||
{
|
||||
if((sourceEvent.getEvent() == SourceEvent.Event.NOTIFICATION_ERROR_STATE ||
|
||||
sourceEvent.getEvent() == SourceEvent.Event.NOTIFICATION_TUNER_SHUTDOWN) &&
|
||||
sourceEvent.getSource() != null)
|
||||
if(sourceEvent.getEvent() == SourceEvent.Event.NOTIFICATION_ERROR_STATE && sourceEvent.getSource() != null)
|
||||
{
|
||||
Channel toShutdown = null;
|
||||
|
||||
@@ -750,10 +826,6 @@ public class ChannelProcessingManager implements Listener<ChannelEvent>
|
||||
{
|
||||
mLog.warn("Channel source error detected - stopping channel [" + toShutdown.getName() + "]");
|
||||
}
|
||||
else if(sourceEvent.getEvent() == SourceEvent.Event.NOTIFICATION_TUNER_SHUTDOWN)
|
||||
{
|
||||
mLog.warn("Tuner removal detected - stopping channel [" + toShutdown.getName() + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
mLog.warn("Source event error - stopping channel [" + toShutdown.getName() + "]");
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2022 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 io.github.dsheirer.controller.channel.event;
|
||||
|
||||
import io.github.dsheirer.module.ModuleEventBusMessage;
|
||||
import io.github.dsheirer.source.tuner.channel.TunerChannelSource;
|
||||
|
||||
/**
|
||||
* Request to stop processing a channel for a specific tuner channel source
|
||||
*/
|
||||
public class ChannelStopProcessingRequest extends ModuleEventBusMessage
|
||||
{
|
||||
private TunerChannelSource mTunerChannelSource;
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param tunerChannelSource for the channel to stop
|
||||
*/
|
||||
public ChannelStopProcessingRequest(TunerChannelSource tunerChannelSource)
|
||||
{
|
||||
mTunerChannelSource = tunerChannelSource;
|
||||
}
|
||||
|
||||
public TunerChannelSource getTunerChannelSource()
|
||||
{
|
||||
return mTunerChannelSource;
|
||||
}
|
||||
}
|
||||
@@ -21,11 +21,13 @@ package io.github.dsheirer.dsp.filter.channelizer;
|
||||
import io.github.dsheirer.buffer.INativeBuffer;
|
||||
import io.github.dsheirer.buffer.INativeBufferProvider;
|
||||
import io.github.dsheirer.buffer.NativeBufferPoisonPill;
|
||||
import io.github.dsheirer.controller.channel.event.ChannelStopProcessingRequest;
|
||||
import io.github.dsheirer.dsp.filter.FilterFactory;
|
||||
import io.github.dsheirer.dsp.filter.channelizer.output.IPolyphaseChannelOutputProcessor;
|
||||
import io.github.dsheirer.dsp.filter.channelizer.output.OneChannelOutputProcessor;
|
||||
import io.github.dsheirer.dsp.filter.channelizer.output.TwoChannelOutputProcessor;
|
||||
import io.github.dsheirer.dsp.filter.design.FilterDesignException;
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.sample.Broadcaster;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.sample.complex.InterleavedComplexSamples;
|
||||
@@ -37,10 +39,6 @@ import io.github.dsheirer.source.tuner.TunerController;
|
||||
import io.github.dsheirer.source.tuner.channel.TunerChannel;
|
||||
import io.github.dsheirer.source.tuner.channel.TunerChannelSource;
|
||||
import io.github.dsheirer.util.Dispatcher;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -51,6 +49,9 @@ import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Polyphase Channel Manager is a DDC channel manager and complex buffer queue/processor for a tuner. This class
|
||||
@@ -136,14 +137,7 @@ public class PolyphaseChannelManager implements ISourceEventProcessor
|
||||
|
||||
for(TunerChannelSource tunerChannelSource: toStop)
|
||||
{
|
||||
try
|
||||
{
|
||||
tunerChannelSource.process(SourceEvent.tunerShutdown(tunerChannelSource));
|
||||
}
|
||||
catch(SourceException se)
|
||||
{
|
||||
mLog.error("Error stopping tuner channel source for tuner shutdown");
|
||||
}
|
||||
MyEventBus.getGlobalEventBus().post(new ChannelStopProcessingRequest(tunerChannelSource));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.preference.mp3.MP3Preference;
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.GridPane;
|
||||
@@ -44,7 +45,12 @@ public class MP3PreferenceEditor extends HBox
|
||||
private GridPane mEditorPane;
|
||||
private ComboBox<MP3Setting> mMP3SettingComboBox;
|
||||
private ComboBox<InputAudioFormat> mAudioSampleRateComboBox;
|
||||
private CheckBox mNormalizeAudioCheckBox;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param userPreferences
|
||||
*/
|
||||
public MP3PreferenceEditor(UserPreferences userPreferences)
|
||||
{
|
||||
mMP3Preference = userPreferences.getMP3Preference();
|
||||
@@ -65,6 +71,9 @@ public class MP3PreferenceEditor extends HBox
|
||||
Label topLabel = new Label("MP3 Encoder Preferences");
|
||||
mEditorPane.add(topLabel, 0, row++, 2, 1);
|
||||
|
||||
|
||||
mEditorPane.add(getNormalizeAudioCheckBox(), 1, row++);
|
||||
|
||||
Label label = new Label("(LAME) Encoder Setting:");
|
||||
GridPane.setHalignment(label, HPos.RIGHT);
|
||||
mEditorPane.add(label, 0, row);
|
||||
@@ -76,7 +85,7 @@ public class MP3PreferenceEditor extends HBox
|
||||
mEditorPane.add(getAudioSampleRateComboBox(), 1, row++);
|
||||
|
||||
Label notice = new Label("Note: sdrtrunk default 8 kHz audio rate is resampled to input sample rate before MP3 encoding");
|
||||
mEditorPane.add(notice, 0, row, 2, 1);
|
||||
mEditorPane.add(notice, 0, row++, 2, 1);
|
||||
}
|
||||
|
||||
return mEditorPane;
|
||||
@@ -109,4 +118,17 @@ public class MP3PreferenceEditor extends HBox
|
||||
|
||||
return mAudioSampleRateComboBox;
|
||||
}
|
||||
|
||||
private CheckBox getNormalizeAudioCheckBox()
|
||||
{
|
||||
if(mNormalizeAudioCheckBox == null)
|
||||
{
|
||||
mNormalizeAudioCheckBox = new CheckBox("Normalize Audio Before Encoding");
|
||||
mNormalizeAudioCheckBox.setSelected(mMP3Preference.isNormalizeAudioBeforeEncode());
|
||||
mNormalizeAudioCheckBox.onActionProperty().set(event ->
|
||||
mMP3Preference.setNormalizeAudioBeforeEncode(getNormalizeAudioCheckBox().isSelected()));
|
||||
}
|
||||
|
||||
return mNormalizeAudioCheckBox;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,12 @@ import io.github.dsheirer.jmbe.github.Release;
|
||||
import io.github.dsheirer.util.FileUtil;
|
||||
import io.github.dsheirer.util.OSType;
|
||||
import io.github.dsheirer.util.ThreadPool;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
@@ -37,13 +43,6 @@ import org.rauschig.jarchivelib.ArchiverFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* Creates the JMBE library by downloading the JMBE Creator CLI application from GitHub and executing it.
|
||||
*/
|
||||
@@ -147,7 +146,7 @@ public class JmbeCreator
|
||||
|
||||
OSType osType = OSType.getCurrentOSType();
|
||||
|
||||
if(osType.isLinux())
|
||||
if(osType.isLinux() || osType.isOsx())
|
||||
{
|
||||
script = FileUtil.findFile(unzipped, CREATOR_SCRIPT_LINUX);
|
||||
}
|
||||
@@ -156,6 +155,7 @@ public class JmbeCreator
|
||||
script = FileUtil.findFile(unzipped, CREATOR_SCRIPT_WINDOWS);
|
||||
}
|
||||
|
||||
|
||||
if(script != null)
|
||||
{
|
||||
ProcessBuilder processBuilder = new ProcessBuilder();
|
||||
|
||||
@@ -32,6 +32,7 @@ import io.github.dsheirer.controller.channel.ChannelModel;
|
||||
import io.github.dsheirer.controller.channel.ChannelProcessingManager;
|
||||
import io.github.dsheirer.controller.channel.map.ChannelMap;
|
||||
import io.github.dsheirer.controller.channel.map.ChannelMapModel;
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.icon.IconModel;
|
||||
import io.github.dsheirer.module.log.EventLogManager;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
@@ -40,10 +41,6 @@ import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.service.radioreference.RadioReference;
|
||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||
import io.github.dsheirer.util.ThreadPool;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -54,6 +51,9 @@ import java.util.ArrayList;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Manages all aspects of playlists and related models
|
||||
@@ -104,6 +104,11 @@ public class PlaylistManager implements Listener<ChannelEvent>
|
||||
mChannelModel = new ChannelModel(mAliasModel);
|
||||
mChannelProcessingManager = new ChannelProcessingManager(mChannelMapModel, eventLogManager, mTunerManager,
|
||||
mAliasModel, mUserPreferences);
|
||||
|
||||
//Register the channel processing manager to receive global channel stop processing requests so that it can
|
||||
//respond to tuner shutdown (ie error) events
|
||||
MyEventBus.getGlobalEventBus().register(mChannelProcessingManager);
|
||||
|
||||
mChannelModel.addListener(mChannelProcessingManager);
|
||||
mChannelProcessingManager.addChannelEventListener(mChannelModel);
|
||||
|
||||
|
||||
@@ -24,11 +24,10 @@ import io.github.dsheirer.audio.convert.MP3Setting;
|
||||
import io.github.dsheirer.preference.Preference;
|
||||
import io.github.dsheirer.preference.PreferenceType;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import java.util.prefs.Preferences;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* User preferences for playlists
|
||||
*/
|
||||
@@ -36,11 +35,14 @@ public class MP3Preference extends Preference
|
||||
{
|
||||
private static final String PREFERENCE_KEY_AUDIO_MP3_SETTING = "audio.mp3.setting";
|
||||
private static final String PREFERENCE_KEY_AUDIO_MP3_SAMPLE_RATE = "audio.mp3.sample.rate";
|
||||
private static final String PREFERENCE_KEY_AUDIO_MP3_NORMALIZE_BEFORE_ENCODE = "audio.mp3.normalize.before.encode";
|
||||
private final static Logger mLog = LoggerFactory.getLogger(MP3Preference.class);
|
||||
private Preferences mPreferences = Preferences.userNodeForPackage(MP3Preference.class);
|
||||
private InputAudioFormat mInputAudioFormat;
|
||||
private MP3Setting mMP3Setting;
|
||||
|
||||
private Boolean mNormalizeAudio;
|
||||
|
||||
/**
|
||||
* Constructs this preference with an update listener
|
||||
* @param updateListener to receive notifications whenever these preferences change
|
||||
@@ -128,4 +130,29 @@ public class MP3Preference extends Preference
|
||||
mPreferences.put(PREFERENCE_KEY_AUDIO_MP3_SAMPLE_RATE, mInputAudioFormat.name());
|
||||
notifyPreferenceUpdated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the user prefers to normalize audio before encoding to MP3
|
||||
* @return true to normalize
|
||||
*/
|
||||
public boolean isNormalizeAudioBeforeEncode()
|
||||
{
|
||||
if(mNormalizeAudio == null)
|
||||
{
|
||||
mNormalizeAudio = mPreferences.getBoolean(PREFERENCE_KEY_AUDIO_MP3_NORMALIZE_BEFORE_ENCODE, false);
|
||||
}
|
||||
|
||||
return mNormalizeAudio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the preferenced to normalize audio before encoding to MP3.
|
||||
* @param normalizeAudio true to normalize
|
||||
*/
|
||||
public void setNormalizeAudioBeforeEncode(boolean normalizeAudio)
|
||||
{
|
||||
mNormalizeAudio = normalizeAudio;
|
||||
mPreferences.putBoolean(PREFERENCE_KEY_AUDIO_MP3_NORMALIZE_BEFORE_ENCODE, normalizeAudio);
|
||||
notifyPreferenceUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,6 @@ import io.github.dsheirer.record.wave.AudioMetadata;
|
||||
import io.github.dsheirer.record.wave.AudioMetadataUtils;
|
||||
import io.github.dsheirer.record.wave.WaveWriter;
|
||||
import io.github.dsheirer.sample.ConversionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@@ -39,6 +36,8 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Recording utility for audio segments
|
||||
@@ -96,7 +95,9 @@ public class AudioSegmentRecorder
|
||||
InputAudioFormat inputAudioFormat = userPreferences.getMP3Preference().getAudioSampleRate();
|
||||
MP3Setting mp3Setting = userPreferences.getMP3Preference().getMP3Setting();
|
||||
|
||||
MP3AudioConverter converter = new MP3AudioConverter(inputAudioFormat, mp3Setting);
|
||||
boolean normalizeAudio = userPreferences.getMP3Preference().isNormalizeAudioBeforeEncode();
|
||||
|
||||
MP3AudioConverter converter = new MP3AudioConverter(inputAudioFormat, mp3Setting, normalizeAudio);
|
||||
List<byte[]> mp3Frames = converter.convert(audioSegment.getAudioBuffers());
|
||||
for(byte[] mp3Frame: mp3Frames)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2019 Dennis Sheirer
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2022 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
|
||||
@@ -15,17 +14,16 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
* ****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.sample;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Broadcasts an item to multiple listeners
|
||||
@@ -33,7 +31,6 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
public class Broadcaster<T> implements Listener<T>
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(Broadcaster.class);
|
||||
private boolean mDebug;
|
||||
private ReentrantLock mLock = new ReentrantLock();
|
||||
private List<Listener<T>> mListeners = new ArrayList<>();
|
||||
|
||||
@@ -41,14 +38,6 @@ public class Broadcaster<T> implements Listener<T>
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on/off debugging to troubleshoot and log which listeners are receiving an item.
|
||||
*/
|
||||
public void setDebug(boolean debug)
|
||||
{
|
||||
mDebug = debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the Listener<T> interface to receive an element and broadcast that element to all registered
|
||||
* listeners.
|
||||
@@ -66,16 +55,7 @@ public class Broadcaster<T> implements Listener<T>
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
mLock.lock();
|
||||
|
||||
try
|
||||
{
|
||||
mListeners.clear();
|
||||
}
|
||||
finally
|
||||
{
|
||||
mLock.unlock();
|
||||
}
|
||||
clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,16 +132,7 @@ public class Broadcaster<T> implements Listener<T>
|
||||
*/
|
||||
public void clear()
|
||||
{
|
||||
mLock.lock();
|
||||
|
||||
try
|
||||
{
|
||||
mListeners.clear();
|
||||
}
|
||||
finally
|
||||
{
|
||||
mLock.unlock();
|
||||
}
|
||||
mListeners.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,21 +144,11 @@ public class Broadcaster<T> implements Listener<T>
|
||||
|
||||
try
|
||||
{
|
||||
if(mDebug)
|
||||
List<Listener<T>> listeners = new ArrayList<>(mListeners);
|
||||
|
||||
for(Listener listener: listeners)
|
||||
{
|
||||
for(Listener<T> listener : mListeners)
|
||||
{
|
||||
mLog.debug("Sending [" + t + "] to listener [" + listener.getClass() + "]");
|
||||
listener.receive(t);
|
||||
mLog.debug("Finished sending to listener [" + listener.getClass() + "]");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(Listener<T> listener : mListeners)
|
||||
{
|
||||
listener.receive(t);
|
||||
}
|
||||
listener.receive(t);
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -18,11 +18,10 @@
|
||||
*/
|
||||
package io.github.dsheirer.source;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class SourceEvent
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(SourceEvent.class);
|
||||
@@ -195,15 +194,6 @@ public class SourceEvent
|
||||
return new SourceEvent(Event.NOTIFICATION_ERROR_STATE, source, errorDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification that a tuner is shutting down and the source is therefore shutting down.
|
||||
* @param source that is shutting down
|
||||
*/
|
||||
public static SourceEvent tunerShutdown(Source source)
|
||||
{
|
||||
return new SourceEvent(Event.NOTIFICATION_TUNER_SHUTDOWN, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new locked state change event
|
||||
*/
|
||||
|
||||
@@ -28,6 +28,7 @@ import io.github.dsheirer.source.tuner.TunerEvent.Event;
|
||||
import io.github.dsheirer.source.tuner.manager.ChannelSourceManager;
|
||||
import io.github.dsheirer.source.tuner.manager.HeterodyneChannelSourceManager;
|
||||
import io.github.dsheirer.source.tuner.manager.PolyphaseChannelSourceManager;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -44,6 +45,7 @@ public abstract class Tuner implements ISourceEventProcessor, ITunerErrorListene
|
||||
private TunerController mTunerController;
|
||||
private TunerFrequencyErrorMonitor mTunerFrequencyErrorMonitor;
|
||||
private ITunerErrorListener mTunerErrorListener;
|
||||
private AtomicBoolean mRunning = new AtomicBoolean();
|
||||
|
||||
public Tuner(TunerController tunerController, ITunerErrorListener tunerErrorListener)
|
||||
{
|
||||
@@ -85,20 +87,25 @@ public abstract class Tuner implements ISourceEventProcessor, ITunerErrorListene
|
||||
*/
|
||||
public void start() throws SourceException
|
||||
{
|
||||
try
|
||||
if(mRunning.compareAndSet(false, true))
|
||||
{
|
||||
getTunerController().start();
|
||||
}
|
||||
catch(SourceException se)
|
||||
{
|
||||
//Rethrow the source exception
|
||||
throw se;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Wrap any other exceptions in a new source exception
|
||||
mLog.error("Error starting " + getTunerClass() + " tuner", e);
|
||||
throw new SourceException("Unable to start " + getTunerClass() + " tuner", e);
|
||||
try
|
||||
{
|
||||
getTunerController().start();
|
||||
}
|
||||
catch(SourceException se)
|
||||
{
|
||||
mRunning.set(false);
|
||||
//Rethrow the source exception
|
||||
throw se;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
mRunning.set(false);
|
||||
//Wrap any other exceptions in a new source exception
|
||||
mLog.error("Error starting " + getTunerClass() + " tuner", e);
|
||||
throw new SourceException("Unable to start " + getTunerClass() + " tuner", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,20 +114,24 @@ public abstract class Tuner implements ISourceEventProcessor, ITunerErrorListene
|
||||
*/
|
||||
public void stop()
|
||||
{
|
||||
if(getChannelSourceManager() != null)
|
||||
if(mRunning.compareAndSet(true, false))
|
||||
{
|
||||
getChannelSourceManager().stopAllChannels();
|
||||
getChannelSourceManager().dispose();
|
||||
mChannelSourceManager = null;
|
||||
broadcast(new TunerEvent(this, Event.NOTIFICATION_SHUTTING_DOWN));
|
||||
|
||||
if(getChannelSourceManager() != null)
|
||||
{
|
||||
getChannelSourceManager().stopAllChannels();
|
||||
getChannelSourceManager().dispose();
|
||||
mChannelSourceManager = null;
|
||||
}
|
||||
|
||||
getTunerController().stop();
|
||||
getTunerController().dispose();
|
||||
|
||||
mTunerEventBroadcaster.clear();
|
||||
mTunerFrequencyErrorMonitor = null;
|
||||
mTunerErrorListener = null;
|
||||
}
|
||||
|
||||
broadcast(new TunerEvent(this, Event.NOTIFICATION_SHUTTING_DOWN));
|
||||
getTunerController().stop();
|
||||
getTunerController().dispose();
|
||||
|
||||
mTunerEventBroadcaster.clear();
|
||||
mTunerFrequencyErrorMonitor = null;
|
||||
mTunerErrorListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -147,7 +147,7 @@ public class TunerFactory
|
||||
case RAFAELMICRO_R820T:
|
||||
return new R820TTunerConfiguration(uniqueID);
|
||||
case RECORDING:
|
||||
return new RecordingTunerConfiguration(uniqueID);
|
||||
return RecordingTunerConfiguration.create();
|
||||
default:
|
||||
throw new IllegalArgumentException("Unrecognized tuner type [" + type.name() + "]");
|
||||
}
|
||||
|
||||
@@ -172,10 +172,6 @@ public abstract class TunerChannelSource extends ComplexSource implements ISourc
|
||||
sourceEvent.setSource(this);
|
||||
broadcastProducerSourceEvent(sourceEvent);
|
||||
break;
|
||||
case NOTIFICATION_TUNER_SHUTDOWN:
|
||||
//Rebroadcast this event so the channel processing manager receives it and shuts down the channel
|
||||
broadcastConsumerSourceEvent(sourceEvent);
|
||||
break;
|
||||
//Request events from the consumer
|
||||
case REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE:
|
||||
setChannelFrequencyCorrection(sourceEvent.getValue().longValue());
|
||||
|
||||
@@ -29,9 +29,6 @@ import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||
import io.github.dsheirer.source.tuner.manager.IDiscoveredTunerStatusListener;
|
||||
import io.github.dsheirer.source.tuner.manager.TunerStatus;
|
||||
import io.github.dsheirer.util.ThreadPool;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@@ -42,6 +39,8 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Manages settings and configurations for all tuner types.
|
||||
@@ -252,7 +251,6 @@ public class TunerConfigurationManager implements IDiscoveredTunerStatusListener
|
||||
*/
|
||||
public void addTunerConfiguration(TunerConfiguration tunerConfiguration)
|
||||
{
|
||||
mLog.info("Adding tuner config: " + tunerConfiguration);
|
||||
if(!mTunerConfigurations.stream().filter(config -> config.getTunerType().equals(tunerConfiguration.getTunerType()) &&
|
||||
config.getUniqueID().equalsIgnoreCase(tunerConfiguration.getUniqueID())).findFirst().isPresent())
|
||||
{
|
||||
@@ -291,6 +289,17 @@ public class TunerConfigurationManager implements IDiscoveredTunerStatusListener
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all tuner configurations that match the specified tuner type.
|
||||
* @param tunerType to match
|
||||
* @return list of all configurations.
|
||||
*/
|
||||
public List<TunerConfiguration> getTunerConfigurations(TunerType tunerType)
|
||||
{
|
||||
return mTunerConfigurations.stream().filter(tunerConfiguration -> tunerConfiguration.getTunerType()
|
||||
.equals(tunerType)).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the current tuner configuration state and resets the save pending flag
|
||||
*/
|
||||
|
||||
@@ -25,8 +25,9 @@ import io.github.dsheirer.source.SourceEvent;
|
||||
import io.github.dsheirer.source.tuner.channel.ChannelSpecification;
|
||||
import io.github.dsheirer.source.tuner.channel.TunerChannel;
|
||||
import io.github.dsheirer.source.tuner.channel.TunerChannelSource;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Interface to define the functionality of a channel source manager for handling tuner channel management and source
|
||||
@@ -34,6 +35,8 @@ import java.util.SortedSet;
|
||||
*/
|
||||
public abstract class ChannelSourceManager implements ISourceEventProcessor
|
||||
{
|
||||
private Logger mLogger = LoggerFactory.getLogger(ChannelSourceManager.class);
|
||||
|
||||
private Broadcaster<SourceEvent> mSourceEventBroadcaster = new Broadcaster<>();
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2022 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 io.github.dsheirer.source.tuner.manager;
|
||||
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.source.SourceException;
|
||||
import io.github.dsheirer.source.tuner.TunerClass;
|
||||
import io.github.dsheirer.source.tuner.recording.RecordingTuner;
|
||||
import io.github.dsheirer.source.tuner.recording.RecordingTunerConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Discovered tuner for recording tuner type.
|
||||
*/
|
||||
public class DiscoveredRecordingTuner extends DiscoveredTuner
|
||||
{
|
||||
private static final Logger mLog = LoggerFactory.getLogger(DiscoveredRecordingTuner.class);
|
||||
private UserPreferences mUserPreferences;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param userPreferences instance
|
||||
* @param recordingTunerConfiguration with recording path and frequency
|
||||
*/
|
||||
public DiscoveredRecordingTuner(UserPreferences userPreferences,
|
||||
RecordingTunerConfiguration recordingTunerConfiguration)
|
||||
{
|
||||
mUserPreferences = userPreferences;
|
||||
setTunerConfiguration(recordingTunerConfiguration);
|
||||
|
||||
//Default all recordings to be disabled on startup
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the tuner configuration as a recording tuner configuration
|
||||
*/
|
||||
public RecordingTunerConfiguration getRecordingTunerConfiguration()
|
||||
{
|
||||
return (RecordingTunerConfiguration) getTunerConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TunerClass getTunerClass()
|
||||
{
|
||||
return TunerClass.RECORDING_TUNER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return getRecordingTunerConfiguration().getPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
if(!hasTuner())
|
||||
{
|
||||
mTuner = new RecordingTuner(mUserPreferences, this, getRecordingTunerConfiguration());
|
||||
|
||||
try
|
||||
{
|
||||
mTuner.start();
|
||||
}
|
||||
catch(SourceException se)
|
||||
{
|
||||
setErrorMessage("Error - " + se.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Recording [" + getRecordingTunerConfiguration().getPath() + "]";
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,9 @@
|
||||
package io.github.dsheirer.source.tuner.manager;
|
||||
|
||||
import io.github.dsheirer.buffer.NativeSampleDelayBuffer;
|
||||
import io.github.dsheirer.controller.channel.event.ChannelStopProcessingRequest;
|
||||
import io.github.dsheirer.dsp.filter.design.FilterDesignException;
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.source.SourceEvent;
|
||||
import io.github.dsheirer.source.SourceException;
|
||||
@@ -28,14 +30,13 @@ import io.github.dsheirer.source.tuner.channel.ChannelSpecification;
|
||||
import io.github.dsheirer.source.tuner.channel.HalfBandTunerChannelSource;
|
||||
import io.github.dsheirer.source.tuner.channel.TunerChannel;
|
||||
import io.github.dsheirer.source.tuner.channel.TunerChannelSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Channel provider for heterodyne and decimate method of channel provisioning.
|
||||
@@ -68,14 +69,7 @@ public class HeterodyneChannelSourceManager extends ChannelSourceManager
|
||||
|
||||
for(TunerChannelSource tunerChannelSource: toStop)
|
||||
{
|
||||
try
|
||||
{
|
||||
tunerChannelSource.process(SourceEvent.tunerShutdown(tunerChannelSource));
|
||||
}
|
||||
catch(SourceException se)
|
||||
{
|
||||
mLog.error("Error stopping tuner channel source for tuner shutdown");
|
||||
}
|
||||
MyEventBus.getGlobalEventBus().post(new ChannelStopProcessingRequest(tunerChannelSource));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,8 +272,6 @@ public class HeterodyneChannelSourceManager extends ChannelSourceManager
|
||||
//The start sample stream request contains a start timestamp and the delay buffer
|
||||
//will preload the channel with delayed sample buffers that either contain the
|
||||
//timestamp or occur later/newer than the timestamp.
|
||||
// mSampleDelayBuffer.addListener((CICTunerChannelSource)sourceEvent.getSource(),
|
||||
// sourceEvent.getValue().longValue());
|
||||
mSampleDelayBuffer.addListener((HalfBandTunerChannelSource)sourceEvent.getSource(),
|
||||
sourceEvent.getValue().longValue());
|
||||
}
|
||||
@@ -287,7 +279,6 @@ public class HeterodyneChannelSourceManager extends ChannelSourceManager
|
||||
case REQUEST_STOP_SAMPLE_STREAM:
|
||||
if(sourceEvent.getSource() instanceof HalfBandTunerChannelSource)
|
||||
{
|
||||
// mSampleDelayBuffer.removeListener((CICTunerChannelSource)sourceEvent.getSource());
|
||||
mSampleDelayBuffer.removeListener((HalfBandTunerChannelSource)sourceEvent.getSource());
|
||||
stopDelayBuffer();
|
||||
}
|
||||
@@ -295,7 +286,6 @@ public class HeterodyneChannelSourceManager extends ChannelSourceManager
|
||||
case REQUEST_SOURCE_DISPOSE:
|
||||
if(sourceEvent.getSource() instanceof HalfBandTunerChannelSource)
|
||||
{
|
||||
// CICTunerChannelSource channelSource = (CICTunerChannelSource)sourceEvent.getSource();
|
||||
HalfBandTunerChannelSource channelSource = (HalfBandTunerChannelSource) sourceEvent.getSource();
|
||||
mChannelSources.remove(channelSource);
|
||||
mTunerChannels.remove(channelSource.getTunerChannel());
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
package io.github.dsheirer.source.tuner.manager;
|
||||
|
||||
import io.github.dsheirer.controller.channel.event.ChannelStopProcessingRequest;
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.source.SourceEvent;
|
||||
import io.github.dsheirer.source.SourceException;
|
||||
@@ -27,14 +29,13 @@ import io.github.dsheirer.source.tuner.channel.ChannelSpecification;
|
||||
import io.github.dsheirer.source.tuner.channel.PassThroughChannelSource;
|
||||
import io.github.dsheirer.source.tuner.channel.TunerChannel;
|
||||
import io.github.dsheirer.source.tuner.channel.TunerChannelSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Pass through source manager for relatively small bandwidth complex streams that don't warrant the overhead of
|
||||
@@ -62,14 +63,7 @@ public class PassThroughSourceManager extends ChannelSourceManager
|
||||
|
||||
for(TunerChannelSource tunerChannelSource: toStop)
|
||||
{
|
||||
try
|
||||
{
|
||||
tunerChannelSource.process(SourceEvent.tunerShutdown(tunerChannelSource));
|
||||
}
|
||||
catch(SourceException se)
|
||||
{
|
||||
mLog.error("Error stopping tuner channel source for tuner shutdown");
|
||||
}
|
||||
MyEventBus.getGlobalEventBus().post(new ChannelStopProcessingRequest(tunerChannelSource));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,16 @@ import io.github.dsheirer.source.tuner.channel.TunerChannel;
|
||||
import io.github.dsheirer.source.tuner.channel.TunerChannelSource;
|
||||
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
|
||||
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationManager;
|
||||
import io.github.dsheirer.source.tuner.recording.RecordingTunerConfiguration;
|
||||
import io.github.dsheirer.source.tuner.ui.DiscoveredTunerModel;
|
||||
import io.github.dsheirer.util.ThreadPool;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.usb4java.Context;
|
||||
@@ -47,14 +55,6 @@ import org.usb4java.HotplugCallback;
|
||||
import org.usb4java.HotplugCallbackHandle;
|
||||
import org.usb4java.LibUsb;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Tuner manager provides access to tuners using USB, recording, sound-card and system-daemon accessible devices. This
|
||||
* manager also supports hot-plug detection and black-listing of discovered tuners so that they can be used with other
|
||||
@@ -90,6 +90,14 @@ public class TunerManager implements IDiscoveredTunerStatusListener
|
||||
return mDiscoveredTunerModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tuner configuration manager
|
||||
*/
|
||||
public TunerConfigurationManager getTunerConfigurationManager()
|
||||
{
|
||||
return mTunerConfigurationManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the tuner manager and loads all available tuners
|
||||
*/
|
||||
@@ -101,13 +109,20 @@ public class TunerManager implements IDiscoveredTunerStatusListener
|
||||
mLog.info("LibUsb API Version: " + ((api >> 24) & 0xFF) + "." + ((api >> 16) & 0xFF) + "." + (api & 0xFFFF));
|
||||
mLog.info("LibUsb Version: " + LibUsb.getVersion());
|
||||
|
||||
int status = LibUsb.init(mLibUsbApplicationContext);
|
||||
|
||||
if(status == LibUsb.SUCCESS)
|
||||
try
|
||||
{
|
||||
mLibUsbInitialized = true;
|
||||
int status = LibUsb.init(mLibUsbApplicationContext);
|
||||
|
||||
if(status == LibUsb.SUCCESS)
|
||||
{
|
||||
mLibUsbInitialized = true;
|
||||
// LibUsb.setOption(mLibUsbApplicationContext, LibUsb.OPTION_LOG_LEVEL, LibUsb.LOG_LEVEL_DEBUG);
|
||||
discoverUSBTuners();
|
||||
discoverUSBTuners();
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
mLog.error("Error initializing LibUsb and usb4java library", e);
|
||||
}
|
||||
|
||||
if(mLibUsbInitialized)
|
||||
@@ -280,7 +295,26 @@ public class TunerManager implements IDiscoveredTunerStatusListener
|
||||
*/
|
||||
private void discoverRecordingTuners()
|
||||
{
|
||||
//placeholder
|
||||
List<TunerConfiguration> tunerConfigurations = getTunerConfigurationManager().getTunerConfigurations(TunerType.RECORDING);
|
||||
|
||||
if(tunerConfigurations.size() > 0)
|
||||
{
|
||||
mLog.info("Discovered [" + tunerConfigurations.size() + "] recording tuners");
|
||||
}
|
||||
|
||||
for(TunerConfiguration tunerConfiguration: tunerConfigurations)
|
||||
{
|
||||
if(tunerConfiguration instanceof RecordingTunerConfiguration recordingTunerConfiguration)
|
||||
{
|
||||
DiscoveredRecordingTuner discoveredRecordingTuner =
|
||||
new DiscoveredRecordingTuner(mUserPreferences, recordingTunerConfiguration);
|
||||
|
||||
discoveredRecordingTuner.addTunerStatusListener(this);
|
||||
discoveredRecordingTuner.setEnabled(false);
|
||||
mLog.info("Tuner Added: " + discoveredRecordingTuner);
|
||||
mDiscoveredTunerModel.addDiscoveredTuner(discoveredRecordingTuner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -305,13 +339,17 @@ public class TunerManager implements IDiscoveredTunerStatusListener
|
||||
{
|
||||
TunerType tunerType = discoveredTuner.getTuner().getTunerType();
|
||||
|
||||
TunerConfiguration tunerConfiguration = mTunerConfigurationManager
|
||||
.getTunerConfiguration(tunerType, discoveredTuner.getId());
|
||||
|
||||
if(tunerConfiguration != null)
|
||||
//Don't fetch or create a configuration for recording tuners
|
||||
if(tunerType != TunerType.RECORDING)
|
||||
{
|
||||
discoveredTuner.setTunerConfiguration(tunerConfiguration);
|
||||
mTunerConfigurationManager.saveConfigurations();
|
||||
TunerConfiguration tunerConfiguration = mTunerConfigurationManager
|
||||
.getTunerConfiguration(tunerType, discoveredTuner.getId());
|
||||
|
||||
if(tunerConfiguration != null)
|
||||
{
|
||||
discoveredTuner.setTunerConfiguration(tunerConfiguration);
|
||||
mTunerConfigurationManager.saveConfigurations();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,15 @@ package io.github.dsheirer.source.tuner.recording;
|
||||
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.properties.SystemProperties;
|
||||
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationManager;
|
||||
import io.github.dsheirer.source.tuner.manager.DiscoveredRecordingTuner;
|
||||
import io.github.dsheirer.source.tuner.ui.DiscoveredTunerModel;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.slf4j.Logger;
|
||||
@@ -35,12 +43,6 @@ import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Dialog to select a recording and specify a center frequency for use in adding a Recording Tuner
|
||||
@@ -52,6 +54,7 @@ public class AddRecordingTunerDialog extends JFrame
|
||||
private static final String LAST_FILE_BROWSE_LOCATION_KEY = "AddRecordingTunerDialog.lastBrowseLocation";
|
||||
private UserPreferences mUserPreferences;
|
||||
private DiscoveredTunerModel mDiscoveredTunerModel;
|
||||
private TunerConfigurationManager mTunerConfigurationManager;
|
||||
private JButton mSelectFileButton;
|
||||
private File mSelectedRecording;
|
||||
private JLabel mRecordingFileLabel;
|
||||
@@ -59,92 +62,91 @@ public class AddRecordingTunerDialog extends JFrame
|
||||
private JTextField mFrequencyTextField;
|
||||
private JButton mAddButton;
|
||||
private JButton mCancelButton;
|
||||
private static final Pattern TUNER_RECORDING_PATTERN = Pattern.compile("TUNER_(\\d*)_baseband_\\d{8}_\\d{6}\\.wav");
|
||||
private static final Pattern TUNER_RECORDING_PATTERN = Pattern.compile(".*_(\\d*)_baseband_\\d{8}_\\d{6}\\.wav");
|
||||
|
||||
public AddRecordingTunerDialog(UserPreferences userPreferences, DiscoveredTunerModel discoveredTunerModel)
|
||||
public AddRecordingTunerDialog(UserPreferences userPreferences, DiscoveredTunerModel discoveredTunerModel,
|
||||
TunerConfigurationManager tunerConfigurationManager)
|
||||
{
|
||||
Validate.notNull(userPreferences, "UserPreferences cannot be null");
|
||||
Validate.notNull(discoveredTunerModel, "TunerModel cannot be null");
|
||||
Validate.notNull(tunerConfigurationManager, "TunerConfigurationManager cannot be null");
|
||||
|
||||
mDiscoveredTunerModel = discoveredTunerModel;
|
||||
mUserPreferences = userPreferences;
|
||||
mTunerConfigurationManager = tunerConfigurationManager;
|
||||
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setTitle("Select Recording File");
|
||||
setSize(new Dimension(500, 250));
|
||||
|
||||
JPanel content = new JPanel();
|
||||
content.setLayout(new MigLayout("", "[align right][][]",
|
||||
"[][][grow][]"));
|
||||
content.setLayout(new MigLayout("", "[align right][][]", "[][][grow][]"));
|
||||
|
||||
mSelectFileButton = new JButton("Select ...");
|
||||
mSelectFileButton.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
mSelectFileButton.addActionListener(e -> {
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
String lastBrowsedDirectory = SystemProperties.getInstance().get(LAST_FILE_BROWSE_LOCATION_KEY, "");
|
||||
|
||||
File browseDirectory;
|
||||
|
||||
if(lastBrowsedDirectory != null && !lastBrowsedDirectory.isEmpty())
|
||||
{
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
String lastBrowsedDirectory = SystemProperties.getInstance().get(LAST_FILE_BROWSE_LOCATION_KEY, "");
|
||||
|
||||
File browseDirectory;
|
||||
|
||||
if(lastBrowsedDirectory != null && !lastBrowsedDirectory.isEmpty())
|
||||
{
|
||||
browseDirectory = new File(lastBrowsedDirectory);
|
||||
}
|
||||
else
|
||||
{
|
||||
browseDirectory = mUserPreferences.getDirectoryPreference().getDefaultRecordingDirectory().toFile();
|
||||
}
|
||||
|
||||
fileChooser.setCurrentDirectory(browseDirectory);
|
||||
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
fileChooser.setFileFilter(new FileFilter()
|
||||
{
|
||||
@Override
|
||||
public boolean accept(File f)
|
||||
{
|
||||
return f.getAbsolutePath().endsWith(".wav") || f.isDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return "Recordings (*.wav)";
|
||||
}
|
||||
});
|
||||
|
||||
int returnVal = fileChooser.showOpenDialog(AddRecordingTunerDialog.this);
|
||||
|
||||
File lastDirectory = fileChooser.getCurrentDirectory();
|
||||
|
||||
if(lastDirectory != null)
|
||||
{
|
||||
SystemProperties.getInstance().set(LAST_FILE_BROWSE_LOCATION_KEY, lastDirectory.getAbsolutePath());
|
||||
}
|
||||
|
||||
if(returnVal == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
mSelectedRecording = fileChooser.getSelectedFile();
|
||||
|
||||
if(mSelectedRecording != null &&
|
||||
(mFrequencyTextField.getText() == null || mFrequencyTextField.getText().isEmpty()))
|
||||
{
|
||||
Matcher m = TUNER_RECORDING_PATTERN.matcher(mSelectedRecording.getName());
|
||||
|
||||
if(m.matches())
|
||||
{
|
||||
mFrequencyTextField.setText(m.group(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mSelectedRecording = null;
|
||||
}
|
||||
|
||||
mRecordingFileLabel.setText(mSelectedRecording != null ? mSelectedRecording.getName() : SELECT_A_FILE);
|
||||
browseDirectory = new File(lastBrowsedDirectory);
|
||||
}
|
||||
else
|
||||
{
|
||||
browseDirectory = mUserPreferences.getDirectoryPreference().getDefaultRecordingDirectory().toFile();
|
||||
}
|
||||
|
||||
fileChooser.setCurrentDirectory(browseDirectory);
|
||||
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
fileChooser.setFileFilter(new FileFilter()
|
||||
{
|
||||
@Override
|
||||
public boolean accept(File f)
|
||||
{
|
||||
return f.getAbsolutePath().endsWith(".wav") || f.isDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return "Recordings (*.wav)";
|
||||
}
|
||||
});
|
||||
|
||||
int returnVal = fileChooser.showOpenDialog(AddRecordingTunerDialog.this);
|
||||
|
||||
File lastDirectory = fileChooser.getCurrentDirectory();
|
||||
|
||||
if(lastDirectory != null)
|
||||
{
|
||||
SystemProperties.getInstance().set(LAST_FILE_BROWSE_LOCATION_KEY, lastDirectory.getAbsolutePath());
|
||||
}
|
||||
|
||||
if(returnVal == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
mSelectedRecording = fileChooser.getSelectedFile();
|
||||
|
||||
mAddButton.setEnabled(mSelectedRecording != null);
|
||||
|
||||
if(mSelectedRecording != null &&
|
||||
(mFrequencyTextField.getText() == null || mFrequencyTextField.getText().isEmpty()))
|
||||
{
|
||||
Matcher m = TUNER_RECORDING_PATTERN.matcher(mSelectedRecording.getName());
|
||||
|
||||
if(m.matches())
|
||||
{
|
||||
mFrequencyTextField.setText(m.group(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mSelectedRecording = null;
|
||||
}
|
||||
|
||||
mRecordingFileLabel.setText(mSelectedRecording != null ? mSelectedRecording.getName() : SELECT_A_FILE);
|
||||
});
|
||||
content.add(mSelectFileButton);
|
||||
|
||||
@@ -163,52 +165,47 @@ public class AddRecordingTunerDialog extends JFrame
|
||||
content.add(new JLabel(""));
|
||||
|
||||
mAddButton = new JButton("Add");
|
||||
mAddButton.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
mAddButton.setEnabled(false);
|
||||
mAddButton.addActionListener(e -> {
|
||||
if(mSelectedRecording == null)
|
||||
{
|
||||
if(mSelectedRecording == null)
|
||||
{
|
||||
JOptionPane.showMessageDialog(AddRecordingTunerDialog.this,
|
||||
"Please select a recording file",
|
||||
"Select a Recording File",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
long frequency = getFrequency();
|
||||
|
||||
if(frequency <= 0 || frequency > Integer.MAX_VALUE)
|
||||
{
|
||||
JOptionPane.showMessageDialog(AddRecordingTunerDialog.this,
|
||||
"Please provide a recording center frequency (1 Hz to 2.14 GHz)",
|
||||
"Center Frequency Required",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
mLog.info("Adding recording tuner = frequency [" + frequency +
|
||||
"] recording [" + mSelectedRecording.getAbsolutePath() + "]");
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// RecordingTuner tuner = new RecordingTuner(mUserPreferences);
|
||||
// mDiscoveredTunerModel.addDiscoveredTuner(tuner);
|
||||
// RecordingTunerController controller = tuner.getTunerController();
|
||||
// RecordingTunerConfiguration config = new RecordingTunerConfiguration();
|
||||
// config.setFrequency(frequency);
|
||||
// config.setPath(mSelectedRecording.getAbsolutePath());
|
||||
// controller.apply(config);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
mLog.error("Error adding recording tuner", ex);
|
||||
}
|
||||
|
||||
AddRecordingTunerDialog.this.setVisible(false);
|
||||
JOptionPane.showMessageDialog(AddRecordingTunerDialog.this,
|
||||
"Please select a recording file",
|
||||
"Select a Recording File",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
long frequency = getFrequency();
|
||||
|
||||
if(frequency <= 0 || frequency > Integer.MAX_VALUE)
|
||||
{
|
||||
JOptionPane.showMessageDialog(AddRecordingTunerDialog.this,
|
||||
"Please provide a recording center frequency (1 Hz to 2.14 GHz)",
|
||||
"Center Frequency Required",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
mLog.info("Adding recording tuner = frequency [" + frequency +
|
||||
"] recording [" + mSelectedRecording.getAbsolutePath() + "]");
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
RecordingTunerConfiguration config = RecordingTunerConfiguration.create();
|
||||
config.setFrequency(frequency);
|
||||
config.setPath(mSelectedRecording.getAbsolutePath());
|
||||
mTunerConfigurationManager.addTunerConfiguration(config);
|
||||
DiscoveredRecordingTuner discoveredRecordingTuner = new DiscoveredRecordingTuner(mUserPreferences, config);
|
||||
mDiscoveredTunerModel.addDiscoveredTuner(discoveredRecordingTuner);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
mLog.error("Error adding recording tuner", ex);
|
||||
}
|
||||
|
||||
AddRecordingTunerDialog.this.setVisible(false);
|
||||
});
|
||||
content.add(mAddButton, "grow,push");
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package io.github.dsheirer.source.tuner.recording;
|
||||
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.preference.source.ChannelizerType;
|
||||
import io.github.dsheirer.source.SourceEvent;
|
||||
import io.github.dsheirer.source.SourceException;
|
||||
import io.github.dsheirer.source.tuner.ITunerErrorListener;
|
||||
import io.github.dsheirer.source.tuner.Tuner;
|
||||
import io.github.dsheirer.source.tuner.TunerClass;
|
||||
@@ -41,11 +41,17 @@ public class RecordingTuner extends Tuner
|
||||
private final int mInstanceID = mInstanceCounter++;
|
||||
private UserPreferences mUserPreferences;
|
||||
|
||||
public RecordingTuner(UserPreferences userPreferences, ITunerErrorListener tunerErrorListener)
|
||||
public RecordingTuner(UserPreferences userPreferences, ITunerErrorListener tunerErrorListener,
|
||||
RecordingTunerConfiguration config)
|
||||
{
|
||||
super(new RecordingTunerController(tunerErrorListener), tunerErrorListener);
|
||||
super(new RecordingTunerController(tunerErrorListener, config.getPath(), config.getFrequency()), tunerErrorListener);
|
||||
|
||||
mUserPreferences = userPreferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws SourceException {
|
||||
super.start();
|
||||
|
||||
if(getTunerController().getCurrentSampleRate() < 100000.0d)
|
||||
{
|
||||
@@ -53,7 +59,7 @@ public class RecordingTuner extends Tuner
|
||||
}
|
||||
else
|
||||
{
|
||||
ChannelizerType channelizerType = userPreferences.getTunerPreference().getChannelizerType();
|
||||
ChannelizerType channelizerType = mUserPreferences.getTunerPreference().getChannelizerType();
|
||||
|
||||
if(channelizerType == ChannelizerType.POLYPHASE)
|
||||
{
|
||||
@@ -73,7 +79,7 @@ public class RecordingTuner extends Tuner
|
||||
@Override
|
||||
public String getPreferredName()
|
||||
{
|
||||
return "Recording Tuner-" + mInstanceID;
|
||||
return "Recording Tuner #" + mInstanceID;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,39 +114,6 @@ public class RecordingTuner extends Tuner
|
||||
return 16.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(SourceEvent event)
|
||||
{
|
||||
super.process(event);
|
||||
|
||||
if(event.getEvent() == SourceEvent.Event.NOTIFICATION_RECORDING_FILE_LOADED)
|
||||
{
|
||||
if(getTunerController().getCurrentSampleRate() < 100000.0d)
|
||||
{
|
||||
setChannelSourceManager(new PassThroughSourceManager(getTunerController()));
|
||||
}
|
||||
else
|
||||
{
|
||||
ChannelizerType channelizerType = mUserPreferences.getTunerPreference().getChannelizerType();
|
||||
|
||||
mLog.debug("Using Channelizer Type: " + channelizerType);
|
||||
|
||||
if(channelizerType == ChannelizerType.POLYPHASE)
|
||||
{
|
||||
setChannelSourceManager(new PolyphaseChannelSourceManager(getTunerController()));
|
||||
}
|
||||
else if(channelizerType == ChannelizerType.HETERODYNE)
|
||||
{
|
||||
setChannelSourceManager(new HeterodyneChannelSourceManager(getTunerController()));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("Unrecognized channelizer type: " + channelizerType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumUSBBitsPerSecond()
|
||||
{
|
||||
|
||||
@@ -23,17 +23,31 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import io.github.dsheirer.source.tuner.TunerType;
|
||||
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Recording tuner configuration for using baseband I/Q recordings as a tuner source
|
||||
*/
|
||||
public class RecordingTunerConfiguration extends TunerConfiguration
|
||||
{
|
||||
private static final Logger mLog = LoggerFactory.getLogger(RecordingTunerConfiguration.class);
|
||||
private String mPath;
|
||||
|
||||
/**
|
||||
* Jackson constructor
|
||||
*/
|
||||
public RecordingTunerConfiguration()
|
||||
{
|
||||
//Empty jackson constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param uniqueId to use for this configuration
|
||||
*/
|
||||
public RecordingTunerConfiguration(String uniqueId)
|
||||
{
|
||||
setUniqueID(uniqueId);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@@ -43,11 +57,6 @@ public class RecordingTunerConfiguration extends TunerConfiguration
|
||||
return TunerType.RECORDING;
|
||||
}
|
||||
|
||||
public RecordingTunerConfiguration(String uniqueId)
|
||||
{
|
||||
super(uniqueId);
|
||||
}
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "path")
|
||||
public String getPath()
|
||||
{
|
||||
@@ -58,4 +67,9 @@ public class RecordingTunerConfiguration extends TunerConfiguration
|
||||
{
|
||||
mPath = path;
|
||||
}
|
||||
|
||||
public static RecordingTunerConfiguration create()
|
||||
{
|
||||
return new RecordingTunerConfiguration("Recording " + System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,22 +18,22 @@
|
||||
*/
|
||||
package io.github.dsheirer.source.tuner.recording;
|
||||
|
||||
import io.github.dsheirer.buffer.INativeBuffer;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.source.SourceEvent;
|
||||
import io.github.dsheirer.source.SourceException;
|
||||
import io.github.dsheirer.source.tuner.ITunerErrorListener;
|
||||
import io.github.dsheirer.source.tuner.TunerController;
|
||||
import io.github.dsheirer.source.tuner.TunerType;
|
||||
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
|
||||
import io.github.dsheirer.source.wave.ComplexWaveSource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.sound.sampled.UnsupportedAudioFileException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Tuner controller for playback of baseband complex recording files.
|
||||
*/
|
||||
public class RecordingTunerController extends TunerController
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(RecordingTunerController.class);
|
||||
@@ -41,16 +41,24 @@ public class RecordingTunerController extends TunerController
|
||||
public static final int DC_NOISE_BANDWIDTH = 0;
|
||||
public static final double USABLE_BANDWIDTH_PERCENTAGE = 1.00;
|
||||
private ComplexWaveSource mComplexWaveSource;
|
||||
private String mPath;
|
||||
private long mCenterFrequency;
|
||||
private boolean mRunning;
|
||||
|
||||
/**
|
||||
* Tuner controller testing implementation.
|
||||
* Constructs an instance
|
||||
* @param tunerErrorListener to receive errors from this controller
|
||||
*/
|
||||
public RecordingTunerController(ITunerErrorListener tunerErrorListener)
|
||||
public RecordingTunerController(ITunerErrorListener tunerErrorListener, String path, long centerFrequency)
|
||||
{
|
||||
super(tunerErrorListener);
|
||||
mPath = path;
|
||||
mCenterFrequency = centerFrequency;
|
||||
if(mCenterFrequency == 0)
|
||||
{
|
||||
mCenterFrequency = 100000000;
|
||||
}
|
||||
|
||||
setMinimumFrequency(1000000l);
|
||||
setMaximumFrequency(3000000000l);
|
||||
setMiddleUnusableHalfBandwidth(DC_NOISE_BANDWIDTH);
|
||||
@@ -60,13 +68,65 @@ public class RecordingTunerController extends TunerController
|
||||
@Override
|
||||
public void start() throws SourceException
|
||||
{
|
||||
if(mComplexWaveSource == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
mComplexWaveSource = new ComplexWaveSource(new File(mPath), true);
|
||||
}
|
||||
catch(IOException ioe)
|
||||
{
|
||||
mLog.error("Error", ioe);
|
||||
setErrorMessage(ioe.getMessage() + " File:" + mPath);
|
||||
return;
|
||||
}
|
||||
|
||||
mComplexWaveSource.setListener(complexSamples -> broadcast(complexSamples));
|
||||
|
||||
try
|
||||
{
|
||||
mComplexWaveSource.open();
|
||||
mComplexWaveSource.start();
|
||||
mLog.info("Tuner Recording Loaded: " + mPath);
|
||||
}
|
||||
catch(IOException | UnsupportedAudioFileException e)
|
||||
{
|
||||
mLog.error("Error", e);
|
||||
setErrorMessage(e.getMessage() + " File:" + mPath);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
mFrequencyController.setFrequency(mCenterFrequency);
|
||||
mFrequencyController.setSampleRate((int)mComplexWaveSource.getSampleRate());
|
||||
mFrequencyController.broadcast(SourceEvent.recordingFileLoaded());
|
||||
}
|
||||
catch(SourceException e)
|
||||
{
|
||||
mLog.error("Error", e);
|
||||
setErrorMessage(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop()
|
||||
{
|
||||
if(mComplexWaveSource != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
mComplexWaveSource.stop();
|
||||
mComplexWaveSource.close();
|
||||
}
|
||||
catch(IOException ioe)
|
||||
{
|
||||
mLog.error("Ignoring - error stopping baseband recording playback - " + ioe.getLocalizedMessage());
|
||||
}
|
||||
|
||||
mComplexWaveSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,60 +135,6 @@ public class RecordingTunerController extends TunerController
|
||||
return TunerType.RECORDING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the recording file and center frequency for this controller
|
||||
* @param recordingPath to play
|
||||
* @param centerFrequency of the recording
|
||||
* @throws IOException if there are any errors
|
||||
*/
|
||||
private void setRecording(String recordingPath, long centerFrequency) throws IOException
|
||||
{
|
||||
if(mComplexWaveSource != null)
|
||||
{
|
||||
mComplexWaveSource.close();
|
||||
mComplexWaveSource = null;
|
||||
}
|
||||
|
||||
if(recordingPath == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mComplexWaveSource = new ComplexWaveSource(new File(recordingPath), true);
|
||||
mComplexWaveSource.setListener(complexSamples -> broadcast(complexSamples));
|
||||
|
||||
try
|
||||
{
|
||||
mComplexWaveSource.open();
|
||||
mLog.info("Tuner Recording Loaded: " + recordingPath);
|
||||
}
|
||||
catch(UnsupportedAudioFileException e)
|
||||
{
|
||||
mLog.error("Unsupported audio format", e);
|
||||
}
|
||||
|
||||
|
||||
mCenterFrequency = centerFrequency;
|
||||
|
||||
mLog.debug("Set recording center frequency to: " + mCenterFrequency);
|
||||
|
||||
if(mCenterFrequency == 0)
|
||||
{
|
||||
mCenterFrequency = 100000000;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
mFrequencyController.setFrequency(mCenterFrequency);
|
||||
mFrequencyController.setSampleRate((int)mComplexWaveSource.getSampleRate());
|
||||
mFrequencyController.broadcast(SourceEvent.recordingFileLoaded());
|
||||
}
|
||||
catch(SourceException e)
|
||||
{
|
||||
throw new IOException("Can't set frequency or sample rate", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBufferSampleCount()
|
||||
{
|
||||
@@ -140,55 +146,6 @@ public class RecordingTunerController extends TunerController
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBufferListener(Listener<INativeBuffer> listener)
|
||||
{
|
||||
super.addBufferListener(listener);
|
||||
|
||||
if(mComplexWaveSource != null)
|
||||
{
|
||||
if(!mRunning)
|
||||
{
|
||||
mComplexWaveSource.start();
|
||||
mRunning = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBufferListener(Listener<INativeBuffer> listener)
|
||||
{
|
||||
super.removeBufferListener(listener);
|
||||
|
||||
if(!mNativeBufferBroadcaster.hasListeners() && mComplexWaveSource != null)
|
||||
{
|
||||
mComplexWaveSource.setListener((Listener<INativeBuffer>)null);
|
||||
mComplexWaveSource.stop();
|
||||
mRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(TunerConfiguration config) throws SourceException
|
||||
{
|
||||
//Invoke super for frequency, frequency correction and autoPPM
|
||||
super.apply(config);
|
||||
|
||||
if(config instanceof RecordingTunerConfiguration rtc)
|
||||
{
|
||||
mCenterFrequency = rtc.getFrequency();
|
||||
|
||||
try
|
||||
{
|
||||
setRecording(rtc.getPath(), rtc.getFrequency());
|
||||
}
|
||||
catch(IOException ioe)
|
||||
{
|
||||
mLog.debug("Error loading recording tuner baseband recording [" + rtc.getPath() + "] Error: " + ioe.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrequency(long frequency) throws SourceException
|
||||
{
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package io.github.dsheirer.source.tuner.recording;
|
||||
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.source.SourceException;
|
||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||
@@ -28,6 +27,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JSeparator;
|
||||
|
||||
/**
|
||||
* Recording tuner configuration editor
|
||||
@@ -37,9 +37,6 @@ public class RecordingTunerEditor extends TunerEditor<RecordingTuner,RecordingTu
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog = LoggerFactory.getLogger(RecordingTunerEditor.class);
|
||||
private JLabel mRecordingPath;
|
||||
private boolean mLoading;
|
||||
|
||||
private RecordingTunerController mController;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
@@ -50,8 +47,8 @@ public class RecordingTunerEditor extends TunerEditor<RecordingTuner,RecordingTu
|
||||
public RecordingTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredTuner discoveredTuner)
|
||||
{
|
||||
super(userPreferences, tunerManager, discoveredTuner);
|
||||
// mController = discoveredTuner.getTunerController();
|
||||
// init();
|
||||
init();
|
||||
tunerStatusUpdated();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,63 +60,71 @@ public class RecordingTunerEditor extends TunerEditor<RecordingTuner,RecordingTu
|
||||
@Override
|
||||
protected void tunerStatusUpdated()
|
||||
{
|
||||
setLoading(true);
|
||||
|
||||
if(hasTuner())
|
||||
{
|
||||
getTunerIdLabel().setText(getTuner().getPreferredName());
|
||||
}
|
||||
else
|
||||
{
|
||||
getTunerIdLabel().setText(null);
|
||||
}
|
||||
|
||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
||||
if(getDiscoveredTuner().hasErrorMessage())
|
||||
{
|
||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
||||
}
|
||||
getTunerStatusLabel().setText(status);
|
||||
getButtonPanel().updateControls();
|
||||
getFrequencyPanel().updateControls();
|
||||
|
||||
if(hasConfiguration())
|
||||
{
|
||||
getRecordingPath().setText(getConfiguration().getPath());
|
||||
}
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout(new MigLayout("fill,wrap 4", "[right][grow,fill]",
|
||||
"[][][grow]"));
|
||||
add(new JLabel("Recording Tuner Configuration"), "span,align center");
|
||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill]",
|
||||
"[][][][][][][][grow]"));
|
||||
|
||||
add(new JLabel("Tuner:"));
|
||||
add(getTunerIdLabel(), "wrap");
|
||||
|
||||
add(new JLabel("Status:"));
|
||||
add(getTunerStatusLabel(), "wrap");
|
||||
|
||||
add(new JLabel("File:"));
|
||||
mRecordingPath = new JLabel();
|
||||
add(mRecordingPath);
|
||||
add(getRecordingPath(), "wrap");
|
||||
|
||||
add(getButtonPanel(), "span,align left");
|
||||
add(new JSeparator(), "span,growx,push");
|
||||
|
||||
add(new JLabel("Frequency (MHz):"));
|
||||
add(getFrequencyPanel(), "wrap");
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void setItem(TunerConfiguration tunerConfiguration)
|
||||
// {
|
||||
// super.setItem(tunerConfiguration);
|
||||
//
|
||||
// //Toggle loading so that we don't fire a change event and schedule a settings file save
|
||||
// mLoading = true;
|
||||
//
|
||||
// if(hasItem())
|
||||
// {
|
||||
// RecordingTunerConfiguration config = getConfiguration();
|
||||
//
|
||||
// mRecordingPath.setText(config.getPath());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// mRecordingPath.setText("");
|
||||
// }
|
||||
//
|
||||
// mLoading = false;
|
||||
// }
|
||||
private JLabel getRecordingPath()
|
||||
{
|
||||
if(mRecordingPath == null)
|
||||
{
|
||||
mRecordingPath = new JLabel();
|
||||
}
|
||||
|
||||
return mRecordingPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
if(hasConfiguration() && !mLoading)
|
||||
if(hasConfiguration() && !isLoading())
|
||||
{
|
||||
RecordingTunerConfiguration config = getConfiguration();
|
||||
String path = mRecordingPath.getText();
|
||||
|
||||
if(path != null && !path.isEmpty())
|
||||
{
|
||||
config.setPath(path);
|
||||
|
||||
try
|
||||
{
|
||||
mController.apply(config);
|
||||
}
|
||||
catch(SourceException se)
|
||||
{
|
||||
mLog.error("Error while applying recording tuner configuration", se);
|
||||
}
|
||||
}
|
||||
|
||||
config.setFrequency(getFrequencyControl().getFrequency());
|
||||
saveConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package io.github.dsheirer.source.tuner.ui;
|
||||
|
||||
import io.github.dsheirer.gui.control.JFrequencyControl;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.properties.SystemProperties;
|
||||
import io.github.dsheirer.record.wave.IRecordingStatusListener;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.source.ISourceEventProcessor;
|
||||
@@ -32,7 +33,12 @@ import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||
import io.github.dsheirer.source.tuner.manager.IDiscoveredTunerStatusListener;
|
||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||
import io.github.dsheirer.source.tuner.manager.TunerStatus;
|
||||
import io.github.dsheirer.spectrum.SpectralDisplayPanel;
|
||||
import io.github.dsheirer.util.SwingUtils;
|
||||
import java.awt.EventQueue;
|
||||
import java.text.CharacterIterator;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.StringCharacterIterator;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -48,10 +54,6 @@ import javax.swing.SpinnerNumberModel;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import java.awt.EventQueue;
|
||||
import java.text.CharacterIterator;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.StringCharacterIterator;
|
||||
|
||||
/**
|
||||
* Base tuner configuration editor.
|
||||
@@ -320,6 +322,8 @@ public abstract class TunerEditor<T extends Tuner,C extends TunerConfiguration>
|
||||
|
||||
if(tuner != null)
|
||||
{
|
||||
SystemProperties.getInstance().set(SpectralDisplayPanel.SPECTRAL_DISPLAY_ENABLED, true);
|
||||
|
||||
mTunerManager.getDiscoveredTunerModel().broadcast(new TunerEvent(tuner,
|
||||
TunerEvent.Event.REQUEST_MAIN_SPECTRAL_DISPLAY));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package io.github.dsheirer.source.tuner.ui;
|
||||
|
||||
import io.github.dsheirer.playlist.PlaylistManager;
|
||||
import io.github.dsheirer.properties.SystemProperties;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.settings.SettingsManager;
|
||||
import io.github.dsheirer.source.tuner.Tuner;
|
||||
@@ -28,17 +29,30 @@ import io.github.dsheirer.spectrum.SpectralDisplayPanel;
|
||||
import io.github.dsheirer.spectrum.SpectrumFrame;
|
||||
import io.github.dsheirer.util.SwingUtils;
|
||||
import io.github.dsheirer.util.ThreadPool;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Spectral display manager for displaying tuner spectral content.
|
||||
*/
|
||||
public class TunerSpectralDisplayManager implements Listener<TunerEvent>
|
||||
{
|
||||
private Logger mLog = LoggerFactory.getLogger(TunerSpectralDisplayManager.class);
|
||||
|
||||
private SpectralDisplayPanel mSpectralDisplayPanel;
|
||||
private PlaylistManager mPlaylistManager;
|
||||
private SettingsManager mSettingsManager;
|
||||
private DiscoveredTunerModel mDiscoveredTunerModel;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param panel to manage
|
||||
* @param playlistManager for channel updates
|
||||
* @param settingsManager for settings
|
||||
* @param discoveredTunerModel to access tuners
|
||||
*/
|
||||
public TunerSpectralDisplayManager(SpectralDisplayPanel panel, PlaylistManager playlistManager,
|
||||
SettingsManager settingsManager, DiscoveredTunerModel discoveredTunerModel)
|
||||
{
|
||||
@@ -53,6 +67,12 @@ public class TunerSpectralDisplayManager implements Listener<TunerEvent>
|
||||
*/
|
||||
public Tuner showFirstTuner()
|
||||
{
|
||||
if(!SystemProperties.getInstance().get(SpectralDisplayPanel.SPECTRAL_DISPLAY_ENABLED, true))
|
||||
{
|
||||
//Spectral display is disabled, stop
|
||||
return null;
|
||||
}
|
||||
|
||||
List<DiscoveredTuner> availableTuners = mDiscoveredTunerModel.getAvailableTuners();
|
||||
|
||||
for(DiscoveredTuner discoveredTuner: availableTuners)
|
||||
@@ -76,7 +96,10 @@ public class TunerSpectralDisplayManager implements Listener<TunerEvent>
|
||||
SwingUtils.run(() -> mSpectralDisplayPanel.clearTuner());
|
||||
break;
|
||||
case REQUEST_MAIN_SPECTRAL_DISPLAY:
|
||||
SwingUtils.run(() -> mSpectralDisplayPanel.showTuner(event.getTuner()));
|
||||
if(SystemProperties.getInstance().get(SpectralDisplayPanel.SPECTRAL_DISPLAY_ENABLED, true))
|
||||
{
|
||||
SwingUtils.run(() -> mSpectralDisplayPanel.showTuner(event.getTuner()));
|
||||
}
|
||||
break;
|
||||
case REQUEST_NEW_SPECTRAL_DISPLAY:
|
||||
final SpectrumFrame frame = new SpectrumFrame(mPlaylistManager, mSettingsManager, mDiscoveredTunerModel, event.getTuner());
|
||||
|
||||
@@ -22,14 +22,23 @@ package io.github.dsheirer.source.tuner.ui;
|
||||
import com.jidesoft.swing.JideSplitPane;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.preference.swing.JTableColumnWidthMonitor;
|
||||
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationManager;
|
||||
import io.github.dsheirer.source.tuner.manager.DiscoveredRecordingTuner;
|
||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||
import io.github.dsheirer.source.tuner.manager.TunerStatus;
|
||||
import io.github.dsheirer.source.tuner.recording.AddRecordingTunerDialog;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
@@ -40,11 +49,6 @@ import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import javax.swing.table.TableRowSorter;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Panel containing a discovered tuners table and a tuner editor for a selected tuner.
|
||||
@@ -55,13 +59,16 @@ public class TunerViewPanel extends JPanel
|
||||
private final static Logger mLog = LoggerFactory.getLogger(TunerViewPanel.class);
|
||||
private static final String TABLE_PREFERENCE_KEY = "tuner.view.panel";
|
||||
|
||||
private UserPreferences mUserPreferences;
|
||||
private DiscoveredTunerModel mDiscoveredTunerModel;
|
||||
private DiscoveredTunerEditor mDiscoveredTunerEditor;
|
||||
private TunerConfigurationManager mTunerConfigurationManager;
|
||||
private JTable mTunerTable;
|
||||
private JTableColumnWidthMonitor mColumnWidthMonitor;
|
||||
private TableRowSorter<DiscoveredTunerModel> mRowSorter;
|
||||
private JideSplitPane mSplitPane;
|
||||
private DiscoveredTunerEditor mDiscoveredTunerEditor;
|
||||
private UserPreferences mUserPreferences;
|
||||
private JButton mAddRecordingButton;
|
||||
private JButton mRemoveRecordingButton;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
@@ -72,6 +79,7 @@ public class TunerViewPanel extends JPanel
|
||||
{
|
||||
mDiscoveredTunerModel = tunerManager.getDiscoveredTunerModel();
|
||||
mDiscoveredTunerEditor = new DiscoveredTunerEditor(userPreferences, tunerManager);
|
||||
mTunerConfigurationManager = tunerManager.getTunerConfigurationManager();
|
||||
mUserPreferences = userPreferences;
|
||||
init();
|
||||
}
|
||||
@@ -90,6 +98,8 @@ public class TunerViewPanel extends JPanel
|
||||
mTunerTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
mTunerTable.getSelectionModel().addListSelectionListener(event ->
|
||||
{
|
||||
getRemoveRecordingButton().setEnabled(false);
|
||||
|
||||
if(!event.getValueIsAdjusting())
|
||||
{
|
||||
int row = mTunerTable.getSelectedRow();
|
||||
@@ -97,7 +107,10 @@ public class TunerViewPanel extends JPanel
|
||||
if(row >= 0)
|
||||
{
|
||||
int modelRow = mTunerTable.convertRowIndexToModel(row);
|
||||
mDiscoveredTunerEditor.setItem(mDiscoveredTunerModel.getDiscoveredTuner(modelRow));
|
||||
|
||||
DiscoveredTuner selected = mDiscoveredTunerModel.getDiscoveredTuner(modelRow);
|
||||
mDiscoveredTunerEditor.setItem(selected);
|
||||
getRemoveRecordingButton().setEnabled(selected instanceof DiscoveredRecordingTuner);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -138,7 +151,6 @@ public class TunerViewPanel extends JPanel
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
TableCellRenderer errorCellRenderer = new TunerStatusCellRenderer();
|
||||
mTunerTable.getColumnModel().getColumn(DiscoveredTunerModel.COLUMN_TUNER_STATUS).setCellRenderer(errorCellRenderer);
|
||||
|
||||
@@ -146,20 +158,14 @@ public class TunerViewPanel extends JPanel
|
||||
JScrollPane tunerTableScroller = new JScrollPane(mTunerTable);
|
||||
|
||||
JPanel tunerTablePanel = new JPanel();
|
||||
tunerTablePanel.setLayout(new MigLayout("insets 0 0 0 0", "[fill,grow][]", "[fill,grow][]"));
|
||||
tunerTablePanel.setLayout(new MigLayout("insets 0", "[fill,grow,align center]", "[fill,grow][]"));
|
||||
tunerTablePanel.add(tunerTableScroller, "span");
|
||||
|
||||
tunerTablePanel.add(new JLabel("")); //Empty spacer
|
||||
|
||||
// JButton addRecordingTunerButton = new JButton("Add Recording Tuner");
|
||||
// addRecordingTunerButton.addActionListener(e ->
|
||||
// {
|
||||
// AddRecordingTunerDialog dialog = new AddRecordingTunerDialog(mUserPreferences, mDiscoveredTunerModel);
|
||||
// dialog.setLocationRelativeTo(TunerViewPanel.this);
|
||||
// EventQueue.invokeLater(() -> dialog.setVisible(true));
|
||||
// });
|
||||
//
|
||||
// tunerTablePanel.add(addRecordingTunerButton);
|
||||
JPanel buttonPanel = new JPanel();
|
||||
buttonPanel.setLayout(new MigLayout("insets 0 1 3 0", "", ""));
|
||||
buttonPanel.add(getAddRecordingButton());
|
||||
buttonPanel.add(getRemoveRecordingButton());
|
||||
tunerTablePanel.add(buttonPanel);
|
||||
|
||||
tunerTablePanel.setPreferredSize(new Dimension(200,200));
|
||||
JScrollPane editorScroller = new JScrollPane(mDiscoveredTunerEditor);
|
||||
@@ -169,10 +175,58 @@ public class TunerViewPanel extends JPanel
|
||||
mSplitPane.setOrientation(JideSplitPane.HORIZONTAL_SPLIT);
|
||||
mSplitPane.add(tunerTablePanel);
|
||||
mSplitPane.add(editorScroller);
|
||||
mSplitPane.setProportionalLayout(true);
|
||||
mSplitPane.setProportions(new double[]{0.5});
|
||||
|
||||
add(mSplitPane);
|
||||
}
|
||||
|
||||
private JButton getAddRecordingButton()
|
||||
{
|
||||
if(mAddRecordingButton == null)
|
||||
{
|
||||
mAddRecordingButton = new JButton("Add Recording Tuner");
|
||||
mAddRecordingButton.addActionListener(e ->
|
||||
{
|
||||
AddRecordingTunerDialog dialog = new AddRecordingTunerDialog(mUserPreferences, mDiscoveredTunerModel,
|
||||
mTunerConfigurationManager);
|
||||
dialog.setLocationRelativeTo(TunerViewPanel.this);
|
||||
EventQueue.invokeLater(() -> dialog.setVisible(true));
|
||||
});
|
||||
}
|
||||
|
||||
return mAddRecordingButton;
|
||||
}
|
||||
|
||||
private JButton getRemoveRecordingButton()
|
||||
{
|
||||
if(mRemoveRecordingButton == null)
|
||||
{
|
||||
mRemoveRecordingButton = new JButton("Remove Recording Tuner");
|
||||
mRemoveRecordingButton.setEnabled(false);
|
||||
mRemoveRecordingButton.addActionListener(e -> {
|
||||
int[] indexes = mTunerTable.getSelectionModel().getSelectedIndices();
|
||||
|
||||
//With single selection mode this should always be length one
|
||||
if(indexes.length == 1)
|
||||
{
|
||||
int modelIndex = mTunerTable.convertRowIndexToModel(indexes[0]);
|
||||
DiscoveredTuner selected = mDiscoveredTunerModel.getDiscoveredTuner(modelIndex);
|
||||
|
||||
if(selected instanceof DiscoveredRecordingTuner discoveredRecordingTuner)
|
||||
{
|
||||
mLog.info("Removing Tuner: " + discoveredRecordingTuner);
|
||||
discoveredRecordingTuner.stop();
|
||||
mTunerConfigurationManager.removeTunerConfiguration(discoveredRecordingTuner.getTunerConfiguration());
|
||||
EventQueue.invokeLater(() -> mDiscoveredTunerModel.removeDiscoveredTuner(discoveredRecordingTuner));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return mRemoveRecordingButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom cell renderer for the TunerStatus enumeration column
|
||||
*/
|
||||
|
||||
@@ -26,6 +26,12 @@ import io.github.dsheirer.source.tuner.ITunerErrorListener;
|
||||
import io.github.dsheirer.source.tuner.TunerController;
|
||||
import io.github.dsheirer.source.tuner.TunerType;
|
||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.LinkedTransferQueue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.usb4java.Context;
|
||||
@@ -37,13 +43,6 @@ import org.usb4java.LibUsb;
|
||||
import org.usb4java.Transfer;
|
||||
import org.usb4java.TransferCallback;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.LinkedTransferQueue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/**
|
||||
* Tuner controller implementation for USB tuners. Manages general USB operations and incorporates threaded USB
|
||||
* Transfer processing.
|
||||
@@ -69,6 +68,9 @@ public abstract class USBTunerController extends TunerController
|
||||
private ReentrantLock mListenerLock = new ReentrantLock();
|
||||
private boolean mRunning = false;
|
||||
|
||||
//Troubleshooting libusb bug: https://github.com/DSheirer/sdrtrunk/issues/1253
|
||||
private int mAnomalousTransfersDetected = 0;
|
||||
|
||||
/**
|
||||
* USB tuner controller class. Provides auto-start and auto-stop function when complex buffer listeners are added
|
||||
* or removed from this tuner controller.
|
||||
@@ -544,7 +546,7 @@ public abstract class USBTunerController extends TunerController
|
||||
{
|
||||
for(Transfer transfer: transfers)
|
||||
{
|
||||
submitTransfer(transfer);
|
||||
submitTransfer(transfer, LibUsb.SUCCESS, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,7 +554,7 @@ public abstract class USBTunerController extends TunerController
|
||||
* (Re)Submits the transfer for stream processing
|
||||
* @param transfer to (re)submit
|
||||
*/
|
||||
private void submitTransfer(Transfer transfer)
|
||||
private void submitTransfer(Transfer transfer, int previousStatus, int previousBytesTransferred)
|
||||
{
|
||||
int status = LibUsb.submitTransfer(transfer);
|
||||
|
||||
@@ -560,9 +562,37 @@ public abstract class USBTunerController extends TunerController
|
||||
{
|
||||
mInProgressTransfers.add(transfer);
|
||||
}
|
||||
else if(status == LibUsb.ERROR_BUSY)
|
||||
{
|
||||
mInProgressTransfers.add(transfer);
|
||||
|
||||
//Weird issue/bug with libusb on Windows where libusb tells us the transfer is complete and then tells
|
||||
//us that the transfer is already submitted when we attempt to re-submit the transfer. We track the
|
||||
//number of times this occurs and log when the anomaly count exceeds the number of transfer buffers
|
||||
//in case the application gets to a state where all transfers are no longer usable ... so that we
|
||||
//know post-mortem what happened to the application.
|
||||
mAnomalousTransfersDetected++;
|
||||
|
||||
if(mAnomalousTransfersDetected < USB_BULK_TRANSFER_BUFFER_POOL_SIZE)
|
||||
{
|
||||
mLog.error("USB transfer anomaly detected - continuing - previous status [" + previousStatus +
|
||||
" ] transferred [" + previousBytesTransferred + "] this has happened [" +
|
||||
mAnomalousTransfersDetected + "] times");
|
||||
}
|
||||
|
||||
//This should only log once, when the anomaly count matches the transfer count
|
||||
if(mAnomalousTransfersDetected == USB_BULK_TRANSFER_BUFFER_POOL_SIZE)
|
||||
{
|
||||
mLog.warn("USB transfer anomaly detection count exceeded the total number [8] of available " +
|
||||
"tranfers - sdrtrunk may no longer be streaming data from this tuner and may appear to " +
|
||||
"be locked up. If so, restart the application to resolve the issue and please send the " +
|
||||
"application log to the developer");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mLog.error("Error submitting USB transfer - " + LibUsb.errorName(status));
|
||||
mLog.error("Error submitting USB transfer - status [" + status + "] " + LibUsb.errorName(status) +
|
||||
" - previous status [" + previousStatus + "] and transferred [" + previousBytesTransferred + "]");
|
||||
setErrorMessage("Usb I/O Error - Can't submit buffers to tuner - stopping tuner");
|
||||
}
|
||||
}
|
||||
@@ -593,44 +623,32 @@ public abstract class USBTunerController extends TunerController
|
||||
case LibUsb.TRANSFER_STALL:
|
||||
case LibUsb.TRANSFER_TIMED_OUT:
|
||||
case LibUsb.TRANSFER_ERROR:
|
||||
if(transfer.actualLength() > 0)
|
||||
int transferLength = transfer.actualLength();
|
||||
|
||||
if(transferLength > 0)
|
||||
{
|
||||
dispatchTransfer(transfer);
|
||||
transfer.buffer().rewind();
|
||||
}
|
||||
|
||||
transfer.buffer().rewind();
|
||||
|
||||
if(mAutoResubmitTransfers)
|
||||
{
|
||||
submitTransfer(transfer);
|
||||
submitTransfer(transfer, transfer.status(), transferLength);
|
||||
}
|
||||
break;
|
||||
case LibUsb.TRANSFER_CANCELLED:
|
||||
//Reset the transfer but don't do anything else
|
||||
//Reset the transfer but don't do anything else since we're shutting down
|
||||
transfer.buffer().rewind();
|
||||
break;
|
||||
default:
|
||||
//Unexpected transfer error - need to reset the bulk transfer interface
|
||||
transfer.buffer().rewind();
|
||||
//TODO: usually the device is in a bad state at this point ... need to raise the error flag
|
||||
setErrorMessage("LibUsb Transfer Error - stopping device - status [" + transfer.status() + "] - " +
|
||||
LibUsb.errorName(transfer.status()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes of the transfer and dereferences the native byte buffer so that it can be garbage collected.
|
||||
*/
|
||||
private void disposeTransfers()
|
||||
{
|
||||
for(Transfer transfer: mAvailableTransfers)
|
||||
{
|
||||
transfer.setBuffer(null);
|
||||
}
|
||||
|
||||
mAvailableTransfers.clear();
|
||||
mAvailableTransfers = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a copy of the transfer's native memory byte array payload so that the transfer can be reused.
|
||||
* Dispatches the native buffer to registered listeners.
|
||||
|
||||
@@ -36,9 +36,9 @@ public class ClearTunerMenuItem extends JMenuItem
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
mSpectralDisplayPanel.clearTuner();
|
||||
SystemProperties properties = SystemProperties.getInstance();
|
||||
properties.set(SpectralDisplayPanel.SPECTRAL_DISPLAY_ENABLED, false);
|
||||
mSpectralDisplayPanel.clearTuner();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ public class ShowTunerMenuItem extends JMenuItem
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
mDiscoveredTunerModel.broadcast(new TunerEvent(mTuner, TunerEvent.Event.REQUEST_MAIN_SPECTRAL_DISPLAY));
|
||||
SystemProperties properties = SystemProperties.getInstance();
|
||||
properties.set(SpectralDisplayPanel.SPECTRAL_DISPLAY_ENABLED, true);
|
||||
mDiscoveredTunerModel.broadcast(new TunerEvent(mTuner, TunerEvent.Event.REQUEST_MAIN_SPECTRAL_DISPLAY));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -47,6 +47,17 @@ import io.github.dsheirer.spectrum.menu.FFTWindowTypeItem;
|
||||
import io.github.dsheirer.spectrum.menu.FrameRateItem;
|
||||
import io.github.dsheirer.spectrum.menu.SmoothingItem;
|
||||
import io.github.dsheirer.spectrum.menu.SmoothingTypeItem;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.slf4j.Logger;
|
||||
@@ -68,17 +79,6 @@ import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.MouseInputAdapter;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
|
||||
public class SpectralDisplayPanel extends JPanel
|
||||
implements Listener<INativeBuffer>, ISourceEventProcessor, IDFTWidthChangeProcessor
|
||||
|
||||
Reference in New Issue
Block a user