Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processing Enhancements and SIMD Vector Support #1148

Merged
merged 1 commit into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .idea/dictionaries/denny.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

138 changes: 16 additions & 122 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2021 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
Expand All @@ -20,7 +20,6 @@ plugins {
id 'application'
id 'java'
id 'idea'
id 'org.openjfx.javafxplugin' version '0.0.10'
id 'org.beryx.runtime' version '1.12.7'
}

Expand All @@ -32,12 +31,6 @@ repositories {
version = '0.5.0-alpha7'
sourceCompatibility = '17'

javafx {
version = "17.0.1"
modules = ['javafx.base', 'javafx.controls', 'javafx.graphics', 'javafx.swing']
configuration = "implementation"
}

sourceSets {
main.java.srcDirs 'src/main'
test.java.srcDirs 'src/test'
Expand All @@ -47,12 +40,6 @@ test {
useJUnitPlatform()
}

configurations {
javafx_libs_linux
javafx_libs_osx
javafx_libs_win
}

dependencies {

// JUnit Tests
Expand Down Expand Up @@ -100,53 +87,21 @@ dependencies {
implementation 'org.usb4java:usb4java:1.3.0'
implementation 'org.usb4java:usb4java-javax:1.3.0'
implementation 'pl.edu.icm:JLargeArrays:1.6'

//JavaFX libraries for Linux
javafx_libs_linux "org.openjfx:javafx-base:$javafx.version:linux"
javafx_libs_linux "org.openjfx:javafx-controls:$javafx.version:linux"
javafx_libs_linux "org.openjfx:javafx-graphics:$javafx.version:linux"
javafx_libs_linux "org.openjfx:javafx-swing:$javafx.version:linux"

//JavaFX libraries for OSX
javafx_libs_osx "org.openjfx:javafx-base:$javafx.version:mac"
javafx_libs_osx "org.openjfx:javafx-controls:$javafx.version:mac"
javafx_libs_osx "org.openjfx:javafx-graphics:$javafx.version:mac"
javafx_libs_osx "org.openjfx:javafx-swing:$javafx.version:mac"

//JavaFX libraries for Windows
javafx_libs_win "org.openjfx:javafx-base:$javafx.version:win"
javafx_libs_win "org.openjfx:javafx-controls:$javafx.version:win"
javafx_libs_win "org.openjfx:javafx-graphics:$javafx.version:win"
javafx_libs_win "org.openjfx:javafx-swing:$javafx.version:win"
}

application {
mainClass.set("io.github.dsheirer.gui.SDRTrunk")

//Note: jide-oss.jar requires access to hidden windows look & feel
//Note: controlsfx.jar requires access to hidden javaFX classes
applicationDefaultJvmArgs = ['--add-exports=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED',
'--add-exports=javafx.base/com.sun.javafx.event=org.controlsfx.controls']
}

/**
* Runtime JVM arguments. JDK 17 has hidden a number of classes that are no longer exported from the
* modules. Some legacy support libraries still require access to these classes, so we explicitly
* add them to be exported from those modules here.
* This is needed for the JDK17 vector API ... until it moves out of incubation
*/
import org.gradle.internal.os.OperatingSystem;
tasks.withType(JavaCompile) {
options.compilerArgs.add("--add-modules=jdk.incubator.vector")
}

run {
if(OperatingSystem.current().isWindows()) {
//Note: jide-oss.jar requires access to hidden windows look & feel
//Note: controlsfx.jar requires access to hidden javaFX classes
jvmArgs = ['--add-exports=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED',
'--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED']
}
else {
//Note: controlsfx.jar requires access to hidden javaFX classes
jvmArgs = ['--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED']
}
application {
mainClassName = "io.github.dsheirer.gui.SDRTrunk"
applicationDefaultJvmArgs =
['--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED', //Needed for controls-fx.jar
'--add-modules=jdk.incubator.vector', //Needed while Panama Vector API remains in incubator
'--add-exports=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED'] //Windows Swing - jide-oss library
}

jar {
Expand Down Expand Up @@ -177,13 +132,13 @@ idea {
*/
def jdk_base = '/home/denny/java_jdks/'

def jdk_linux_arm64 = jdk_base + 'linux-arm64/jdk-17.0.1-full'
def jdk_linux_x86_64 = jdk_base + 'linux-x64/jdk-17.0.1-full'
def jdk_osx_x86_64 = jdk_base + 'osx-x64/jdk-17.0.1-full.jdk'
def jdk_windows_x86_64 = jdk_base + 'windows-x64/jdk-17.0.1-full'
def jdk_linux_arm64 = jdk_base + 'linux-arm64/jdk-17.0.2-full'
def jdk_linux_x86_64 = jdk_base + 'linux-x64/jdk-17.0.2-full'
def jdk_osx_x86_64 = jdk_base + 'osx-x64/jdk-17.0.2-full.jdk'
def jdk_windows_x86_64 = jdk_base + 'windows-x64/jdk-17.0.2-full'

def hasTargetJdk = file(jdk_linux_x86_64).exists() ||
file(jdk_linux_arm64) ||
file(jdk_linux_arm64).exists() ||
file(jdk_osx_x86_64).exists() ||
file(jdk_windows_x86_64).exists()

Expand Down Expand Up @@ -230,66 +185,5 @@ runtime {
}

options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
modules = ['java.desktop', 'java.naming', 'jdk.unsupported', 'jdk.unsupported.desktop', 'java.net.http',
'java.sql', 'jdk.crypto.ec']
imageZip = hasTargetJdk ? file("$buildDir/image/sdr-trunk.zip") : file("$buildDir/image/sdr-trunk-" + version + ".zip")
}

def image_lib_linux_arm64 = file("$buildDir/image/sdr-trunk-linux-arm64-v" + version + "/lib")
def image_lib_linux_x86_64 = file("$buildDir/image/sdr-trunk-linux-x86_64-v" + version + "/lib")
def image_lib_osx_x86_64 = file("$buildDir/image/sdr-trunk-osx-x86_64-v" + version + "/lib")
def image_lib_win_x86_64 = file("$buildDir/image/sdr-trunk-windows-x86_64-v" + version + "/lib")

/**
* Copy JavaFX OS-specific libraries for each JDK to each platform target directory
*/
tasks.runtime.doLast
{
if(file(jdk_linux_arm64).exists())
{
//Delete any host system OS-specific JavaFX JDK modules that were inserted as part of default build
delete(fileTree(image_lib_linux_arm64).include { it.name ==~ /javafx.*-(win|mac|linux)\.jar/ })

//Copy OS-specific JavaFX libraries
copy {
from configurations.javafx_libs_linux
into image_lib_linux_arm64
}
}

if(file(jdk_linux_x86_64).exists())
{
//Delete any host system OS-specific JavaFX JDK modules that were inserted as part of default build
delete(fileTree(image_lib_linux_x86_64).include { it.name ==~ /javafx.*-(win|mac|linux)\.jar/ })

//Copy OS-specific JavaFX libraries
copy {
from configurations.javafx_libs_linux
into image_lib_linux_x86_64
}
}

if(file(jdk_osx_x86_64).exists())
{
//Delete any host system OS-specific JavaFX JDK modules that were inserted as part of default build
delete(fileTree(image_lib_osx_x86_64).include { it.name ==~ /javafx.*-(win|mac|linux)\.jar/ })

//Copy OS-specific JavaFX libraries
copy {
from configurations.javafx_libs_osx
into image_lib_osx_x86_64
}
}

if(file(jdk_windows_x86_64).exists())
{
//Delete any host system OS-specific JavaFX JDK modules that were inserted as part of default build
delete(fileTree(image_lib_win_x86_64).include { it.name ==~ /javafx.*-(win|mac|linux)\.jar/ })

//Copy OS-specific JavaFX libraries
copy {
from configurations.javafx_libs_win
into image_lib_win_x86_64
}
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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/>
* *****************************************************************************
* ****************************************************************************
*/

package io.github.dsheirer.alias.action;
Expand All @@ -26,8 +25,8 @@
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.util.ThreadPool;

import javax.swing.JOptionPane;
import java.awt.EventQueue;
import javax.swing.*;
import java.awt.*;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -92,7 +91,7 @@ public void execute(Alias alias, IMessage message)
*/
private void performThreadedAction(final Alias alias, final IMessage message)
{
ThreadPool.SCHEDULED.schedule(() -> performAction(alias, message), 0, TimeUnit.SECONDS);
ThreadPool.CACHED.execute(() -> performAction(alias, message));
}

@Override
Expand Down
54 changes: 23 additions & 31 deletions src/main/java/io/github/dsheirer/audio/AudioModule.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2022 Dennis Sheirer
*
* * ******************************************************************************
* * Copyright (C) 2014-2019 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/>
* * *****************************************************************************
* 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.audio;

import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.audio.squelch.ISquelchStateListener;
import io.github.dsheirer.audio.squelch.SquelchState;
import io.github.dsheirer.audio.squelch.SquelchStateEvent;
import io.github.dsheirer.dsp.filter.FilterFactory;
import io.github.dsheirer.dsp.filter.design.FilterDesignException;
import io.github.dsheirer.dsp.filter.fir.FIRFilterSpecification;
import io.github.dsheirer.dsp.filter.fir.real.RealFIRFilter2;
import io.github.dsheirer.dsp.filter.fir.real.IRealFilter;
import io.github.dsheirer.dsp.filter.fir.remez.RemezFIRFilterDesigner;
import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.sample.buffer.IReusableBufferListener;
import io.github.dsheirer.sample.buffer.ReusableFloatBuffer;
import io.github.dsheirer.sample.real.IRealBufferListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -41,8 +38,8 @@
*
* Incorporates audio squelch state listener to control if audio packets are broadcast or ignored.
*/
public class AudioModule extends AbstractAudioModule implements ISquelchStateListener, IReusableBufferListener,
Listener<ReusableFloatBuffer>
public class AudioModule extends AbstractAudioModule implements ISquelchStateListener, IRealBufferListener,
Listener<float[]>
{
private static final Logger mLog = LoggerFactory.getLogger(AudioModule.class);
private static float[] sHighPassFilterCoefficients;
Expand Down Expand Up @@ -73,7 +70,7 @@ public class AudioModule extends AbstractAudioModule implements ISquelchStateLis
}
}

private RealFIRFilter2 mHighPassFilter = new RealFIRFilter2(sHighPassFilterCoefficients);
private IRealFilter mHighPassFilter = FilterFactory.getRealFilter(sHighPassFilterCoefficients);
private SquelchStateListener mSquelchStateListener = new SquelchStateListener();
private SquelchState mSquelchState = SquelchState.SQUELCH;

Expand Down Expand Up @@ -120,22 +117,17 @@ public Listener<SquelchStateEvent> getSquelchStateListener()
}

@Override
public void receive(ReusableFloatBuffer audioBuffer)
public void receive(float[] audioBuffer)
{
if(mSquelchState == SquelchState.UNSQUELCH)
{
ReusableFloatBuffer highPassFilteredAudio = mHighPassFilter.filter(audioBuffer);
addAudio(highPassFilteredAudio.getSamplesCopy());
highPassFilteredAudio.decrementUserCount();
}
else
{
audioBuffer.decrementUserCount();
audioBuffer = mHighPassFilter.filter(audioBuffer);
addAudio(audioBuffer);
}
}

@Override
public Listener<ReusableFloatBuffer> getReusableBufferListener()
public Listener<float[]> getBufferListener()
{
//Redirect received reusable buffers to the receive(buffer) method
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2020 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
Expand All @@ -20,7 +20,6 @@

import io.github.dsheirer.sample.Broadcaster;
import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.sample.buffer.AbstractReusableBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down