mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-11 08:07:24 -05:00
Compare commits
20 Commits
v0.5.0-bet
...
v0.5.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a24c3736f4 | ||
|
|
ac61b681e6 | ||
|
|
0866bfd555 | ||
|
|
79fed701d9 | ||
|
|
48a93990e8 | ||
|
|
414ba25d61 | ||
|
|
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" project-jdk-name="liberica-19.0.1.fx" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
64
build.gradle
64
build.gradle
@@ -28,7 +28,7 @@ repositories {
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
|
||||
version = '0.5.0-beta3'
|
||||
version = '0.5.0-beta6'
|
||||
sourceCompatibility = '17'
|
||||
|
||||
sourceSets {
|
||||
@@ -43,10 +43,10 @@ test {
|
||||
dependencies {
|
||||
|
||||
// JUnit Tests
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.assertj:assertj-core:3.8.0'
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
|
||||
testImplementation 'org.mockito:mockito-core:3.+'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
testImplementation 'org.assertj:assertj-core:3.23.1'
|
||||
testImplementation('org.junit.jupiter:junit-jupiter-api:5.9.0')
|
||||
testImplementation 'org.mockito:mockito-core:4.8.0'
|
||||
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
|
||||
|
||||
@@ -56,37 +56,37 @@ dependencies {
|
||||
implementation 'com.github.nwaldispuehl:java-lame:v3.98.4'
|
||||
|
||||
//mavenCentral/jcenter imports
|
||||
implementation 'ch.qos.logback:logback-classic:1.2.3'
|
||||
implementation 'ch.qos.logback:logback-core:1.2.3'
|
||||
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.2'
|
||||
implementation 'com.fazecast:jSerialComm:2.5.0'
|
||||
implementation 'ch.qos.logback:logback-classic:1.4.4'
|
||||
implementation 'ch.qos.logback:logback-core:1.4.4'
|
||||
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.14.0'
|
||||
implementation 'com.fazecast:jSerialComm:2.9.2'
|
||||
implementation 'com.github.jiconfont:jiconfont-font_awesome:4.7.0.1'
|
||||
implementation 'com.github.jiconfont:jiconfont-javafx:1.0.0'
|
||||
implementation 'com.github.jiconfont:jiconfont-swing:1.0.1'
|
||||
implementation 'com.github.wendykierp:JTransforms:3.1'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
implementation 'com.google.guava:guava:27.0.1-jre'
|
||||
implementation 'com.google.code.gson:gson:2.10'
|
||||
implementation 'com.google.guava:guava:31.1-jre'
|
||||
implementation 'com.jidesoft:jide-oss:3.6.18'
|
||||
implementation 'com.miglayout:miglayout-swing:5.2'
|
||||
implementation 'com.miglayout:miglayout-swing:11.0'
|
||||
implementation 'com.mpatric:mp3agic:0.9.1'
|
||||
implementation 'commons-io:commons-io:2.7'
|
||||
implementation 'commons-io:commons-io:2.11.0'
|
||||
implementation 'eu.hansolo:charts:1.0.5'
|
||||
implementation 'io.github.dsheirer:radio-reference-api:15.1.8'
|
||||
implementation 'javax.usb:usb-api:1.0.2'
|
||||
implementation 'net.coderazzi:tablefilter-swing:5.4.0'
|
||||
implementation 'org.apache.commons:commons-compress:1.20'
|
||||
implementation 'org.apache.commons:commons-lang3:3.8.1'
|
||||
implementation 'net.coderazzi:tablefilter-swing:5.5.4'
|
||||
implementation 'org.apache.commons:commons-compress:1.21'
|
||||
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
||||
implementation 'org.apache.commons:commons-math3:3.6.1'
|
||||
implementation 'org.apache.commons:commons-csv:1.9.0'
|
||||
implementation 'org.apache.mina:mina-core:2.1.3'
|
||||
implementation 'org.apache.mina:mina-http:2.1.3'
|
||||
implementation 'org.controlsfx:controlsfx:11.1.0'
|
||||
implementation 'org.rauschig:jarchivelib:1.0.0'
|
||||
implementation 'org.slf4j:slf4j-api:1.7.25'
|
||||
implementation 'org.apache.mina:mina-core:2.2.1'
|
||||
implementation 'org.apache.mina:mina-http:2.2.1'
|
||||
implementation 'org.controlsfx:controlsfx:11.1.2'
|
||||
implementation 'org.rauschig:jarchivelib:1.2.0'
|
||||
implementation 'org.slf4j:slf4j-api:2.0.3'
|
||||
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'
|
||||
}
|
||||
|
||||
@@ -139,11 +139,11 @@ String targetWindowsX86_64 = 'windows-x86_64-v' + version
|
||||
* author's development environment, but can be changed to your environment if you want to use this build pattern.
|
||||
*/
|
||||
String jdk_base = '/home/denny/java_jdks/'
|
||||
String jdk_linux_aarch64 = jdk_base + 'linux-arm64/jdk-18.0.1-full'
|
||||
String jdk_linux_x86_64 = jdk_base + 'linux-x64/jdk-18.0.1-full'
|
||||
String jdk_osx_x86_64 = jdk_base + 'osx-x64/jdk-18.0.1-full.jdk'
|
||||
String jdk_osx_aarch64 = jdk_base + 'osx-arm64/jdk-18.0.1-full.jdk'
|
||||
String jdk_windows_x86_64 = jdk_base + 'windows-x64/jdk-18.0.1-full'
|
||||
String jdk_linux_aarch64 = jdk_base + 'linux-arm64/jdk-19.0.1-full'
|
||||
String jdk_linux_x86_64 = jdk_base + 'linux-x64/jdk-19.0.1-full'
|
||||
String jdk_osx_x86_64 = jdk_base + 'osx-x64/jdk-19.0.1-full.jdk'
|
||||
String jdk_osx_aarch64 = jdk_base + 'osx-arm64/jdk-19.0.1-full.jdk'
|
||||
String jdk_windows_x86_64 = jdk_base + 'windows-x64/jdk-19.0.1-full'
|
||||
|
||||
boolean hasTargetJdks = file(jdk_linux_x86_64).exists() || file(jdk_linux_aarch64).exists() ||
|
||||
file(jdk_osx_x86_64).exists() || file(jdk_osx_aarch64).exists() || file(jdk_windows_x86_64).exists()
|
||||
@@ -172,19 +172,19 @@ runtime {
|
||||
println("Building all runtime images")
|
||||
println("The [ > jre: ] build phase downloads several target JDKs and this may take a while ... please wait")
|
||||
targetPlatform(targetLinuxAarch64) {
|
||||
jdkHome = jdkDownload("https://download.bell-sw.com/java/18.0.1+12/bellsoft-jdk18.0.1+12-linux-aarch64-full.tar.gz")
|
||||
jdkHome = jdkDownload("https://download.bell-sw.com/java/19.0.1+11/bellsoft-jdk19.0.1+11-linux-aarch64-full.tar.gz")
|
||||
}
|
||||
targetPlatform(targetLinuxX86_64) {
|
||||
jdkHome = jdkDownload("https://download.bell-sw.com/java/18.0.1+12/bellsoft-jdk18.0.1+12-linux-amd64-full.tar.gz")
|
||||
jdkHome = jdkDownload("https://download.bell-sw.com/java/19.0.1+11/bellsoft-jdk19.0.1+11-linux-amd64-full.tar.gz")
|
||||
}
|
||||
targetPlatform(targetOsxAarch64) {
|
||||
jdkHome = jdkDownload("https://download.bell-sw.com/java/18.0.1+12/bellsoft-jdk18.0.1+12-macos-aarch64-full.tar.gz")
|
||||
jdkHome = jdkDownload("https://download.bell-sw.com/java/19.0.1+11/bellsoft-jdk19.0.1+11-macos-aarch64-full.tar.gz")
|
||||
}
|
||||
targetPlatform(targetOsxX86_64) {
|
||||
jdkHome = jdkDownload("https://download.bell-sw.com/java/18.0.1+12/bellsoft-jdk18.0.1+12-macos-amd64-full.tar.gz")
|
||||
jdkHome = jdkDownload("https://download.bell-sw.com/java/19.0.1+11/bellsoft-jdk19.0.1+11-macos-amd64-full.tar.gz")
|
||||
}
|
||||
targetPlatform(targetWindowsX86_64) {
|
||||
jdkHome = jdkDownload("https://download.bell-sw.com/java/18.0.1+12/bellsoft-jdk18.0.1+12-windows-amd64-full.zip")
|
||||
jdkHome = jdkDownload("https://download.bell-sw.com/java/19.0.1+11/bellsoft-jdk19.0.1+11-windows-amd64-full.zip")
|
||||
}
|
||||
}
|
||||
//Build using pre-downloaded JDKs
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -19,6 +19,6 @@
|
||||
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-rc-3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
290
gradlew
vendored
290
gradlew
vendored
@@ -1,94 +1,132 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# ******************************************************************************
|
||||
# Copyright (C) 2014-2022 Dennis Sheirer
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# 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.
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
# 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.
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
# *****************************************************************************
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
@@ -97,7 +135,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
@@ -105,79 +143,95 @@ location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
||||
25
gradlew.bat
vendored
25
gradlew.bat
vendored
@@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -51,7 +54,7 @@ goto fail
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
@@ -61,28 +64,14 @@ echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,6 @@ package io.github.dsheirer.buffer;
|
||||
|
||||
import io.github.dsheirer.sample.complex.ComplexSamples;
|
||||
import io.github.dsheirer.sample.complex.InterleavedComplexSamples;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
@@ -42,7 +41,7 @@ public class ByteNativeBuffer implements INativeBuffer
|
||||
|
||||
for(int x = 0; x < 256; x++)
|
||||
{
|
||||
LOOKUP_VALUES[x] = (float)(x - 127) / 128.0f;
|
||||
LOOKUP_VALUES[x] = ((float)x - 127.5f) / 128.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,16 +26,20 @@ import java.nio.ByteBuffer;
|
||||
*/
|
||||
public class ByteNativeBufferFactory implements INativeBufferFactory
|
||||
{
|
||||
private static final float DC_FILTER_GAIN = 0.007f; //Normalizes DC over period of ~142 (1 / .007) buffers
|
||||
private float mAverageDc = 0.0f;
|
||||
private DcCorrectionManager mDcCorrectionManager = new DcCorrectionManager();
|
||||
|
||||
@Override
|
||||
public INativeBuffer getBuffer(ByteBuffer samples, long timestamp)
|
||||
{
|
||||
byte[] copy = new byte[samples.capacity()];
|
||||
samples.get(copy);
|
||||
calculateDc(copy);
|
||||
return new ByteNativeBuffer(copy, timestamp, mAverageDc);
|
||||
|
||||
if(mDcCorrectionManager.shouldCalculateDc())
|
||||
{
|
||||
calculateDc(copy);
|
||||
}
|
||||
|
||||
return new ByteNativeBuffer(copy, timestamp, mDcCorrectionManager.getAverageDc());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +49,7 @@ public class ByteNativeBufferFactory implements INativeBufferFactory
|
||||
*/
|
||||
private void calculateDc(byte[] samples)
|
||||
{
|
||||
double dcAccumulator = 0;
|
||||
float dcAccumulator = 0;
|
||||
|
||||
for(byte sample: samples)
|
||||
{
|
||||
@@ -53,9 +57,8 @@ public class ByteNativeBufferFactory implements INativeBufferFactory
|
||||
}
|
||||
|
||||
dcAccumulator /= samples.length;
|
||||
dcAccumulator -= 127.0f;
|
||||
dcAccumulator -= 127.5f;
|
||||
dcAccumulator /= 128.0f;
|
||||
dcAccumulator -= mAverageDc;
|
||||
mAverageDc += (dcAccumulator * DC_FILTER_GAIN);
|
||||
mDcCorrectionManager.adjust(dcAccumulator);
|
||||
}
|
||||
}
|
||||
|
||||
114
src/main/java/io/github/dsheirer/buffer/DcCorrectionManager.java
Normal file
114
src/main/java/io/github/dsheirer/buffer/DcCorrectionManager.java
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* 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.buffer;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Provides DC offset correction value and manages calculation processing interval.
|
||||
*/
|
||||
public class DcCorrectionManager
|
||||
{
|
||||
// private static Logger mLog = LoggerFactory.getLogger(DcCorrectionManager.class);
|
||||
// private DecimalFormat mDecimalFormat = new DecimalFormat("0.00000");
|
||||
|
||||
/**
|
||||
* Time (delay) interval for running DC removal calculations
|
||||
*/
|
||||
private static final long DC_PROCESSING_INTERVAL = TimeUnit.SECONDS.toMillis(50);
|
||||
|
||||
/**
|
||||
* Number of buffers to process per DC calculation processing interval.
|
||||
*/
|
||||
private static final int DC_CALCULATIONS_PER_INTERVAL = 5;
|
||||
|
||||
/**
|
||||
* DC offset processing residual threshold for ending DC processing interval
|
||||
*/
|
||||
private static final float TARGET_DC_OFFSET_REMAINING = 0.0001f;
|
||||
|
||||
/**
|
||||
* Number of DC calculations remaining in the current interval
|
||||
*/
|
||||
private int mDcCalculationsRemaining = DC_CALCULATIONS_PER_INTERVAL; //Initial value for coarse correction
|
||||
|
||||
/**
|
||||
* Last time DC offset calculation interval ran
|
||||
*/
|
||||
private long mLastDcCalculationTimestamp = 0;
|
||||
|
||||
/**
|
||||
* DC offset calculation gain.
|
||||
*/
|
||||
private static final float DC_FILTER_GAIN = 0.05f;
|
||||
|
||||
/**
|
||||
* Current DC offset correction value
|
||||
*/
|
||||
private float mAverageDc = 0.0f;
|
||||
|
||||
public float getAverageDc()
|
||||
{
|
||||
return mAverageDc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the average DC based on the current calculated DC offset present in a sample buffer.
|
||||
* @param calculatedDc for the current sample buffer
|
||||
*/
|
||||
public void adjust(float calculatedDc)
|
||||
{
|
||||
//Calculate the average scaled DC offset so that it can be applied in the native buffer's converted samples
|
||||
float residualOffsetToRemove = calculatedDc - mAverageDc;
|
||||
|
||||
mAverageDc += (residualOffsetToRemove * DC_FILTER_GAIN);
|
||||
|
||||
if(Math.abs(residualOffsetToRemove) < TARGET_DC_OFFSET_REMAINING)
|
||||
{
|
||||
mDcCalculationsRemaining--;
|
||||
}
|
||||
//
|
||||
// mLog.info("DC: " + mDecimalFormat.format(mAverageDc) +
|
||||
// " RES:" + mDecimalFormat.format(residualOffsetToRemove) +
|
||||
// " REM:" + mDcCalculationsRemaining);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if a DC offset calculation for a buffer should be performed.
|
||||
*/
|
||||
public boolean shouldCalculateDc()
|
||||
{
|
||||
if(System.currentTimeMillis() > (mLastDcCalculationTimestamp + DC_PROCESSING_INTERVAL))
|
||||
{
|
||||
if(mDcCalculationsRemaining > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Reset the number of buffers to calculate and the timestamp
|
||||
mDcCalculationsRemaining = DC_CALCULATIONS_PER_INTERVAL;
|
||||
mLastDcCalculationTimestamp = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -20,14 +20,51 @@
|
||||
package io.github.dsheirer.buffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Implements a factory for creating SignedByteNativeBuffer instances
|
||||
*/
|
||||
public class SignedByteNativeBufferFactory implements INativeBufferFactory
|
||||
{
|
||||
private static final float DC_FILTER_GAIN = 0.02f; //Normalizes DC over period of ~50 (1 / .02) buffers
|
||||
/**
|
||||
* DC removal calculations will run once a minute
|
||||
*/
|
||||
private static final long DC_PROCESSING_INTERVAL = TimeUnit.SECONDS.toMillis(60);
|
||||
|
||||
/**
|
||||
* Number of buffers to process per DC calculation processing interval.
|
||||
*/
|
||||
private static final int DC_CALCULATIONS_PER_INTERVAL = 5;
|
||||
|
||||
/**
|
||||
* DC offset processing residual threshold for ending DC processing interval
|
||||
*/
|
||||
private static final float TARGET_DC_OFFSET_REMAINING = 0.0002f;
|
||||
|
||||
/**
|
||||
* Number of DC calculations remaining in the current interval
|
||||
*/
|
||||
private int mDcCalculationsRemaining = DC_CALCULATIONS_PER_INTERVAL; //Initial value for coarse correction
|
||||
|
||||
/**
|
||||
* Last time DC offset calculation interval ran
|
||||
*/
|
||||
private long mLastDcCalculationTimestamp = 0;
|
||||
|
||||
/**
|
||||
* DC offset calculation gain.
|
||||
*/
|
||||
private static final float DC_FILTER_GAIN = 0.05f;
|
||||
|
||||
/**
|
||||
* Current DC offset correction for Inphase samples
|
||||
*/
|
||||
private float mIAverageDc = 0.0f;
|
||||
|
||||
/**
|
||||
* Current DC offset correction for Quadrature samples
|
||||
*/
|
||||
private float mQAverageDc = 0.0f;
|
||||
|
||||
@Override
|
||||
@@ -35,10 +72,37 @@ public class SignedByteNativeBufferFactory implements INativeBufferFactory
|
||||
{
|
||||
byte[] copy = new byte[samples.capacity()];
|
||||
samples.get(copy);
|
||||
calculateDc(copy);
|
||||
|
||||
if(shouldCalculateDc())
|
||||
{
|
||||
calculateDc(copy);
|
||||
}
|
||||
|
||||
return new SignedByteNativeBuffer(copy, timestamp, mIAverageDc, mQAverageDc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if a DC offset calculation for a buffer should be performed.
|
||||
*/
|
||||
private boolean shouldCalculateDc()
|
||||
{
|
||||
if(System.currentTimeMillis() > (mLastDcCalculationTimestamp + DC_PROCESSING_INTERVAL))
|
||||
{
|
||||
if(mDcCalculationsRemaining > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Reset the number of buffers to calculate and the timestamp
|
||||
mDcCalculationsRemaining = DC_CALCULATIONS_PER_INTERVAL;
|
||||
mLastDcCalculationTimestamp = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the average DC in the sample stream so that it can be subtracted from the samples when the
|
||||
* native buffer is used.
|
||||
@@ -46,8 +110,8 @@ public class SignedByteNativeBufferFactory implements INativeBufferFactory
|
||||
*/
|
||||
private void calculateDc(byte[] samples)
|
||||
{
|
||||
double iDcAccumulator = 0;
|
||||
double qDcAccumulator = 0;
|
||||
float iDcAccumulator = 0;
|
||||
float qDcAccumulator = 0;
|
||||
|
||||
for(int x = 0; x < samples.length; x += 2)
|
||||
{
|
||||
@@ -64,5 +128,10 @@ public class SignedByteNativeBufferFactory implements INativeBufferFactory
|
||||
qDcAccumulator /= 128.0f;
|
||||
qDcAccumulator -= mQAverageDc;
|
||||
mQAverageDc += (qDcAccumulator * DC_FILTER_GAIN);
|
||||
|
||||
if(Math.abs(iDcAccumulator) < TARGET_DC_OFFSET_REMAINING && Math.abs(qDcAccumulator) < TARGET_DC_OFFSET_REMAINING)
|
||||
{
|
||||
mDcCalculationsRemaining--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package io.github.dsheirer.buffer.airspy;
|
||||
|
||||
import io.github.dsheirer.buffer.DcCorrectionManager;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
@@ -26,40 +27,61 @@ import java.nio.ByteBuffer;
|
||||
*/
|
||||
public class ScalarPackedSampleConverter implements IAirspySampleConverter
|
||||
{
|
||||
private static final float DC_FILTER_GAIN = 0.007f; //Normalizes DC over period of ~142 (1 / .007) buffers
|
||||
private float mAverageDc = 0.0f;
|
||||
/**
|
||||
* Manages DC calculations and processing interval
|
||||
*/
|
||||
private DcCorrectionManager mDcCalculationManager = new DcCorrectionManager();
|
||||
|
||||
@Override
|
||||
public short[] convert(ByteBuffer buffer)
|
||||
{
|
||||
boolean shouldCalculateDc = mDcCalculationManager.shouldCalculateDc();
|
||||
|
||||
int offset = 0;
|
||||
long dcAccumulator = 0;
|
||||
short sample;
|
||||
short[] samples;
|
||||
byte b1, b2, b3;
|
||||
|
||||
samples = new short[buffer.capacity() / 3 * 2];
|
||||
|
||||
for(int x = 0; x < samples.length; x += 2)
|
||||
if(shouldCalculateDc)
|
||||
{
|
||||
b1 = buffer.get(offset++);
|
||||
b2 = buffer.get(offset++);
|
||||
b3 = buffer.get(offset++);
|
||||
long dcAccumulator = 0;
|
||||
|
||||
sample = (short)(((b1 & 0xFF) << 4) | ((b2 & 0xF0) >> 4));
|
||||
samples[x] = sample;
|
||||
dcAccumulator += sample;
|
||||
for(int x = 0; x < samples.length; x += 2)
|
||||
{
|
||||
b1 = buffer.get(offset++);
|
||||
b2 = buffer.get(offset++);
|
||||
b3 = buffer.get(offset++);
|
||||
|
||||
sample = (short)(((b2 & 0xF) << 8) | (b3 & 0xFF));
|
||||
samples[x] = sample;
|
||||
dcAccumulator += sample;
|
||||
sample = (short)(((b1 & 0xFF) << 4) | ((b2 & 0xF0) >> 4));
|
||||
samples[x] = sample;
|
||||
dcAccumulator += sample;
|
||||
|
||||
sample = (short)(((b2 & 0xF) << 8) | (b3 & 0xFF));
|
||||
samples[x] = sample;
|
||||
dcAccumulator += sample;
|
||||
}
|
||||
|
||||
float averageDcNow = ((float)dcAccumulator / (float)samples.length) - 2048.0f;
|
||||
averageDcNow *= AirspyBufferIterator.SCALE_SIGNED_12_BIT_TO_FLOAT;
|
||||
mDcCalculationManager.adjust(averageDcNow);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int x = 0; x < samples.length; x += 2)
|
||||
{
|
||||
b1 = buffer.get(offset++);
|
||||
b2 = buffer.get(offset++);
|
||||
b3 = buffer.get(offset++);
|
||||
|
||||
//Calculate the average scaled DC offset so that it can be applied in the native buffer's converted samples
|
||||
float averageDcNow = ((float)dcAccumulator / (float)samples.length) - 2048.0f;
|
||||
averageDcNow *= AirspyBufferIterator.SCALE_SIGNED_12_BIT_TO_FLOAT;
|
||||
averageDcNow -= mAverageDc;
|
||||
mAverageDc += (averageDcNow * DC_FILTER_GAIN);
|
||||
sample = (short)(((b1 & 0xFF) << 4) | ((b2 & 0xF0) >> 4));
|
||||
samples[x] = sample;
|
||||
|
||||
sample = (short)(((b2 & 0xF) << 8) | (b3 & 0xFF));
|
||||
samples[x] = sample;
|
||||
}
|
||||
}
|
||||
|
||||
return samples;
|
||||
}
|
||||
@@ -67,7 +89,7 @@ public class ScalarPackedSampleConverter implements IAirspySampleConverter
|
||||
@Override
|
||||
public float getAverageDc()
|
||||
{
|
||||
return mAverageDc;
|
||||
return mDcCalculationManager.getAverageDc();
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package io.github.dsheirer.buffer.airspy;
|
||||
|
||||
import io.github.dsheirer.buffer.DcCorrectionManager;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
@@ -26,34 +27,50 @@ import java.nio.ByteBuffer;
|
||||
*/
|
||||
public class ScalarUnpackedSampleConverter implements IAirspySampleConverter
|
||||
{
|
||||
private static final float DC_FILTER_GAIN = 0.007f; //Normalizes DC over period of ~142 (1 / .007) buffers
|
||||
private float mAverageDc = 0.0f;
|
||||
/**
|
||||
* Manages DC calculations and processing interval
|
||||
*/
|
||||
private DcCorrectionManager mDcCalculationManager = new DcCorrectionManager();
|
||||
|
||||
@Override
|
||||
public short[] convert(ByteBuffer buffer)
|
||||
{
|
||||
boolean shouldCalculateDc = mDcCalculationManager.shouldCalculateDc();
|
||||
|
||||
int offset = 0;
|
||||
long dcAccumulator = 0;
|
||||
short sample;
|
||||
short[] samples;
|
||||
byte b1, b2;
|
||||
|
||||
samples = new short[buffer.capacity() / 2];
|
||||
|
||||
for(int x = 0; x < samples.length; x++)
|
||||
if(shouldCalculateDc)
|
||||
{
|
||||
b1 = buffer.get(offset++);
|
||||
b2 = buffer.get(offset++);
|
||||
sample = (short)(((b2 & 0x0F) << 8) | (b1 & 0xFF));
|
||||
samples[x] = sample;
|
||||
dcAccumulator += sample;
|
||||
}
|
||||
long dcAccumulator = 0;
|
||||
|
||||
//Calculate the average scaled DC offset so that it can be applied in the native buffer's converted samples
|
||||
float averageDcNow = ((float)dcAccumulator / (float)samples.length) - 2048.0f;
|
||||
averageDcNow *= AirspyBufferIterator.SCALE_SIGNED_12_BIT_TO_FLOAT;
|
||||
averageDcNow -= mAverageDc;
|
||||
mAverageDc += (averageDcNow * DC_FILTER_GAIN);
|
||||
for(int x = 0; x < samples.length; x++)
|
||||
{
|
||||
b1 = buffer.get(offset++);
|
||||
b2 = buffer.get(offset++);
|
||||
sample = (short)(((b2 & 0x0F) << 8) | (b1 & 0xFF));
|
||||
samples[x] = sample;
|
||||
dcAccumulator += sample;
|
||||
}
|
||||
|
||||
float averageDcNow = ((float)dcAccumulator / (float)samples.length) - 2048.0f;
|
||||
averageDcNow *= AirspyBufferIterator.SCALE_SIGNED_12_BIT_TO_FLOAT;
|
||||
mDcCalculationManager.adjust(averageDcNow);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int x = 0; x < samples.length; x++)
|
||||
{
|
||||
b1 = buffer.get(offset++);
|
||||
b2 = buffer.get(offset++);
|
||||
sample = (short)(((b2 & 0x0F) << 8) | (b1 & 0xFF));
|
||||
samples[x] = sample;
|
||||
}
|
||||
}
|
||||
|
||||
return samples;
|
||||
}
|
||||
@@ -61,6 +78,6 @@ public class ScalarUnpackedSampleConverter implements IAirspySampleConverter
|
||||
@Override
|
||||
public float getAverageDc()
|
||||
{
|
||||
return mAverageDc;
|
||||
return mDcCalculationManager.getAverageDc();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,25 +19,29 @@
|
||||
|
||||
package io.github.dsheirer.buffer.airspy;
|
||||
|
||||
import io.github.dsheirer.buffer.DcCorrectionManager;
|
||||
import java.nio.ByteBuffer;
|
||||
import jdk.incubator.vector.ShortVector;
|
||||
import jdk.incubator.vector.VectorOperators;
|
||||
import jdk.incubator.vector.VectorSpecies;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* Scalar implementation of airspy sample converter for un-packed samples.
|
||||
*/
|
||||
public class VectorUnpackedSampleConverter implements IAirspySampleConverter
|
||||
{
|
||||
private static final VectorSpecies<Short> VECTOR_SPECIES = ShortVector.SPECIES_PREFERRED;
|
||||
private static final float DC_FILTER_GAIN = 0.007f; //Normalizes DC over period of ~142 (1 / .007) buffers
|
||||
private float mAverageDc = 0.0f;
|
||||
|
||||
/**
|
||||
* Manages DC calculations and processing interval
|
||||
*/
|
||||
private DcCorrectionManager mDcCalculationManager = new DcCorrectionManager();
|
||||
|
||||
@Override
|
||||
public short[] convert(ByteBuffer buffer)
|
||||
{
|
||||
long dcAccumulator = 0;
|
||||
boolean shouldCalculateDc = mDcCalculationManager.shouldCalculateDc();
|
||||
|
||||
short sample;
|
||||
short[] samples;
|
||||
byte b1, b2;
|
||||
@@ -53,44 +57,73 @@ public class VectorUnpackedSampleConverter implements IAirspySampleConverter
|
||||
short[] bytes1 = new short[VECTOR_SPECIES.length()];
|
||||
short[] bytes2 = new short[VECTOR_SPECIES.length()];
|
||||
|
||||
for(; samplesOffset < VECTOR_SPECIES.loopBound(samples.length); samplesOffset += VECTOR_SPECIES.length())
|
||||
if(shouldCalculateDc)
|
||||
{
|
||||
bytesOffset = 0;
|
||||
long dcAccumulator = 0;
|
||||
|
||||
while(bytesOffset < VECTOR_SPECIES.length())
|
||||
for(; samplesOffset < VECTOR_SPECIES.loopBound(samples.length); samplesOffset += VECTOR_SPECIES.length())
|
||||
{
|
||||
bytes1[bytesOffset] = (short)(buffer.get(rawPointer++) & 0xFF);
|
||||
bytes2[bytesOffset++] = (short)(buffer.get(rawPointer++) & 0x0F);
|
||||
bytesOffset = 0;
|
||||
|
||||
while(bytesOffset < VECTOR_SPECIES.length())
|
||||
{
|
||||
bytes1[bytesOffset] = (short)(buffer.get(rawPointer++) & 0xFF);
|
||||
bytes2[bytesOffset++] = (short)(buffer.get(rawPointer++) & 0x0F);
|
||||
}
|
||||
|
||||
vector = ShortVector.fromArray(VECTOR_SPECIES, bytes1, 0)
|
||||
.or(ShortVector.fromArray(VECTOR_SPECIES, bytes2, 0).lanewise(VectorOperators.LSHL, 8));
|
||||
dcAccumulator += vector.reduceLanes(VectorOperators.ADD);
|
||||
vector.intoArray(samples, samplesOffset);
|
||||
}
|
||||
|
||||
vector = ShortVector.fromArray(VECTOR_SPECIES, bytes1, 0)
|
||||
.or(ShortVector.fromArray(VECTOR_SPECIES, bytes2, 0).lanewise(VectorOperators.LSHL, 8));
|
||||
dcAccumulator += vector.reduceLanes(VectorOperators.ADD);
|
||||
vector.intoArray(samples, samplesOffset);
|
||||
}
|
||||
for(; samplesOffset < samples.length; samplesOffset++)
|
||||
{
|
||||
b1 = buffer.get(rawPointer++);
|
||||
b2 = buffer.get(rawPointer++);
|
||||
|
||||
for(; samplesOffset < samples.length; samplesOffset++)
|
||||
sample = (short)(((b2 & 0x0F) << 8) | (b1 & 0xFF));
|
||||
samples[samplesOffset] = sample;
|
||||
dcAccumulator += sample;
|
||||
}
|
||||
|
||||
float averageDcNow = ((float)dcAccumulator / (float)samples.length) - 2048.0f;
|
||||
averageDcNow *= AirspyBufferIterator.SCALE_SIGNED_12_BIT_TO_FLOAT;
|
||||
mDcCalculationManager.adjust(averageDcNow);
|
||||
}
|
||||
else
|
||||
{
|
||||
b1 = buffer.get(rawPointer++);
|
||||
b2 = buffer.get(rawPointer++);
|
||||
for(; samplesOffset < VECTOR_SPECIES.loopBound(samples.length); samplesOffset += VECTOR_SPECIES.length())
|
||||
{
|
||||
bytesOffset = 0;
|
||||
|
||||
sample = (short)(((b2 & 0x0F) << 8) | (b1 & 0xFF));
|
||||
samples[samplesOffset] = sample;
|
||||
dcAccumulator += sample;
|
||||
while(bytesOffset < VECTOR_SPECIES.length())
|
||||
{
|
||||
bytes1[bytesOffset] = (short)(buffer.get(rawPointer++) & 0xFF);
|
||||
bytes2[bytesOffset++] = (short)(buffer.get(rawPointer++) & 0x0F);
|
||||
}
|
||||
|
||||
vector = ShortVector.fromArray(VECTOR_SPECIES, bytes1, 0)
|
||||
.or(ShortVector.fromArray(VECTOR_SPECIES, bytes2, 0).lanewise(VectorOperators.LSHL, 8));
|
||||
vector.intoArray(samples, samplesOffset);
|
||||
}
|
||||
|
||||
for(; samplesOffset < samples.length; samplesOffset++)
|
||||
{
|
||||
b1 = buffer.get(rawPointer++);
|
||||
b2 = buffer.get(rawPointer++);
|
||||
|
||||
sample = (short)(((b2 & 0x0F) << 8) | (b1 & 0xFF));
|
||||
samples[samplesOffset] = sample;
|
||||
}
|
||||
}
|
||||
|
||||
//Calculate the average scaled DC offset so that it can be applied in the native buffer's converted samples
|
||||
float averageDcNow = ((float)dcAccumulator / (float)samples.length) - 2048.0f;
|
||||
averageDcNow *= AirspyBufferIterator.SCALE_SIGNED_12_BIT_TO_FLOAT;
|
||||
averageDcNow -= mAverageDc;
|
||||
mAverageDc += (averageDcNow * DC_FILTER_GAIN);
|
||||
|
||||
return samples;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAverageDc()
|
||||
{
|
||||
return mAverageDc;
|
||||
return mDcCalculationManager.getAverageDc();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 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
|
||||
@@ -14,21 +14,20 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
* ****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.module.log;
|
||||
|
||||
import io.github.dsheirer.module.Module;
|
||||
import io.github.dsheirer.util.TimeStamp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Path;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public abstract class EventLogger extends Module
|
||||
{
|
||||
@@ -78,9 +77,6 @@ public abstract class EventLogger extends Module
|
||||
sb.append(mFileNameSuffix);
|
||||
|
||||
mLogFileName = sb.toString();
|
||||
|
||||
mLog.info("Creating log file:" + mLogFileName);
|
||||
|
||||
mLogFile = new OutputStreamWriter(new FileOutputStream(mLogFileName));
|
||||
|
||||
write(getHeader());
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* 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.
|
||||
* 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/>
|
||||
******************************************************************************/
|
||||
* 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.settings;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
|
||||
public class ColorSetting extends Setting
|
||||
{
|
||||
@@ -91,7 +91,7 @@ public class ColorSetting extends Setting
|
||||
return new Color(temp.getRed(),
|
||||
temp.getGreen(),
|
||||
temp.getBlue(),
|
||||
mAlpha);
|
||||
getColorSettingName().getTranslucency());
|
||||
}
|
||||
|
||||
public void setColor(Color color)
|
||||
@@ -111,84 +111,81 @@ public class ColorSetting extends Setting
|
||||
|
||||
public enum ColorSettingName
|
||||
{
|
||||
CHANNEL_CONFIG(getTranslucent(Color.LIGHT_GRAY, CONFIG_TRANSLUCENCY),
|
||||
"Channel", "Channel Color"),
|
||||
CHANNEL_CONFIG_PROCESSING(getTranslucent(Color.GREEN, CONFIG_TRANSLUCENCY),
|
||||
"Channel Processing", "Processing Channel Color"),
|
||||
CHANNEL_CONFIG_SELECTED(getTranslucent(Color.BLUE, CONFIG_TRANSLUCENCY),
|
||||
"Channel Selected", "Selected Channel Color"),
|
||||
|
||||
CHANNEL_STATE_BACKGROUND(Color.BLACK, "Background",
|
||||
"Channel State Background"),
|
||||
CHANNEL_STATE_GRADIENT_TOP_CALL(Color.BLACK,
|
||||
"Call Gradient Top", "Channel Call State Gradient Top"),
|
||||
CHANNEL_STATE_GRADIENT_MIDDLE_CALL(Color.BLUE,
|
||||
"Call Gradient Middle", "Channel Call State Gradient Middle"),
|
||||
CHANNEL_STATE_GRADIENT_TOP_CONTROL(Color.BLACK,
|
||||
"Control Gradient Top", "Channel Control State Gradient Top"),
|
||||
CHANNEL_STATE_GRADIENT_MIDDLE_CONTROL(new Color(0xC64F00),
|
||||
"Control Gradient Middle", "Channel Control State Gradient Middle"),
|
||||
CHANNEL_STATE_GRADIENT_TOP_DATA(Color.BLACK,
|
||||
"Data Gradient Top", "Channel Data State Gradient Top"),
|
||||
CHANNEL_STATE_GRADIENT_MIDDLE_DATA(new Color(0xCC00CC),
|
||||
"Data Gradient Middle", "Channel Data State Gradient Middle"),
|
||||
CHANNEL_STATE_GRADIENT_TOP_FADE(Color.BLACK,
|
||||
"Fade Gradient Top", "Channel Fade State Gradient Top"),
|
||||
CHANNEL_STATE_GRADIENT_MIDDLE_FADE(Color.DARK_GRAY,
|
||||
"Fade Gradient Middle", "Channel Fade State Gradient Middle"),
|
||||
CHANNEL_STATE_GRADIENT_TOP_IDLE(Color.BLACK,
|
||||
"Idle Gradient Top", "Channel Idle State Gradient Top"),
|
||||
CHANNEL_STATE_GRADIENT_MIDDLE_IDLE(Color.DARK_GRAY,
|
||||
"Idle Gradient Middle", "Channel Idle State Gradient Middle"),
|
||||
CHANNEL_STATE_GRADIENT_TOP_NO_TUNER(Color.RED,
|
||||
"No Tuner Gradient Top", "Channel No Tuner State Gradient Top"),
|
||||
CHANNEL_STATE_GRADIENT_MIDDLE_NO_TUNER(new Color(0x990000),
|
||||
"No Tuner Gradient Middle", "Channel No Tuner State Gradient Middle"),
|
||||
CHANNEL_STATE_LABEL_DETAILS(Color.LIGHT_GRAY,
|
||||
"Details", "Details Label Color"),
|
||||
CHANNEL_STATE_LABEL_DECODER(Color.GREEN,
|
||||
"Decoder", "Decoder Label Color"),
|
||||
CHANNEL_STATE_LABEL_AUX_DECODER(Color.YELLOW,
|
||||
"Aux Decoder", "Aux Decoder Label Color"),
|
||||
CHANNEL_STATE_SELECTED_CHANNEL(Color.YELLOW,
|
||||
"Selected Channel Indicator", "Selected Channel Indicator Color"),
|
||||
|
||||
SPECTRUM_BACKGROUND(Color.BLACK,
|
||||
"Background", "Spectrum Background Color"),
|
||||
SPECTRUM_CURSOR(Color.ORANGE,
|
||||
"Cursor", "Spectrum Cursor Color"),
|
||||
SPECTRUM_GRADIENT_BOTTOM(getTranslucent(Color.GREEN, SPECTRUM_TRANSLUCENCY),
|
||||
"Gradient Bottom", "Spectrum Gradient Bottom Color"),
|
||||
SPECTRUM_GRADIENT_TOP(getTranslucent(Color.WHITE, SPECTRUM_TRANSLUCENCY),
|
||||
"Gradient Top", "Spectrum Gradient Top Color"),
|
||||
SPECTRUM_LINE(getTranslucent(Color.LIGHT_GRAY, SPECTRUM_TRANSLUCENCY),
|
||||
"Line", "Spectrum Lines and Text Color"),
|
||||
|
||||
UNKNOWN(Color.RED, "Unknown", "Unknown Setting Color");
|
||||
CHANNEL_CONFIG(Color.LIGHT_GRAY, CONFIG_TRANSLUCENCY, "Channel", "Channel Color"),
|
||||
CHANNEL_CONFIG_PROCESSING(Color.GREEN, CONFIG_TRANSLUCENCY, "Channel Processing", "Processing Channel Color"),
|
||||
CHANNEL_CONFIG_SELECTED(Color.BLUE, CONFIG_TRANSLUCENCY, "Channel Selected", "Selected Channel Color"),
|
||||
CHANNEL_STATE_BACKGROUND(Color.BLACK, NO_TRANSLUCENCY, "Background", "Channel State Background"),
|
||||
CHANNEL_STATE_GRADIENT_TOP_CALL(Color.BLACK, NO_TRANSLUCENCY, "Call Gradient Top", "Channel Call State Gradient Top"),
|
||||
CHANNEL_STATE_GRADIENT_MIDDLE_CALL(Color.BLUE, NO_TRANSLUCENCY, "Call Gradient Middle", "Channel Call State Gradient Middle"),
|
||||
CHANNEL_STATE_GRADIENT_TOP_CONTROL(Color.BLACK, NO_TRANSLUCENCY, "Control Gradient Top", "Channel Control State Gradient Top"),
|
||||
CHANNEL_STATE_GRADIENT_MIDDLE_CONTROL(new Color(0xC64F00), NO_TRANSLUCENCY, "Control Gradient Middle", "Channel Control State Gradient Middle"),
|
||||
CHANNEL_STATE_GRADIENT_TOP_DATA(Color.BLACK, NO_TRANSLUCENCY, "Data Gradient Top", "Channel Data State Gradient Top"),
|
||||
CHANNEL_STATE_GRADIENT_MIDDLE_DATA(new Color(0xCC00CC), NO_TRANSLUCENCY, "Data Gradient Middle", "Channel Data State Gradient Middle"),
|
||||
CHANNEL_STATE_GRADIENT_TOP_FADE(Color.BLACK, NO_TRANSLUCENCY, "Fade Gradient Top", "Channel Fade State Gradient Top"),
|
||||
CHANNEL_STATE_GRADIENT_MIDDLE_FADE(Color.DARK_GRAY, NO_TRANSLUCENCY, "Fade Gradient Middle", "Channel Fade State Gradient Middle"),
|
||||
CHANNEL_STATE_GRADIENT_TOP_IDLE(Color.BLACK, NO_TRANSLUCENCY, "Idle Gradient Top", "Channel Idle State Gradient Top"),
|
||||
CHANNEL_STATE_GRADIENT_MIDDLE_IDLE(Color.DARK_GRAY, NO_TRANSLUCENCY, "Idle Gradient Middle", "Channel Idle State Gradient Middle"),
|
||||
CHANNEL_STATE_GRADIENT_TOP_NO_TUNER(Color.RED, NO_TRANSLUCENCY, "No Tuner Gradient Top", "Channel No Tuner State Gradient Top"),
|
||||
CHANNEL_STATE_GRADIENT_MIDDLE_NO_TUNER(new Color(0x990000), NO_TRANSLUCENCY, "No Tuner Gradient Middle", "Channel No Tuner State Gradient Middle"),
|
||||
CHANNEL_STATE_LABEL_DETAILS(Color.LIGHT_GRAY, NO_TRANSLUCENCY, "Details", "Details Label Color"),
|
||||
CHANNEL_STATE_LABEL_DECODER(Color.GREEN, NO_TRANSLUCENCY, "Decoder", "Decoder Label Color"),
|
||||
CHANNEL_STATE_LABEL_AUX_DECODER(Color.YELLOW, NO_TRANSLUCENCY, "Aux Decoder", "Aux Decoder Label Color"),
|
||||
CHANNEL_STATE_SELECTED_CHANNEL(Color.YELLOW, NO_TRANSLUCENCY, "Selected Channel Indicator", "Selected Channel Indicator Color"),
|
||||
SPECTRUM_BACKGROUND(Color.BLACK, NO_TRANSLUCENCY, "Background", "Spectrum Background Color"),
|
||||
SPECTRUM_CURSOR(Color.ORANGE, NO_TRANSLUCENCY, "Cursor", "Spectrum Cursor Color"),
|
||||
SPECTRUM_GRADIENT_BOTTOM(Color.GREEN, SPECTRUM_TRANSLUCENCY, "Gradient Bottom", "Spectrum Gradient Bottom Color"),
|
||||
SPECTRUM_GRADIENT_TOP(Color.WHITE, SPECTRUM_TRANSLUCENCY, "Gradient Top", "Spectrum Gradient Top Color"),
|
||||
SPECTRUM_LINE(Color.LIGHT_GRAY, SPECTRUM_TRANSLUCENCY, "Line", "Spectrum Lines and Text Color"),
|
||||
UNKNOWN(Color.RED, NO_TRANSLUCENCY,"Unknown", "Unknown Setting Color");
|
||||
|
||||
private Color mDefaultColor;
|
||||
private int mTranslucency;
|
||||
private String mLabel;
|
||||
private String mDialogTitle;
|
||||
|
||||
private ColorSettingName(Color defaultColor,
|
||||
String label,
|
||||
String dialogTitle)
|
||||
/**
|
||||
* Enumeration of color names used in user interface, primarily in the spectral displays.
|
||||
* @param defaultColor to use and for resets.
|
||||
* @param translucency value for the color.
|
||||
* @param label for menu items
|
||||
* @param dialogTitle for selecting in the color chooser.
|
||||
*/
|
||||
ColorSettingName(Color defaultColor, int translucency, String label, String dialogTitle)
|
||||
{
|
||||
mDefaultColor = defaultColor;
|
||||
mTranslucency = translucency;
|
||||
mLabel = label;
|
||||
mDialogTitle = dialogTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default color to use when resetting to default.
|
||||
*/
|
||||
public Color getDefaultColor()
|
||||
{
|
||||
return mDefaultColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translucency to apply to the color
|
||||
*/
|
||||
public int getTranslucency()
|
||||
{
|
||||
return mTranslucency;
|
||||
}
|
||||
|
||||
/**
|
||||
* Label for the setting
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Title to use in dialogs
|
||||
* @return title
|
||||
*/
|
||||
public String getDialogTitle()
|
||||
{
|
||||
return mDialogTitle;
|
||||
|
||||
@@ -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,19 +194,10 @@ 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
|
||||
*/
|
||||
public static SourceEvent lockedState()
|
||||
public static SourceEvent lockedSampleRateState()
|
||||
{
|
||||
return new SourceEvent(Event.NOTIFICATION_FREQUENCY_AND_SAMPLE_RATE_LOCKED, 1);
|
||||
}
|
||||
@@ -215,7 +205,7 @@ public class SourceEvent
|
||||
/**
|
||||
* Creates a new unlocked state change event
|
||||
*/
|
||||
public static SourceEvent unlockedState()
|
||||
public static SourceEvent unlockedSampleRateState()
|
||||
{
|
||||
return new SourceEvent(Event.NOTIFICATION_FREQUENCY_AND_SAMPLE_RATE_UNLOCKED, 0);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,11 +36,11 @@ import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
|
||||
import io.github.dsheirer.source.tuner.frequency.FrequencyController;
|
||||
import io.github.dsheirer.source.tuner.frequency.FrequencyController.Tunable;
|
||||
import io.github.dsheirer.source.tuner.manager.FrequencyErrorCorrectionManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.SortedSet;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public abstract class TunerController implements Tunable, ISourceEventProcessor, ISourceEventListener,
|
||||
INativeBufferProvider, Listener<INativeBuffer>, ITunerErrorListener
|
||||
@@ -70,6 +70,17 @@ public abstract class TunerController implements Tunable, ISourceEventProcessor,
|
||||
mFrequencyErrorCorrectionManager = new FrequencyErrorCorrectionManager(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock for the frequency controller. This should only be used by the channel source manager to lock access to the
|
||||
* frequency controller while creating a channel source, to block multi-threaded access to the frequency controller
|
||||
* which might put the center tuned frequency value in an indeterminant state.
|
||||
* @return frequency controller lock
|
||||
*/
|
||||
public ReentrantLock getFrequencyControllerLock()
|
||||
{
|
||||
return mFrequencyController.getFrequencyControllerLock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Frequency correction manager for this tuner controller.
|
||||
*/
|
||||
@@ -182,29 +193,30 @@ public abstract class TunerController implements Tunable, ISourceEventProcessor,
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the frequency and sample rate controls are locked by another process. User interface controls
|
||||
* should monitor source events and check the locked state via this method to correctly render the enabled state
|
||||
* of the frequency and sample rate controls.
|
||||
* Indicates if the sample rate control is locked by another process. User interface controls should monitor source
|
||||
* events and check the locked state via this method to correctly render the enabled state of the sample rate control.
|
||||
*
|
||||
* @return true if the tuner controller is locked.
|
||||
*/
|
||||
public boolean isLocked()
|
||||
public boolean isLockedSampleRate()
|
||||
{
|
||||
return mFrequencyController.isLocked();
|
||||
//Note: this access is not protected by the mFrequencyControllerLock
|
||||
return mFrequencyController.isSampleRateLocked();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the frequency and sample rate locked state to the locked argument value. This should only be changed
|
||||
* by a downstream consumer of samples to prevent users or other processes from modifying the center frequency
|
||||
* and/or sample rate of the tuner while processing samples.
|
||||
* Sets the sample rate locked state to the locked argument value. This should only be changed by a downstream
|
||||
* consumer of samples to prevent users or other processes from modifying the sample rate of the tuner while
|
||||
* processing samples.
|
||||
*
|
||||
* @param locked true to indicate the tuner controller is in a locked state, otherwise false.
|
||||
*/
|
||||
public void setLocked(boolean locked)
|
||||
public void setLockedSampleRate(boolean locked)
|
||||
{
|
||||
try
|
||||
{
|
||||
mFrequencyController.setLocked(locked);
|
||||
//Note: this access is not protected by the mFrequencyControllerLock
|
||||
mFrequencyController.setSampleRateLocked(locked);
|
||||
}
|
||||
catch(SourceException se)
|
||||
{
|
||||
@@ -214,6 +226,7 @@ public abstract class TunerController implements Tunable, ISourceEventProcessor,
|
||||
|
||||
public int getBandwidth()
|
||||
{
|
||||
//Note: this access is not protected by the mFrequencyControllerLock
|
||||
return mFrequencyController.getBandwidth();
|
||||
}
|
||||
|
||||
@@ -225,7 +238,15 @@ public abstract class TunerController implements Tunable, ISourceEventProcessor,
|
||||
*/
|
||||
public void setFrequency(long frequency) throws SourceException
|
||||
{
|
||||
mFrequencyController.setFrequency(frequency);
|
||||
try
|
||||
{
|
||||
getFrequencyControllerLock().lock();
|
||||
mFrequencyController.setFrequency(frequency);
|
||||
}
|
||||
finally
|
||||
{
|
||||
getFrequencyControllerLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,28 +256,73 @@ public abstract class TunerController implements Tunable, ISourceEventProcessor,
|
||||
*/
|
||||
public long getFrequency()
|
||||
{
|
||||
return mFrequencyController.getFrequency();
|
||||
long frequency;
|
||||
|
||||
try
|
||||
{
|
||||
getFrequencyControllerLock().lock();
|
||||
frequency = mFrequencyController.getFrequency();
|
||||
}
|
||||
finally
|
||||
{
|
||||
getFrequencyControllerLock().unlock();
|
||||
}
|
||||
|
||||
return frequency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTune(long frequency)
|
||||
{
|
||||
return mFrequencyController.canTune(frequency);
|
||||
boolean canTune;
|
||||
|
||||
try
|
||||
{
|
||||
getFrequencyControllerLock().lock();
|
||||
canTune = mFrequencyController.canTune(frequency);
|
||||
}
|
||||
finally
|
||||
{
|
||||
getFrequencyControllerLock().unlock();
|
||||
}
|
||||
|
||||
return canTune;
|
||||
}
|
||||
|
||||
public double getSampleRate()
|
||||
{
|
||||
//Note: this access is not protected by the mFrequencyControllerLock
|
||||
return mFrequencyController.getSampleRate();
|
||||
}
|
||||
|
||||
public double getFrequencyCorrection()
|
||||
{
|
||||
return mFrequencyController.getFrequencyCorrection();
|
||||
double correction;
|
||||
|
||||
try
|
||||
{
|
||||
getFrequencyControllerLock().lock();
|
||||
correction = mFrequencyController.getFrequencyCorrection();
|
||||
}
|
||||
finally
|
||||
{
|
||||
getFrequencyControllerLock().unlock();
|
||||
}
|
||||
|
||||
return correction;
|
||||
}
|
||||
|
||||
public void setFrequencyCorrection(double correction) throws SourceException
|
||||
{
|
||||
mFrequencyController.setFrequencyCorrection(correction);
|
||||
try
|
||||
{
|
||||
getFrequencyControllerLock().lock();
|
||||
mFrequencyController.setFrequencyCorrection(correction);
|
||||
}
|
||||
finally
|
||||
{
|
||||
getFrequencyControllerLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,7 +331,19 @@ public abstract class TunerController implements Tunable, ISourceEventProcessor,
|
||||
*/
|
||||
public long getMinimumFrequency()
|
||||
{
|
||||
return mFrequencyController.getMinimumFrequency();
|
||||
long minimum;
|
||||
|
||||
try
|
||||
{
|
||||
getFrequencyControllerLock().lock();
|
||||
minimum = mFrequencyController.getMinimumFrequency();
|
||||
}
|
||||
finally
|
||||
{
|
||||
getFrequencyControllerLock().unlock();
|
||||
}
|
||||
|
||||
return minimum;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,7 +352,15 @@ public abstract class TunerController implements Tunable, ISourceEventProcessor,
|
||||
*/
|
||||
public void setMinimumFrequency(long minimum)
|
||||
{
|
||||
mFrequencyController.setMinimumFrequency(minimum);
|
||||
try
|
||||
{
|
||||
getFrequencyControllerLock().lock();
|
||||
mFrequencyController.setMinimumFrequency(minimum);
|
||||
}
|
||||
finally
|
||||
{
|
||||
getFrequencyControllerLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,7 +369,19 @@ public abstract class TunerController implements Tunable, ISourceEventProcessor,
|
||||
*/
|
||||
public long getMaximumFrequency()
|
||||
{
|
||||
return mFrequencyController.getMaximumFrequency();
|
||||
long maximum;
|
||||
|
||||
try
|
||||
{
|
||||
getFrequencyControllerLock().lock();
|
||||
maximum = mFrequencyController.getMaximumFrequency();
|
||||
}
|
||||
finally
|
||||
{
|
||||
getFrequencyControllerLock().unlock();
|
||||
}
|
||||
|
||||
return maximum;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -292,17 +390,49 @@ public abstract class TunerController implements Tunable, ISourceEventProcessor,
|
||||
*/
|
||||
public void setMaximumFrequency(long maximum)
|
||||
{
|
||||
mFrequencyController.setMaximumFrequency(maximum);
|
||||
try
|
||||
{
|
||||
getFrequencyControllerLock().lock();
|
||||
mFrequencyController.setMaximumFrequency(maximum);
|
||||
}
|
||||
finally
|
||||
{
|
||||
getFrequencyControllerLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public long getMinTunedFrequency() throws SourceException
|
||||
{
|
||||
return mFrequencyController.getFrequency() - (getUsableBandwidth() / 2);
|
||||
long minTuned;
|
||||
|
||||
try
|
||||
{
|
||||
getFrequencyControllerLock().lock();
|
||||
minTuned = mFrequencyController.getFrequency() - (getUsableBandwidth() / 2);
|
||||
}
|
||||
finally
|
||||
{
|
||||
getFrequencyControllerLock().unlock();
|
||||
}
|
||||
|
||||
return minTuned;
|
||||
}
|
||||
|
||||
public long getMaxTunedFrequency() throws SourceException
|
||||
{
|
||||
return mFrequencyController.getFrequency() + (getUsableBandwidth() / 2);
|
||||
long maxTuned;
|
||||
|
||||
try
|
||||
{
|
||||
getFrequencyControllerLock().lock();
|
||||
maxTuned = mFrequencyController.getFrequency() + (getUsableBandwidth() / 2);
|
||||
}
|
||||
finally
|
||||
{
|
||||
getFrequencyControllerLock().unlock();
|
||||
}
|
||||
|
||||
return maxTuned;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -425,7 +555,7 @@ public abstract class TunerController implements Tunable, ISourceEventProcessor,
|
||||
*/
|
||||
public void addListener( ISourceEventProcessor processor )
|
||||
{
|
||||
mFrequencyController.addListener(processor);
|
||||
mFrequencyController.addSourceEventProcessor(processor);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -433,7 +563,7 @@ public abstract class TunerController implements Tunable, ISourceEventProcessor,
|
||||
*/
|
||||
public void removeListener( ISourceEventProcessor processor )
|
||||
{
|
||||
mFrequencyController.removeFrequencyChangeProcessor(processor);
|
||||
mFrequencyController.removeSourceEventProcessor(processor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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() + "]");
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ 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.ui.TunerEditor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -40,9 +43,6 @@ import javax.swing.JSlider;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Airspy tuner editor/controller
|
||||
@@ -102,7 +102,7 @@ public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfi
|
||||
getTunerStatusLabel().setText(status);
|
||||
getButtonPanel().updateControls();
|
||||
getFrequencyPanel().updateControls();
|
||||
getSampleRateCombo().setEnabled(hasTuner() && !getTuner().getTunerController().isLocked());
|
||||
getSampleRateCombo().setEnabled(hasTuner() && !getTuner().getTunerController().isLockedSampleRate());
|
||||
getTunerInfoButton().setEnabled(hasTuner());
|
||||
updateGainComponents((hasTuner() && hasConfiguration()) ? getConfiguration().getGain() : null);
|
||||
|
||||
@@ -626,7 +626,7 @@ public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfi
|
||||
*/
|
||||
private void updateSampleRateToolTip()
|
||||
{
|
||||
if(hasTuner() && getTuner().getController().isLocked())
|
||||
if(hasTuner() && getTuner().getController().isLockedSampleRate())
|
||||
{
|
||||
mSampleRateCombo.setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -22,12 +22,11 @@ import io.github.dsheirer.source.ISourceEventProcessor;
|
||||
import io.github.dsheirer.source.InvalidFrequencyException;
|
||||
import io.github.dsheirer.source.SourceEvent;
|
||||
import io.github.dsheirer.source.SourceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class FrequencyController
|
||||
{
|
||||
@@ -40,8 +39,12 @@ public class FrequencyController
|
||||
private long mMaximumFrequency = 0;
|
||||
private double mFrequencyCorrection = 0.0d;
|
||||
private double mSampleRate = 0.0d;
|
||||
private boolean mLocked = false;
|
||||
private boolean mSampleRateLocked = false;
|
||||
private List<ISourceEventProcessor> mProcessors = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Lock protecting access to frequency control plane, source event processor subscriptions and event broadcasting
|
||||
*/
|
||||
private ReentrantLock mLock = new ReentrantLock();
|
||||
|
||||
/**
|
||||
@@ -53,6 +56,15 @@ public class FrequencyController
|
||||
mTunable = tunable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lock for controlling access to frequency control plane, event processor subscriptions and source event broadcasts.
|
||||
*/
|
||||
public ReentrantLock getFrequencyControllerLock()
|
||||
{
|
||||
return mLock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare for disposal of this instance.
|
||||
*/
|
||||
@@ -63,36 +75,36 @@ public class FrequencyController
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this frequency controller is locked by a remote process. A locked state indicates that neither
|
||||
* the frequency nor the sample rate should be changed. The remote process will typically be a downstream
|
||||
* Indicates if the sample rate for this frequency controller is locked by a remote process. A locked state
|
||||
* indicates that the sample rate cannot be changed. The remote process will typically be a downstream
|
||||
* consumer of the data produced by the device being controlled (ie polyphase channelizer) that does not want
|
||||
* the sample rate or frequency to be changed while processing is ongoing.
|
||||
* the sample rate to be changed while processing (ie channels have been allocated) is ongoing.
|
||||
*
|
||||
* @return true if locked or false if not locked.
|
||||
*/
|
||||
public boolean isLocked()
|
||||
public boolean isSampleRateLocked()
|
||||
{
|
||||
return mLocked;
|
||||
return mSampleRateLocked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the lock state for this frequency controller. Set to true when a consumer process requires that the
|
||||
* frequency and sample rate controls be locked so that only the singular consumer process makes changes. This
|
||||
* sample rate control be locked so that only the single consumer process makes changes to the sample rate. This
|
||||
* is primarily to lock down user interface controls when the polyphase channelizer is producing channels.
|
||||
*
|
||||
* @param locked state
|
||||
* @param sampleRateLocked state
|
||||
*/
|
||||
public void setLocked(boolean locked) throws SourceException
|
||||
public void setSampleRateLocked(boolean sampleRateLocked) throws SourceException
|
||||
{
|
||||
mLocked = locked;
|
||||
mSampleRateLocked = sampleRateLocked;
|
||||
|
||||
if(mLocked)
|
||||
if(mSampleRateLocked)
|
||||
{
|
||||
broadcast(SourceEvent.lockedState());
|
||||
broadcast(SourceEvent.lockedSampleRateState());
|
||||
}
|
||||
else
|
||||
{
|
||||
broadcast(SourceEvent.unlockedState());
|
||||
broadcast(SourceEvent.unlockedSampleRateState());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +123,7 @@ public class FrequencyController
|
||||
{
|
||||
if(sampleRate != mSampleRate)
|
||||
{
|
||||
if(!mLocked)
|
||||
if(!mSampleRateLocked)
|
||||
{
|
||||
mSampleRate = sampleRate;
|
||||
|
||||
@@ -284,7 +296,7 @@ public class FrequencyController
|
||||
/**
|
||||
* Adds listener to receive frequency change events
|
||||
*/
|
||||
public void addListener(ISourceEventProcessor processor)
|
||||
public void addSourceEventProcessor(ISourceEventProcessor processor)
|
||||
{
|
||||
mLock.lock();
|
||||
|
||||
@@ -304,7 +316,7 @@ public class FrequencyController
|
||||
/**
|
||||
* Removes listener from receiving frequency change events
|
||||
*/
|
||||
public void removeFrequencyChangeProcessor(ISourceEventProcessor processor)
|
||||
public void removeSourceEventProcessor(ISourceEventProcessor processor)
|
||||
{
|
||||
mLock.lock();
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfig
|
||||
getTunerStatusLabel().setText(status);
|
||||
getButtonPanel().updateControls();
|
||||
getFrequencyPanel().updateControls();
|
||||
getSampleRateCombo().setEnabled(hasTuner() && !getTuner().getTunerController().isLocked());
|
||||
getSampleRateCombo().setEnabled(hasTuner() && !getTuner().getTunerController().isLockedSampleRate());
|
||||
updateSampleRateToolTip();
|
||||
getTunerInfoButton().setEnabled(hasTuner());
|
||||
|
||||
@@ -295,7 +295,7 @@ public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfig
|
||||
*/
|
||||
private void updateSampleRateToolTip()
|
||||
{
|
||||
if(hasTuner() && getTuner().getController().isLocked())
|
||||
if(hasTuner() && getTuner().getController().isLockedSampleRate())
|
||||
{
|
||||
mSampleRateCombo.setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,38 +93,48 @@ public class HeterodyneChannelSourceManager extends ChannelSourceManager
|
||||
return null;
|
||||
}
|
||||
|
||||
if(CenterFrequencyCalculator.canTune(tunerChannel, mTunerController, mTunerChannels))
|
||||
TunerChannelSource source = null;
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
mTunerController.getFrequencyControllerLock().lock();
|
||||
if(CenterFrequencyCalculator.canTune(tunerChannel, mTunerController, mTunerChannels))
|
||||
{
|
||||
//Attempt to create the channel source first, in case we get a filter design exception
|
||||
HalfBandTunerChannelSource tunerChannelSource = new HalfBandTunerChannelSource(mChannelSourceEventProcessor,
|
||||
tunerChannel, mTunerController.getSampleRate(), channelSpecification);
|
||||
try
|
||||
{
|
||||
//Attempt to create the channel source first, in case we get a filter design exception
|
||||
HalfBandTunerChannelSource tunerChannelSource = new HalfBandTunerChannelSource(mChannelSourceEventProcessor,
|
||||
tunerChannel, mTunerController.getSampleRate(), channelSpecification);
|
||||
|
||||
//Add to the list of channel sources so that it will receive the tuner frequency change
|
||||
mChannelSources.add(tunerChannelSource);
|
||||
//Add to the list of channel sources so that it will receive the tuner frequency change
|
||||
mChannelSources.add(tunerChannelSource);
|
||||
|
||||
//Set the current tuner frequency
|
||||
tunerChannelSource.setFrequency(mTunerController.getFrequency());
|
||||
//Set the current tuner frequency
|
||||
tunerChannelSource.setFrequency(mTunerController.getFrequency());
|
||||
|
||||
//Add to the channel list and update the tuner center frequency as needed
|
||||
mTunerChannels.add(tunerChannel);
|
||||
updateTunerFrequency();
|
||||
//Add to the channel list and update the tuner center frequency as needed
|
||||
mTunerChannels.add(tunerChannel);
|
||||
updateTunerFrequency();
|
||||
|
||||
//Lock the tuner controller frequency and sample rate
|
||||
mTunerController.setLocked(true);
|
||||
//Lock the tuner controller frequency and sample rate
|
||||
mTunerController.setLockedSampleRate(true);
|
||||
|
||||
broadcast(SourceEvent.channelCountChange(getTunerChannelCount()));
|
||||
broadcast(SourceEvent.channelCountChange(getTunerChannelCount()));
|
||||
|
||||
return tunerChannelSource;
|
||||
}
|
||||
catch(FilterDesignException fde)
|
||||
{
|
||||
mLog.error("Error creating CIC tuner channel source - couldn't design cleanup filter", fde);
|
||||
source = tunerChannelSource;
|
||||
}
|
||||
catch(FilterDesignException fde)
|
||||
{
|
||||
mLog.error("Error creating CIC tuner channel source - couldn't design cleanup filter", fde);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
mTunerController.getFrequencyControllerLock().unlock();
|
||||
}
|
||||
|
||||
return null;
|
||||
return source;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -278,8 +282,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 +289,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 +296,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());
|
||||
@@ -304,7 +304,7 @@ public class HeterodyneChannelSourceManager extends ChannelSourceManager
|
||||
//Unlock the tuner controller if there are no more channels
|
||||
if(getTunerChannelCount() == 0)
|
||||
{
|
||||
mTunerController.setLocked(false);
|
||||
mTunerController.setLockedSampleRate(false);
|
||||
}
|
||||
broadcast(SourceEvent.channelCountChange(getTunerChannelCount()));
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,18 +82,30 @@ public class PassThroughSourceManager extends ChannelSourceManager
|
||||
@Override
|
||||
public TunerChannelSource getSource(TunerChannel tunerChannel, ChannelSpecification channelSpecification)
|
||||
{
|
||||
|
||||
if(!mRunning)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
PassThroughChannelSource channelSource = new PassThroughChannelSource(new SourceEventProxy(),
|
||||
mTunerController, tunerChannel);
|
||||
TunerChannelSource source = null;
|
||||
|
||||
mTunerChannels.add(tunerChannel);
|
||||
mTunerChannelSources.add(channelSource);
|
||||
try
|
||||
{
|
||||
mTunerController.getFrequencyControllerLock().lock();
|
||||
PassThroughChannelSource channelSource = new PassThroughChannelSource(new SourceEventProxy(),
|
||||
mTunerController, tunerChannel);
|
||||
|
||||
return channelSource;
|
||||
mTunerChannels.add(tunerChannel);
|
||||
mTunerChannelSources.add(channelSource);
|
||||
source = channelSource;
|
||||
}
|
||||
finally
|
||||
{
|
||||
mTunerController.getFrequencyControllerLock().unlock();
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,12 +25,11 @@ import io.github.dsheirer.source.tuner.TunerController;
|
||||
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.apache.commons.math3.util.FastMath;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.SortedSet;
|
||||
|
||||
/**
|
||||
* PolyphaseChannelSourceManager is responsible for managing the tuner's center tuned frequency and providing access to
|
||||
* polyphase tuner channel sources (ie DDCs). This class is responsible for determining IF a requested channel can
|
||||
@@ -416,48 +415,56 @@ public class PolyphaseChannelSourceManager extends ChannelSourceManager
|
||||
@Override
|
||||
public TunerChannelSource getSource(TunerChannel tunerChannel, ChannelSpecification channelSpecification)
|
||||
{
|
||||
if(isTunable(tunerChannel))
|
||||
TunerChannelSource tunerChannelSource = null;
|
||||
|
||||
try
|
||||
{
|
||||
//Get a new set of currently tuned channels
|
||||
SortedSet<TunerChannel> tunerChannels = getTunerChannels();
|
||||
|
||||
//Add the requested channel to the list
|
||||
tunerChannels.add(tunerChannel);
|
||||
|
||||
if(canTune(tunerChannels))
|
||||
mTunerController.getFrequencyControllerLock().lock();
|
||||
if(isTunable(tunerChannel))
|
||||
{
|
||||
long currentCenterFrequency = mTunerController.getFrequency();
|
||||
long updatedCenterFrequency = 0;
|
||||
//Get a new set of currently tuned channels
|
||||
SortedSet<TunerChannel> tunerChannels = getTunerChannels();
|
||||
|
||||
//Attempt to adjust the center frequency before we allocate the channel
|
||||
try
|
||||
//Add the requested channel to the list
|
||||
tunerChannels.add(tunerChannel);
|
||||
|
||||
if(canTune(tunerChannels))
|
||||
{
|
||||
updatedCenterFrequency = getCenterFrequency(tunerChannels, currentCenterFrequency);
|
||||
long currentCenterFrequency = mTunerController.getFrequency();
|
||||
long updatedCenterFrequency = 0;
|
||||
|
||||
if(updatedCenterFrequency != currentCenterFrequency && updatedCenterFrequency != 0)
|
||||
//Attempt to adjust the center frequency before we allocate the channel
|
||||
try
|
||||
{
|
||||
mTunerController.setFrequency(updatedCenterFrequency);
|
||||
}
|
||||
updatedCenterFrequency = getCenterFrequency(tunerChannels, currentCenterFrequency);
|
||||
|
||||
//If we're successful to here, allocate the channel
|
||||
return mPolyphaseChannelManager.getChannel(tunerChannel);
|
||||
}
|
||||
catch(SourceException se)
|
||||
{
|
||||
//Tuner controller threw an error trying to tune to the updated frequency
|
||||
mLog.error("Error while updating tuner controller with new center frequency [" +
|
||||
updatedCenterFrequency + "] - unable to allocate new tuner channel", se);
|
||||
}
|
||||
catch(IllegalArgumentException iae)
|
||||
{
|
||||
//Center frequency calculation failed
|
||||
// mLog.debug("Couldn't calculate new tuner center frequency for new tuner channel [" +
|
||||
// tunerChannel + "] unable to allocate new tuner channel");
|
||||
if(updatedCenterFrequency != currentCenterFrequency && updatedCenterFrequency != 0)
|
||||
{
|
||||
mTunerController.setFrequency(updatedCenterFrequency);
|
||||
}
|
||||
|
||||
//If we're successful to here, allocate the channel
|
||||
tunerChannelSource = mPolyphaseChannelManager.getChannel(tunerChannel);
|
||||
}
|
||||
catch(SourceException se)
|
||||
{
|
||||
//Tuner controller threw an error trying to tune to the updated frequency
|
||||
mLog.error("Error while updating tuner controller with new center frequency [" +
|
||||
updatedCenterFrequency + "] - unable to allocate new tuner channel", se);
|
||||
}
|
||||
catch(IllegalArgumentException iae)
|
||||
{
|
||||
//Center frequency calculation failed
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
mTunerController.getFrequencyControllerLock().unlock();
|
||||
}
|
||||
|
||||
return null;
|
||||
return tunerChannelSource;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -474,7 +481,7 @@ public class PolyphaseChannelSourceManager extends ChannelSourceManager
|
||||
broadcast(sourceEvent);
|
||||
//Lock the frequency and sample rate controls on the tuner controller so users can't change them
|
||||
//when the polyphase manager has channels allocated
|
||||
mTunerController.setLocked(getTunerChannelCount() > 0);
|
||||
mTunerController.setLockedSampleRate(getTunerChannelCount() > 0);
|
||||
break;
|
||||
case NOTIFICATION_MEASURED_FREQUENCY_ERROR_SYNC_LOCKED:
|
||||
//Rebroadcast these frequency measurement errors to the tuner and tuner controller
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ import io.github.dsheirer.source.tuner.rtl.e4k.E4KEmbeddedTuner.E4KGain;
|
||||
import io.github.dsheirer.source.tuner.rtl.e4k.E4KEmbeddedTuner.E4KLNAGain;
|
||||
import io.github.dsheirer.source.tuner.rtl.e4k.E4KEmbeddedTuner.E4KMixerGain;
|
||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -41,8 +43,6 @@ import javax.swing.JOptionPane;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
import javax.usb.UsbException;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* E4000 tuner editor
|
||||
@@ -383,7 +383,7 @@ public class E4KTunerEditor extends TunerEditor<RTL2832Tuner, E4KTunerConfigurat
|
||||
*/
|
||||
private void updateSampleRateToolTip()
|
||||
{
|
||||
if(hasTuner() && getTuner().getTunerController().isLocked())
|
||||
if(hasTuner() && getTuner().getTunerController().isLockedSampleRate())
|
||||
{
|
||||
getSampleRateCombo().setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
||||
}
|
||||
|
||||
@@ -416,7 +416,7 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
|
||||
*/
|
||||
private void updateSampleRateToolTip()
|
||||
{
|
||||
if(hasTuner() && getTuner().getTunerController().isLocked())
|
||||
if(hasTuner() && getTuner().getTunerController().isLockedSampleRate())
|
||||
{
|
||||
getSampleRateCombo().setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
||||
}
|
||||
|
||||
@@ -25,10 +25,6 @@ import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||
import io.github.dsheirer.source.tuner.manager.DiscoveredUSBTuner;
|
||||
import io.github.dsheirer.source.tuner.manager.IDiscoveredTunerStatusListener;
|
||||
import io.github.dsheirer.source.tuner.manager.TunerStatus;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.awt.EventQueue;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
@@ -36,6 +32,10 @@ import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
||||
/**
|
||||
* Model for discovered tuners
|
||||
@@ -449,7 +449,7 @@ public class DiscoveredTunerModel extends AbstractTableModel implements Listener
|
||||
if(discoveredTuner.hasTuner())
|
||||
{
|
||||
int channelCount = discoveredTuner.getTuner().getChannelSourceManager().getTunerChannelCount();
|
||||
return channelCount + " (" + (discoveredTuner.getTuner().getTunerController().isLocked() ? "LOCKED)" : "UNLOCKED)");
|
||||
return channelCount + " (" + (discoveredTuner.getTuner().getTunerController().isLockedSampleRate() ? "LOCKED)" : "UNLOCKED)");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
@@ -615,8 +619,8 @@ public abstract class TunerEditor<T extends Tuner,C extends TunerConfiguration>
|
||||
{
|
||||
getFrequencyControl().clearListeners();
|
||||
getFrequencyControl().addListener(mFrequencyAndCorrectionChangeListener);
|
||||
getFrequencyControl().setEnabled(hasTuner() && !getTuner().getTunerController().isLocked());
|
||||
getTunerLockedStatusLabel().setVisible(hasTuner() && getTuner().getTunerController().isLocked());
|
||||
getFrequencyControl().setEnabled(hasTuner() && !getTuner().getTunerController().isLockedSampleRate());
|
||||
getTunerLockedStatusLabel().setVisible(hasTuner() && getTuner().getTunerController().isLockedSampleRate());
|
||||
getFrequencyCorrectionSpinner().setEnabled(hasTuner());
|
||||
getAutoPPMCheckBox().setEnabled(hasTuner());
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -130,7 +143,7 @@ public class TunerViewPanel extends JPanel
|
||||
|
||||
if(selectedTuner != null && selectedTuner.hasTuner() && tunerEvent.getTuner() == selectedTuner.getTuner())
|
||||
{
|
||||
mDiscoveredTunerEditor.setTunerLockState(selectedTuner.getTuner().getTunerController().isLocked());
|
||||
mDiscoveredTunerEditor.setTunerLockState(selectedTuner.getTuner().getTunerController().isLockedSampleRate());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<!--
|
||||
~ *******************************************************************************
|
||||
~ sdrtrunk
|
||||
~ Copyright (C) 2014-2018 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,7 +14,7 @@
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
~ ******************************************************************************
|
||||
~ *****************************************************************************
|
||||
-->
|
||||
<configuration>
|
||||
<conversionRule conversionWord="memory_usage" converterClass="io.github.dsheirer.util.MemoryUsageLogger" />
|
||||
@@ -24,7 +23,7 @@
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%-12(%d{HH:mm:ss.SSS}) %-5level %logger{25} - %msg %memory_usage%n</pattern>
|
||||
<pattern>%-12(%d{yyyy-MM-dd HH:mm:ss.SSS}) %-5level %logger{25} - %msg %memory_usage%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user