Skip to content
Snippets Groups Projects
Commit 0e75041c authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

Code cleanup

parent 411de51d
No related branches found
No related tags found
No related merge requests found
Showing
with 38 additions and 99 deletions
package de.tobias.playpad;
public class Waveform {
public static native float[] createWaveform(String path);
}
package de.tobias.playpad.audio.windows;
import de.thecodelabs.utils.application.App;
import de.thecodelabs.utils.application.ApplicationUtils;
import de.thecodelabs.utils.application.container.PathType;
import de.thecodelabs.utils.io.IOUtils;
import de.thecodelabs.utils.threading.Worker;
import de.thecodelabs.utils.ui.icon.FontAwesomeType;
import de.thecodelabs.utils.ui.icon.FontIcon;
......@@ -15,13 +15,12 @@ import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import nativeaudio.NativeAudio;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
public class NativeAudioSettingsViewController extends AudioHandlerViewController {
private static final String TEST_SOUND_WAV = "Test-Sound.wav";
@FXML
private ComboBox<String> soundCardComboBox;
@FXML
......@@ -75,16 +74,9 @@ public class NativeAudioSettingsViewController extends AudioHandlerViewControlle
@FXML
private void testButtonHandler(ActionEvent event) {
Path file = ApplicationUtils.getApplication().getPath(PathType.RESOURCES, "Test-Sound.wav");
if (Files.notExists(file)) {
InputStream iStr = getClass().getClassLoader().getResourceAsStream("Test-Sound.wav");
try {
Files.createDirectories(file.getParent());
IOUtils.copy(iStr, file);
} catch (IOException e) {
e.printStackTrace();
}
}
final App app = ApplicationUtils.getApplication();
Path file = app.getPath(PathType.RESOURCES, TEST_SOUND_WAV);
app.getClasspathResource("Test-Sound.wav").copy(PathType.RESOURCES, "TestSound.wav");
if (audioPlayer == null) {
audioPlayer = new NativeAudio();
......
......@@ -109,14 +109,12 @@ public class NativeAudioWinHandler extends AudioHandler implements Soundcardable
@Override
public void pause() {
audioHandler.pause();
if (playedHandlers.contains(this))
playedHandlers.remove(this);
}
@Override
public void stop() {
audioHandler.stop();
if (playedHandlers.contains(this))
playedHandlers.remove(this);
}
......
package de.tobias.playpad.view;
import javafx.scene.paint.Color;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
public class WaveformView extends Path {
public WaveformView(float[] data) {
getElements().add(new MoveTo(0, 0));
double width2 = data.length / 1200.0;
int width = data.length / 10000;
System.out.println(data.length);
System.out.println(width);
int i = 0;
for (i = 0; i < data.length; i += width) {
if (i < data.length) {
LineTo lineTo = new LineTo(i / width2, data[i] * 50.0);
MoveTo moveTo = new MoveTo(i / width2, data[i] * 50.0);
getElements().addAll(lineTo, moveTo);
}
}
for (; i >= 0; i -= width) {
if (i >= 0 && i < data.length) {
LineTo lineTo = new LineTo(i / width2, -data[i] * 50.0);
MoveTo moveTo = new MoveTo(i / width2, -data[i] * 50.0);
getElements().addAll(lineTo, moveTo);
}
}
getElements().add(new LineTo(0, 0));
getElements().add(new MoveTo(0, 0));
setFill(Color.BLACK);
}
}
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class de_tobias_playpad_Waveform */
#ifndef _Included_de_tobias_playpad_Waveform
#define _Included_de_tobias_playpad_Waveform
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: de_tobias_playpad_Waveform
* Method: initialize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_de_tobias_playpad_Waveform_initialize
(JNIEnv *, jclass);
/*
* Class: de_tobias_playpad_Waveform
* Method: createWaveform
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_de_tobias_playpad_Waveform_createWaveform
(JNIEnv *, jclass, jstring);
#ifdef __cplusplus
}
#endif
#endif
package de.tobias.playpad.plugin;
import de.thecodelabs.utils.application.container.ContainerPathType;
import de.thecodelabs.utils.application.container.PathType;
public enum NativeAudioPathType implements ContainerPathType {
AUDIO(PathType.LIBRARY.getFolder() + "/Audio");
private String folder;
NativeAudioPathType(String folder) {
this.folder = folder;
}
@Override
public String getFolder() {
return folder;
}
@Override
public boolean shouldBackup() {
return false;
}
}
......@@ -3,10 +3,9 @@ package de.tobias.playpad.plugin.loader
import java.nio.file.Files
import de.thecodelabs.utils.application.ApplicationUtils
import de.thecodelabs.utils.application.container.PathType
import de.tobias.playpad.PlayPadPlugin
import de.tobias.playpad.audio.mac.NativeAudioMacHandlerFactory
import de.tobias.playpad.plugin.Module
import de.tobias.playpad.plugin.{Module, NativeAudioPathType}
/**
* Created by tobias on 16.04.17.
......@@ -19,7 +18,7 @@ class MacAudioImplLoader extends AudioModuleLoader {
override def preInit(): Unit = {
val app = ApplicationUtils.getApplication
val resourceFolder = app.getPath(PathType.LIBRARY, "Audio")
val resourceFolder = app.getPath(NativeAudioPathType.AUDIO)
if (Files.notExists(resourceFolder)) {
Files.createDirectories(resourceFolder)
}
......
......@@ -18,7 +18,7 @@ class WindowsAudioImplLoader extends AudioModuleLoader {
override def preInit(): Unit = {
val app: App = ApplicationUtils.getApplication
val resourceFolder = app.getPath(PathType.LIBRARY, "Native")
val resourceFolder = app.getPath(PathType.NATIVE_LIBRARY)
if (!app.isDebug) {
if (Files.notExists(resourceFolder))
......@@ -33,7 +33,7 @@ class WindowsAudioImplLoader extends AudioModuleLoader {
copyResource(resourceFolder, ASSETS, "NAudio.dll")
}
Bridge.setVerbose(true)
Bridge.setVerbose(app isDebug)
Bridge.init()
Bridge.LoadAndRegisterAssemblyFrom(resourceFolder.resolve("NativeAudio.j4n.dll").toFile)
}
......
......@@ -18,7 +18,7 @@
<components.version>${project.version}</components.version>
<jlibs.version>2.0.5</jlibs.version>
<Updater.version>1.0.5</Updater.version>
<Updater.version>1.0.6</Updater.version>
<gson.version>2.8.5</gson.version>
<json-smart.version>1.2</json-smart.version>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment