kopia lustrzana https://github.com/jameshball/osci-render
Change to Java 16 and add more exceptions to AudioPlayer setup
rodzic
0f912df3c9
commit
26a753464f
|
@ -80,21 +80,21 @@ To uninstall, use Windows control panel, as you would expect.
|
||||||
### Running using .jar
|
### Running using .jar
|
||||||
|
|
||||||
- Download the latest `osci-render-VERSION.jar` from [Releases](https://github.com/jameshball/osci-render/releases)
|
- Download the latest `osci-render-VERSION.jar` from [Releases](https://github.com/jameshball/osci-render/releases)
|
||||||
- Download and install [Java 15 or later](https://www.oracle.com/java/technologies/javase-jdk16-downloads.html)
|
- Download and install [Java 16 or later](https://www.oracle.com/java/technologies/javase-jdk16-downloads.html)
|
||||||
- Donwload and unpack [JavaFX 16 or later](https://gluonhq.com/products/javafx/)
|
- Donwload and unpack [JavaFX 16 or later](https://gluonhq.com/products/javafx/)
|
||||||
- Make sure you scroll down to `Latest Release`
|
- Make sure you scroll down to `Latest Release`
|
||||||
- Download the SDK for your platform
|
- Download the SDK for your platform
|
||||||
- Unpack the `.zip` at your root directory (e.g. `C:\javafx-sdk-16` for me on Windows)
|
- Unpack the `.zip` at your root directory (e.g. `C:\javafx-sdk-16` for me on Windows)
|
||||||
- The `lib` subfolder should be located at `/javafx-sdk-16/lib`
|
- The `lib` subfolder should be located at `/javafx-sdk-16/lib`
|
||||||
- Run the following command from your terminal to run the `.jar`, substituting the correct paths
|
- Run the following command from your terminal to run the `.jar`, substituting the correct paths
|
||||||
- `java --enable-preview --module-path /javafx-sdk-16/lib --add-modules=javafx.controls,javafx.fxml -jar "path/to/osci-render-VERSION.jar"`
|
- `java --module-path /javafx-sdk-16/lib --add-modules=javafx.controls,javafx.fxml -jar "PATH/TO/osci-render-VERSION.jar"`
|
||||||
- Start rendering!
|
- Start rendering!
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
I am using Maven for dependency management and to package the program. Doing the following will setup the project. I highly recommend using IntelliJ.
|
I am using Maven for dependency management and to package the program. Doing the following will setup the project. I highly recommend using IntelliJ.
|
||||||
|
|
||||||
- Download and install [Java 15 or later](https://www.oracle.com/java/technologies/javase-jdk16-downloads.html)
|
- Download and install [Java 16 or later](https://www.oracle.com/java/technologies/javase-jdk16-downloads.html)
|
||||||
- Run `git clone git@github.com:jameshball/osci-render.git`
|
- Run `git clone git@github.com:jameshball/osci-render.git`
|
||||||
- `cd` into the `osci-render` directory
|
- `cd` into the `osci-render` directory
|
||||||
- Run `mvn package`
|
- Run `mvn package`
|
||||||
|
|
6
pom.xml
6
pom.xml
|
@ -6,13 +6,13 @@
|
||||||
|
|
||||||
<groupId>sh.ball</groupId>
|
<groupId>sh.ball</groupId>
|
||||||
<artifactId>osci-render</artifactId>
|
<artifactId>osci-render</artifactId>
|
||||||
<version>1.6.4</version>
|
<version>1.6.5</version>
|
||||||
|
|
||||||
<name>osci-render</name>
|
<name>osci-render</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.release>15</maven.compiler.release>
|
<maven.compiler.release>16</maven.compiler.release>
|
||||||
<javafx.version>16</javafx.version>
|
<javafx.version>16</javafx.version>
|
||||||
<project.modulePath>${project.build.directory}\modules</project.modulePath>
|
<project.modulePath>${project.build.directory}\modules</project.modulePath>
|
||||||
<appModule>oscirender</appModule>
|
<appModule>oscirender</appModule>
|
||||||
|
@ -99,7 +99,6 @@
|
||||||
<source>${maven.compiler.release}</source>
|
<source>${maven.compiler.release}</source>
|
||||||
<target>${maven.compiler.release}</target>
|
<target>${maven.compiler.release}</target>
|
||||||
<compilerArgs>
|
<compilerArgs>
|
||||||
<compilerArg>--enable-preview</compilerArg>
|
|
||||||
<compilerArg>--module-path</compilerArg>
|
<compilerArg>--module-path</compilerArg>
|
||||||
<compilerArg>${project.modulePath}</compilerArg>
|
<compilerArg>${project.modulePath}</compilerArg>
|
||||||
</compilerArgs>
|
</compilerArgs>
|
||||||
|
@ -118,7 +117,6 @@
|
||||||
<modulePath>${project.build.directory}/modules;${project.build.directory}/classes</modulePath>
|
<modulePath>${project.build.directory}/modules;${project.build.directory}/classes</modulePath>
|
||||||
<destination>${project.build.directory}</destination>
|
<destination>${project.build.directory}</destination>
|
||||||
<javaOptions>
|
<javaOptions>
|
||||||
<option>--enable-preview</option>
|
|
||||||
<option>-Dfile.encoding=UTF-8</option>
|
<option>-Dfile.encoding=UTF-8</option>
|
||||||
</javaOptions>
|
</javaOptions>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -167,19 +167,25 @@ public class AudioPlayer implements Renderer<List<Shape>, AudioInputStream> {
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
service = platform.getService(platform.setupToSystem(XtSetup.CONSUMER_AUDIO));
|
service = platform.getService(platform.setupToSystem(XtSetup.CONSUMER_AUDIO));
|
||||||
}
|
}
|
||||||
if (service == null) return;
|
if (service == null) {
|
||||||
|
throw new RuntimeException("Failed to connect to any audio service");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (service.getCapabilities().contains(Enums.XtServiceCaps.NONE)) {
|
||||||
|
throw new RuntimeException("Audio service has no capabilities");
|
||||||
|
}
|
||||||
|
|
||||||
String output = service.getDefaultDeviceId(true);
|
String output = service.getDefaultDeviceId(true);
|
||||||
if (output == null) {
|
if (output == null) {
|
||||||
output = service.openDeviceList(EnumSet.of(Enums.XtEnumFlags.OUTPUT)).getId(0);
|
output = getFirstDevice(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
try (XtDevice device = service.openDevice(output)) {
|
try (XtDevice device = service.openDevice(output)) {
|
||||||
if (device.supportsFormat(format)) {
|
if (device.supportsFormat(format)) {
|
||||||
|
|
||||||
XtBufferSize size = device.getBufferSize(format);
|
XtBufferSize size = device.getBufferSize(format);
|
||||||
XtStreamParams streamParams = new XtStreamParams(true, this::render, null, null);
|
XtStreamParams streamParams = new XtStreamParams(true, this::render, null, null);
|
||||||
XtDeviceStreamParams deviceParams = new XtDeviceStreamParams(streamParams, format, size.current);
|
XtDeviceStreamParams deviceParams = new XtDeviceStreamParams(streamParams, format, size.current);
|
||||||
|
|
||||||
try (XtStream stream = device.openStream(deviceParams, null);
|
try (XtStream stream = device.openStream(deviceParams, null);
|
||||||
XtSafeBuffer safe = XtSafeBuffer.register(stream, true)) {
|
XtSafeBuffer safe = XtSafeBuffer.register(stream, true)) {
|
||||||
stream.start();
|
stream.start();
|
||||||
|
@ -188,11 +194,17 @@ public class AudioPlayer implements Renderer<List<Shape>, AudioInputStream> {
|
||||||
}
|
}
|
||||||
stream.stop();
|
stream.stop();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("Audio device does not support audio format");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getFirstDevice(XtService service) {
|
||||||
|
return service.openDeviceList(EnumSet.of(Enums.XtEnumFlags.OUTPUT)).getId(0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
stopped = true;
|
stopped = true;
|
||||||
|
|
|
@ -236,7 +236,9 @@ public class Controller implements Initializable, FrequencyListener, Listener {
|
||||||
renderer.addEffect(EffectType.TRANSLATE, translateEffect);
|
renderer.addEffect(EffectType.TRANSLATE, translateEffect);
|
||||||
|
|
||||||
executor.submit(producer);
|
executor.submit(producer);
|
||||||
new Thread(renderer).start();
|
Thread renderThread = new Thread(renderer);
|
||||||
|
renderThread.setUncaughtExceptionHandler((thread, throwable) -> throwable.printStackTrace());
|
||||||
|
renderThread.start();
|
||||||
FrequencyAnalyser<List<Shape>, AudioInputStream> analyser = new FrequencyAnalyser<>(renderer, 2, SAMPLE_RATE);
|
FrequencyAnalyser<List<Shape>, AudioInputStream> analyser = new FrequencyAnalyser<>(renderer, 2, SAMPLE_RATE);
|
||||||
analyser.addListener(this);
|
analyser.addListener(this);
|
||||||
analyser.addListener(wobbleEffect);
|
analyser.addListener(wobbleEffect);
|
||||||
|
|
Ładowanie…
Reference in New Issue