mirror of
https://github.com/eliasstepanik/VoicemeeterSliderControlJava.git
synced 2026-01-11 13:48:34 +00:00
Initial commit
This commit is contained in:
commit
1b9eebc060
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Project exclude paths
|
||||||
|
/.gradle/
|
||||||
|
/build/
|
||||||
|
/build/classes/java/main/
|
||||||
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/../../../../../../:\Users\elias\IdeaProjects\AudioControl\.idea/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="1.8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/encodings.xml
generated
Normal file
6
.idea/encodings.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/de/sailehd/SerialTest.java" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
17
.idea/gradle.xml
generated
Normal file
17
.idea/gradle.xml
generated
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
30
.idea/jarRepositories.xml
generated
Normal file
30
.idea/jarRepositories.xml
generated
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="MavenRepo" />
|
||||||
|
<option name="name" value="MavenRepo" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="m2-dv8tion" />
|
||||||
|
<option name="name" value="m2-dv8tion" />
|
||||||
|
<option name="url" value="https://m2.dv8tion.net/releases" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="BintrayJCenter" />
|
||||||
|
<option name="name" value="BintrayJCenter" />
|
||||||
|
<option name="url" value="https://jcenter.bintray.com/" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
65
.idea/libraries-with-intellij-classes.xml
generated
Normal file
65
.idea/libraries-with-intellij-classes.xml
generated
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="libraries-with-intellij-classes">
|
||||||
|
<option name="intellijApiContainingLibraries">
|
||||||
|
<list>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="ideaIU" />
|
||||||
|
<option name="groupId" value="com.jetbrains.intellij.idea" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="ideaIU" />
|
||||||
|
<option name="groupId" value="com.jetbrains" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="ideaIC" />
|
||||||
|
<option name="groupId" value="com.jetbrains.intellij.idea" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="ideaIC" />
|
||||||
|
<option name="groupId" value="com.jetbrains" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="pycharmPY" />
|
||||||
|
<option name="groupId" value="com.jetbrains.intellij.pycharm" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="pycharmPY" />
|
||||||
|
<option name="groupId" value="com.jetbrains" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="pycharmPC" />
|
||||||
|
<option name="groupId" value="com.jetbrains.intellij.pycharm" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="pycharmPC" />
|
||||||
|
<option name="groupId" value="com.jetbrains" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="clion" />
|
||||||
|
<option name="groupId" value="com.jetbrains.intellij.clion" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="clion" />
|
||||||
|
<option name="groupId" value="com.jetbrains" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="riderRD" />
|
||||||
|
<option name="groupId" value="com.jetbrains.intellij.rider" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="riderRD" />
|
||||||
|
<option name="groupId" value="com.jetbrains" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="goland" />
|
||||||
|
<option name="groupId" value="com.jetbrains.intellij.goland" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="goland" />
|
||||||
|
<option name="groupId" value="com.jetbrains" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
10
.idea/misc.xml
generated
Normal file
10
.idea/misc.xml
generated
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
|
<file type="web" url="file://$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="openjdk-15" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
2
.idea/modules/AudioControl.iml
generated
Normal file
2
.idea/modules/AudioControl.iml
generated
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module external.linked.project.id="AudioControl" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" type="JAVA_MODULE" version="4" />
|
||||||
33
build.gradle
Normal file
33
build.gradle
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
plugins {
|
||||||
|
id'application'
|
||||||
|
id'com.github.johnrengelman.shadow' version '5.2.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
mainClassName = 'de.sailehd.Main'
|
||||||
|
version = '0.1.1'
|
||||||
|
|
||||||
|
sourceCompatibility = targetCompatibility = 1.8
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
name 'm2-dv8tion'
|
||||||
|
url 'https://m2.dv8tion.net/releases'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
|
||||||
|
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
|
||||||
|
compile("ch.qos.logback:logback-classic:1.2.3")
|
||||||
|
compile 'com.fazecast:jSerialComm:[2.0.0,3.0.0)'
|
||||||
|
compile 'com.jcraft:jsch:0.1.55'
|
||||||
|
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
|
||||||
|
compile group: 'javax.mail', name: 'mail', version: '1.4.1'
|
||||||
|
compile group: 'net.java.dev.jna', name: 'jna', version: '4.5.1'
|
||||||
|
compile group: 'org.projectlombok', name: 'lombok', version: '1.16.20'
|
||||||
|
compile 'net.java.dev.jna:jna:4.5.1'
|
||||||
|
}
|
||||||
|
|
||||||
|
compileJava.options.encoding = 'UTF-8'
|
||||||
4
config.esb
Normal file
4
config.esb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
config.esb
|
||||||
|
{
|
||||||
|
String portName = COM3
|
||||||
|
}
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
185
gradlew
vendored
Normal file
185
gradlew
vendored
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# 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
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$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"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
||||||
|
;;
|
||||||
|
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"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
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
|
||||||
|
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" ;;
|
||||||
|
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, 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"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
89
gradlew.bat
vendored
Normal file
89
gradlew.bat
vendored
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
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"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
: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 %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
2
settings.gradle
Normal file
2
settings.gradle
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
rootProject.name = 'AudioControl'
|
||||||
|
|
||||||
128
src/main/java/de/sailehd/Main.java
Normal file
128
src/main/java/de/sailehd/Main.java
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
package de.sailehd;
|
||||||
|
|
||||||
|
import com.fazecast.jSerialComm.*;
|
||||||
|
import de.sailehd.Voicemeeter.Voicemeeter;
|
||||||
|
import de.sailehd.support.Debug;
|
||||||
|
import de.sailehd.support.EasyBase;
|
||||||
|
import de.sailehd.support.TextColor;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
private Thread loop;
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
EasyBase config = new EasyBase("config");
|
||||||
|
config.createData("portName", new String("COM3"));
|
||||||
|
|
||||||
|
String portName = (String) config.getData("portName");
|
||||||
|
SerialPort comPort = null;
|
||||||
|
|
||||||
|
Voicemeeter.init(true);
|
||||||
|
Voicemeeter.login();
|
||||||
|
|
||||||
|
|
||||||
|
for (SerialPort port: SerialPort.getCommPorts()) {
|
||||||
|
if(port.getDescriptivePortName().contains(portName)){
|
||||||
|
comPort = port;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
comPort.openPort();
|
||||||
|
Debug.log(TextColor.GREEN + "Connected to port " + comPort.getDescriptivePortName() + ".");
|
||||||
|
comPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_SEMI_BLOCKING, 0, 0);
|
||||||
|
Main main = new Main();
|
||||||
|
main.runLoop(comPort);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
Debug.log(TextColor.RED + "could not connect to " + comPort.getDescriptivePortName());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runLoop(SerialPort port){
|
||||||
|
this.loop = new Thread(() -> {
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
InputStream in = port.getInputStream();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Scanner scan = new Scanner(in);;
|
||||||
|
|
||||||
|
int startSkip = 20;
|
||||||
|
while (scan.hasNextLine()){
|
||||||
|
String line = scan.nextLine();
|
||||||
|
if(startSkip <= 0){
|
||||||
|
ArrayList<Integer> sliderValuesIntRaw = new ArrayList<Integer>();
|
||||||
|
ArrayList<Float> sliderValuesIntVoicemeeter = new ArrayList<Float>();
|
||||||
|
|
||||||
|
for (Integer value: parseInput(line)) {
|
||||||
|
sliderValuesIntRaw.add(map(value, 0, 1023, 1023, 0));
|
||||||
|
sliderValuesIntVoicemeeter.add(map(value, 0, 1023, 12f, -60f));
|
||||||
|
}
|
||||||
|
|
||||||
|
Voicemeeter.setParameterFloat("Bus[0].Gain", sliderValuesIntVoicemeeter.get(0)); //Speaker
|
||||||
|
Voicemeeter.setParameterFloat("Bus[1].Gain", sliderValuesIntVoicemeeter.get(1)); //Headphones
|
||||||
|
Voicemeeter.setParameterFloat("Strip[1].Gain", sliderValuesIntVoicemeeter.get(2)); //Spotify
|
||||||
|
Voicemeeter.setParameterFloat("Strip[2].Gain", sliderValuesIntVoicemeeter.get(3)); //Browser
|
||||||
|
Voicemeeter.setParameterFloat("Strip[3].Gain", sliderValuesIntVoicemeeter.get(4)); //Game
|
||||||
|
Voicemeeter.setParameterFloat("Strip[5].Gain", sliderValuesIntVoicemeeter.get(5)); //VAIO
|
||||||
|
Voicemeeter.setParameterFloat("Strip[6].Gain", sliderValuesIntVoicemeeter.get(6)); //AUX
|
||||||
|
Voicemeeter.setParameterFloat("Strip[0].Gain", sliderValuesIntVoicemeeter.get(7)); //Mic
|
||||||
|
|
||||||
|
Debug.log("Speaker: " + sliderValuesIntVoicemeeter.get(0) +
|
||||||
|
" # " + "Headphones: " + sliderValuesIntVoicemeeter.get(1) +
|
||||||
|
" # " + "Spotify: " + sliderValuesIntVoicemeeter.get(2) +
|
||||||
|
" # " + "Browser: " + sliderValuesIntVoicemeeter.get(3) +
|
||||||
|
" # " + "Game: " + sliderValuesIntVoicemeeter.get(4) +
|
||||||
|
" # " + "VAIO: " + sliderValuesIntVoicemeeter.get(5) +
|
||||||
|
" # " + "Aux: " + sliderValuesIntVoicemeeter.get(6) +
|
||||||
|
" # " + "Mic: " + sliderValuesIntVoicemeeter.get(7));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
startSkip--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) { e.printStackTrace(); }
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
this.loop.setName("Loop");
|
||||||
|
this.loop.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ArrayList<Integer> parseInput(String line){
|
||||||
|
ArrayList<Integer> sliderValues = new ArrayList<Integer>();
|
||||||
|
|
||||||
|
String[] valuesRaw = line.split("\\|");
|
||||||
|
|
||||||
|
for (String valueRaw: valuesRaw) {
|
||||||
|
sliderValues.add(Integer.parseInt(valueRaw));
|
||||||
|
}
|
||||||
|
|
||||||
|
return sliderValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long map(long x, long in_min, long in_max, long out_min, long out_max)
|
||||||
|
{
|
||||||
|
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float map(float x, float in_min, float in_max, float out_min, float out_max)
|
||||||
|
{
|
||||||
|
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int map(int x, int in_min, int in_max, int out_min, int out_max)
|
||||||
|
{
|
||||||
|
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||||
|
}
|
||||||
|
}
|
||||||
410
src/main/java/de/sailehd/Voicemeeter/Voicemeeter.java
Normal file
410
src/main/java/de/sailehd/Voicemeeter/Voicemeeter.java
Normal file
@ -0,0 +1,410 @@
|
|||||||
|
package de.sailehd.Voicemeeter;
|
||||||
|
|
||||||
|
import com.sun.jna.Memory;
|
||||||
|
import com.sun.jna.Native;
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@SuppressWarnings("Duplicates")
|
||||||
|
public class Voicemeeter {
|
||||||
|
private static VoicemeeterInstance instance;
|
||||||
|
|
||||||
|
public static String DEFAULT_VM_WINDOWS_64BIT_PATH = "C:\\Program Files (x86)\\VB\\Voicemeeter\\VoicemeeterRemote64.dll";
|
||||||
|
public static String DEFAULT_VM_WINDOWS_32BIT_PATH = "C:\\Program Files (x86)\\VB\\Voicemeeter\\VoicemeeterRemote.dll";
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
init(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(boolean is64bit) {
|
||||||
|
init(is64bit, is64bit ? DEFAULT_VM_WINDOWS_64BIT_PATH : DEFAULT_VM_WINDOWS_32BIT_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(boolean is64bit, String vmWindowsPath) {
|
||||||
|
System.load(vmWindowsPath);
|
||||||
|
instance = Native.loadLibrary("VoicemeeterRemote" + (is64bit ? "64" : ""), VoicemeeterInstance.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(VoicemeeterInstance voicemeeterInstance) {
|
||||||
|
instance = voicemeeterInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void login() throws VoicemeeterException {
|
||||||
|
int val = instance.VBVMR_Login();
|
||||||
|
switch (val) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
throw new VoicemeeterException("Voicemeeter is not open");
|
||||||
|
case -1:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter client");
|
||||||
|
case -2:
|
||||||
|
throw new VoicemeeterException("Unexpected login (The client is already logged in)");
|
||||||
|
default:
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void logout() {
|
||||||
|
int val = instance.VBVMR_Logout();
|
||||||
|
if (val != 0) {
|
||||||
|
throw new VoicemeeterException("Unexpected function reutrn value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void runVoicemeeter(int type) {
|
||||||
|
int val = instance.VBVMR_RunVoicemeeter(type);
|
||||||
|
switch (val) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
throw new VoicemeeterException("Voicemeeter is not installed");
|
||||||
|
default:
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getVoicemeeterType() {
|
||||||
|
Pointer type = getPointer(4);
|
||||||
|
int val = instance.VBVMR_GetVoicemeeterType(type);
|
||||||
|
switch (val) {
|
||||||
|
case 0:
|
||||||
|
return type.getInt(0);
|
||||||
|
case -1:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter client");
|
||||||
|
case -2:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter server");
|
||||||
|
default:
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getVoicemeeterVersion() {
|
||||||
|
Pointer version = getPointer(4);
|
||||||
|
int val = instance.VBVMR_GetVoicemeeterVersion(version);
|
||||||
|
switch (val) {
|
||||||
|
case 0:
|
||||||
|
return version.getInt(0);
|
||||||
|
case -1:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter client");
|
||||||
|
case -2:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter server");
|
||||||
|
default:
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean areParametersDirty() {
|
||||||
|
int val = instance.VBVMR_IsParametersDirty();
|
||||||
|
switch (val) {
|
||||||
|
case 0:
|
||||||
|
return false;
|
||||||
|
case 1:
|
||||||
|
return true;
|
||||||
|
case -1:
|
||||||
|
throw new VoicemeeterException("An error has occurred");
|
||||||
|
case -2:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter server");
|
||||||
|
default:
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getParameterFloat(String parameterName) {
|
||||||
|
Pointer paramName = getStringPointer(parameterName);
|
||||||
|
Pointer paramValue = getPointer(4);
|
||||||
|
int val = instance.VBVMR_GetParameterFloat(paramName, paramValue);
|
||||||
|
|
||||||
|
switch (val) {
|
||||||
|
case 0:
|
||||||
|
return paramValue.getFloat(0);
|
||||||
|
case -1:
|
||||||
|
throw new VoicemeeterException("An error has occurred");
|
||||||
|
case -2:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter server");
|
||||||
|
case -3:
|
||||||
|
throw new VoicemeeterException("Unknown parameter name");
|
||||||
|
case -5:
|
||||||
|
throw new VoicemeeterException("Structure mismatch");
|
||||||
|
default:
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getParameterStringA(String parameterName) {
|
||||||
|
Pointer paramName = getStringPointer(parameterName);
|
||||||
|
Pointer paramValue = getPointer(8);
|
||||||
|
int val = instance.VBVMR_GetParameterStringA(paramName, paramValue);
|
||||||
|
|
||||||
|
switch (val) {
|
||||||
|
case 0:
|
||||||
|
return paramValue.getString(0);
|
||||||
|
case -1:
|
||||||
|
throw new VoicemeeterException("An error has occurred");
|
||||||
|
case -2:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter server");
|
||||||
|
case -3:
|
||||||
|
throw new VoicemeeterException("Unknown parameter name");
|
||||||
|
case -5:
|
||||||
|
throw new VoicemeeterException("Structure mismatch");
|
||||||
|
default:
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getParameterStringW(String parameterName) {
|
||||||
|
Pointer paramName = getStringPointer(parameterName);
|
||||||
|
Pointer paramValue = getPointer(8);
|
||||||
|
int val = instance.VBVMR_GetParameterStringW(paramName, paramValue);
|
||||||
|
|
||||||
|
switch (val) {
|
||||||
|
case 0:
|
||||||
|
return paramValue.getString(0);
|
||||||
|
case -1:
|
||||||
|
throw new VoicemeeterException("An error has occurred");
|
||||||
|
case -2:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter server");
|
||||||
|
case -3:
|
||||||
|
throw new VoicemeeterException("Unknown parameter name");
|
||||||
|
case -5:
|
||||||
|
throw new VoicemeeterException("Structure mismatch");
|
||||||
|
default:
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getLevel(int type, int channel) {
|
||||||
|
Pointer levelValue = getPointer(4);
|
||||||
|
int val = instance.VBVMR_GetLevel(type, channel, levelValue);
|
||||||
|
|
||||||
|
switch (val) {
|
||||||
|
case 0:
|
||||||
|
return levelValue.getFloat(0);
|
||||||
|
case -1:
|
||||||
|
throw new VoicemeeterException("An error has occurred");
|
||||||
|
case -2:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter server");
|
||||||
|
case -3:
|
||||||
|
throw new VoicemeeterException("No level value available");
|
||||||
|
case -4:
|
||||||
|
throw new VoicemeeterException("The type of the channel is outside of the allowed range");
|
||||||
|
default:
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] getMidiMessage(int size) {
|
||||||
|
Pointer midiMessage = getPointer(size);
|
||||||
|
int val = instance.VBVMR_GetMidiMessage(midiMessage, size);
|
||||||
|
|
||||||
|
switch (val) {
|
||||||
|
case -1:
|
||||||
|
throw new VoicemeeterException("An error has occurred");
|
||||||
|
case -2:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter server");
|
||||||
|
case -5:
|
||||||
|
case -6:
|
||||||
|
throw new VoicemeeterException("No MIDI data available");
|
||||||
|
default:
|
||||||
|
if (val >= 0)
|
||||||
|
return midiMessage.getByteArray(0, size);
|
||||||
|
else
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setParameterFloat(String parameterName, float value) {
|
||||||
|
Pointer paramName = getStringPointer(parameterName);
|
||||||
|
int val = instance.VBVMR_SetParameterFloat(paramName, value);
|
||||||
|
|
||||||
|
switch (val) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
throw new VoicemeeterException("An error has occurred");
|
||||||
|
case -2:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter server");
|
||||||
|
case -3:
|
||||||
|
throw new VoicemeeterException("Unknown parameter name");
|
||||||
|
default:
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setParameterStringA(String parameterName, String value) {
|
||||||
|
Pointer paramName = getStringPointer(parameterName);
|
||||||
|
Pointer paramValue = getStringPointer(value);
|
||||||
|
int val = instance.VBVMR_SetParameterStringA(paramName, paramValue);
|
||||||
|
|
||||||
|
switch (val) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
throw new VoicemeeterException("An error has occurred");
|
||||||
|
case -2:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter server");
|
||||||
|
case -3:
|
||||||
|
throw new VoicemeeterException("Unknown parameter name");
|
||||||
|
default:
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setParameterStringW(String parameterName, String value) {
|
||||||
|
Pointer paramName = getStringPointer(parameterName);
|
||||||
|
Pointer paramValue = getStringPointer(value);
|
||||||
|
int val = instance.VBVMR_SetParameterStringW(paramName, paramValue);
|
||||||
|
|
||||||
|
switch (val) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
throw new VoicemeeterException("An error has occurred");
|
||||||
|
case -2:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter server");
|
||||||
|
case -3:
|
||||||
|
throw new VoicemeeterException("Unknown parameter name");
|
||||||
|
default:
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setParameters(String script) {
|
||||||
|
Pointer stringPointer = getStringPointer(script);
|
||||||
|
int val = instance.VBVMR_SetParameters(stringPointer);
|
||||||
|
|
||||||
|
switch (val) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
case -3:
|
||||||
|
case -4:
|
||||||
|
throw new VoicemeeterException("An error has occurred");
|
||||||
|
case -2:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter server");
|
||||||
|
default:
|
||||||
|
if (val > 0)
|
||||||
|
throw new VoicemeeterException("Script error on line " + val);
|
||||||
|
else
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setParametersW(String script) {
|
||||||
|
Pointer stringPointer = getStringPointer(script);
|
||||||
|
int val = instance.VBVMR_SetParametersW(stringPointer);
|
||||||
|
|
||||||
|
switch (val) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
case -3:
|
||||||
|
case -4:
|
||||||
|
throw new VoicemeeterException("An error has occurred");
|
||||||
|
case -2:
|
||||||
|
throw new VoicemeeterException("Unable to get the Voicemeeter server");
|
||||||
|
default:
|
||||||
|
if (val > 0)
|
||||||
|
throw new VoicemeeterException("Script error on line " + val);
|
||||||
|
else
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getNumberOfAudioDevices(boolean areInputDevices) {
|
||||||
|
if (areInputDevices) {
|
||||||
|
return instance.VBVMR_Input_GetDeviceNumber();
|
||||||
|
} else {
|
||||||
|
return instance.VBVMR_Output_GetDeviceNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DeviceDescription getAudioDeviceDescriptionA(int index, boolean isInputDevice) {
|
||||||
|
int val;
|
||||||
|
Pointer type = getPointer(4);
|
||||||
|
Pointer name = getPointer(4);
|
||||||
|
Pointer hardwareId = getPointer(4);
|
||||||
|
|
||||||
|
if (isInputDevice) {
|
||||||
|
val = instance.VBVMR_Input_GetDeviceDescA(index, type, name, hardwareId);
|
||||||
|
if (val != 0)
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
} else {
|
||||||
|
val = instance.VBVMR_Output_GetDeviceDescA(index, type, name, hardwareId);
|
||||||
|
if (val != 0)
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceDescription desc = new DeviceDescription();
|
||||||
|
desc.setType(type.getInt(0));
|
||||||
|
desc.setName(name.getString(0));
|
||||||
|
desc.setHardwareId(hardwareId.getString(0));
|
||||||
|
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DeviceDescription getOutputDeviceDescriptionW(int index, boolean isInputDevice) {
|
||||||
|
int val;
|
||||||
|
Pointer type = getPointer(4);
|
||||||
|
Pointer name = getPointer(4);
|
||||||
|
Pointer hardwareId = getPointer(4);
|
||||||
|
|
||||||
|
if (isInputDevice) {
|
||||||
|
val = instance.VBVMR_Input_GetDeviceDescW(index, type, name, hardwareId);
|
||||||
|
if (val != 0)
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
} else {
|
||||||
|
val = instance.VBVMR_Output_GetDeviceDescW(index, type, name, hardwareId);
|
||||||
|
if (val != 0)
|
||||||
|
throw new VoicemeeterException("Unexpected function return value. Function returned " + val);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceDescription desc = new DeviceDescription();
|
||||||
|
desc.setType(type.getInt(0));
|
||||||
|
desc.setName(name.getString(0));
|
||||||
|
desc.setHardwareId(hardwareId.getString(0));
|
||||||
|
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class DeviceDescription {
|
||||||
|
private int type;
|
||||||
|
private String name;
|
||||||
|
private String hardwareId;
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHardwareId() {
|
||||||
|
return hardwareId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHardwareId(String hardwareId) {
|
||||||
|
this.hardwareId = hardwareId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Pointer getStringPointer(String str) {
|
||||||
|
int size = str.getBytes().length + 1;
|
||||||
|
Memory m = new Memory(size);
|
||||||
|
m.setString(0, str);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Pointer getPointer(int size) {
|
||||||
|
return new Memory(size);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package de.sailehd.Voicemeeter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates an error has occurred when trying to
|
||||||
|
* interface with Voicemeeter.
|
||||||
|
*/
|
||||||
|
public class VoicemeeterException extends RuntimeException {
|
||||||
|
public VoicemeeterException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public VoicemeeterException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
623
src/main/java/de/sailehd/Voicemeeter/VoicemeeterInstance.java
Normal file
623
src/main/java/de/sailehd/Voicemeeter/VoicemeeterInstance.java
Normal file
@ -0,0 +1,623 @@
|
|||||||
|
package de.sailehd.Voicemeeter;/*
|
||||||
|
* COPYRIGHT: Vincent Burel (c) 2015 All Rights Reserved
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.sun.jna.*;
|
||||||
|
import com.sun.jna.win32.StdCallLibrary;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JNA interface modelling the VoicemeeterRemote.h file found in the
|
||||||
|
* Voicemeeter Remote API Pack, version 6. All comments been have taken from the
|
||||||
|
* VoicemeeterRemote.h header file.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public interface VoicemeeterInstance extends StdCallLibrary {
|
||||||
|
|
||||||
|
//******************************************************************************//
|
||||||
|
//* Login *//
|
||||||
|
//******************************************************************************//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the communication pipe with Voicemeeter. Must be called on software
|
||||||
|
* startup.
|
||||||
|
*
|
||||||
|
* @return Status code
|
||||||
|
* 0: OK (no error)
|
||||||
|
* 1: OK, however Voicemeeter is not open
|
||||||
|
* -1: Cannot get the client
|
||||||
|
* -2: Unexpected login (The client was already logged in)
|
||||||
|
*/
|
||||||
|
int VBVMR_Login();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the communication pipe with Voicemeeter. Must be called on software
|
||||||
|
* shutdown.
|
||||||
|
*
|
||||||
|
* @return Status code
|
||||||
|
* 0: OK (no error)
|
||||||
|
*/
|
||||||
|
int VBVMR_Logout();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the Voicemeeter application. Gets the directory and runs the program.
|
||||||
|
*
|
||||||
|
* @param type Voicemeeter type.
|
||||||
|
* 1: Voicemeeter
|
||||||
|
* 2: Voicemeeter Banana
|
||||||
|
* @return Status code
|
||||||
|
* 0: OK (no error)
|
||||||
|
* -1: Voicemeeter not installed
|
||||||
|
*/
|
||||||
|
int VBVMR_RunVoicemeeter(int type);
|
||||||
|
|
||||||
|
|
||||||
|
//******************************************************************************//
|
||||||
|
//* General Information *//
|
||||||
|
//******************************************************************************//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets Voicemeeter type.
|
||||||
|
*
|
||||||
|
* @param type 32bit long pointer that will receive the type.
|
||||||
|
* 1: Voicemeeter
|
||||||
|
* 2: Voicemeeter Banana
|
||||||
|
* @return Status code
|
||||||
|
* 0: OK (no error)
|
||||||
|
* -1: Cannot get client
|
||||||
|
* -2: No server
|
||||||
|
*/
|
||||||
|
int VBVMR_GetVoicemeeterType(Pointer type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets Voicemeeter version.
|
||||||
|
* @param version 32bit int pointer that will receive the version
|
||||||
|
* v1 = (version & 0xFF000000) >> 24;
|
||||||
|
* v2 = (version & 0x00FF0000) >> 16;
|
||||||
|
* v3 = (version & 0x0000FF00) >> 8;
|
||||||
|
* v4 = (version & 0x000000FF);
|
||||||
|
* @return Status code
|
||||||
|
* 0: OK (no error)
|
||||||
|
* -1: Cannot get client
|
||||||
|
* -2: No server
|
||||||
|
*/
|
||||||
|
int VBVMR_GetVoicemeeterVersion(Pointer version);
|
||||||
|
|
||||||
|
|
||||||
|
//******************************************************************************//
|
||||||
|
//* Get parameters *//
|
||||||
|
//******************************************************************************//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if parameters have changed. Useful for any GUI displays that display
|
||||||
|
* parameter values. Not thread safe.
|
||||||
|
*
|
||||||
|
* @return 0: No parameters have changed
|
||||||
|
* 1: Parameters have been changed
|
||||||
|
* -1: Error
|
||||||
|
* -2: No server
|
||||||
|
*/
|
||||||
|
int VBVMR_IsParametersDirty();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get float parameter value. See parameter table values for examples.
|
||||||
|
*
|
||||||
|
* @param paramName ASCII string pointer containing the name of the parameter
|
||||||
|
* @param value 32bit float pointer that will receive the value of the
|
||||||
|
* parameter.
|
||||||
|
* @return Status code
|
||||||
|
* 0: OK (no error)
|
||||||
|
* -1: Error
|
||||||
|
* -2: No server
|
||||||
|
* -3: Unknown parameter
|
||||||
|
* -5: Structure mismatch
|
||||||
|
*/
|
||||||
|
int VBVMR_GetParameterFloat(Pointer paramName, Pointer value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get string paramter value
|
||||||
|
*
|
||||||
|
* @param paramName ASCII string pointer containing the name of the parameter
|
||||||
|
* @param string 64bit string pointer that will receive the value of the
|
||||||
|
* parameter.
|
||||||
|
* @return Status code
|
||||||
|
* 0: OK (no error)
|
||||||
|
* -1: Error
|
||||||
|
* -2: No server
|
||||||
|
* -3: Unknown Parameter
|
||||||
|
* -5: Structure mismatch
|
||||||
|
*/
|
||||||
|
int VBVMR_GetParameterStringA(Pointer paramName, Pointer string);
|
||||||
|
int VBVMR_GetParameterStringW(Pointer paramName, Pointer string);
|
||||||
|
|
||||||
|
|
||||||
|
//******************************************************************************//
|
||||||
|
//* Get levels *//
|
||||||
|
//******************************************************************************//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get level data. Not thread safe.
|
||||||
|
*
|
||||||
|
* Voicemeeter Channel Assignment:
|
||||||
|
*
|
||||||
|
* | Strip 1 | Strip 2| Virtual Input |
|
||||||
|
* |---------|--------|----------------------------------------|
|
||||||
|
* | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 |
|
||||||
|
*
|
||||||
|
* | Output A1 / A2 | Virtual Output |
|
||||||
|
* +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
|
||||||
|
* | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 |
|
||||||
|
*
|
||||||
|
* Voicemeeter Banana Channel Assignment:
|
||||||
|
*
|
||||||
|
* | Strip 1 | Strip 2 | Strip 3 | Virtual Input | Virtual Input AUX |
|
||||||
|
* +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
|
||||||
|
* | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
|
||||||
|
*
|
||||||
|
* | Output A1 | Output A2 | Output A3 |
|
||||||
|
* +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
|
||||||
|
* | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
|
||||||
|
*
|
||||||
|
* | Virtual Output B1 | Virtual Output B2 |
|
||||||
|
* +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
|
||||||
|
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param type The type of level to get.
|
||||||
|
* 0: Pre-fader input levels
|
||||||
|
* 1: Post-fader input levels
|
||||||
|
* 2: Post-mute input levels
|
||||||
|
* 3: Output levels
|
||||||
|
* @param channel Zero-indexed audio channel.
|
||||||
|
* @param value 32bit float pointer that will receive the level value.
|
||||||
|
*
|
||||||
|
* @return Status code
|
||||||
|
* 0: OK (no error)
|
||||||
|
* -1: Error
|
||||||
|
* -2: No server
|
||||||
|
* -3: No level available
|
||||||
|
* -4: type of channel out of allowed range
|
||||||
|
*/
|
||||||
|
int VBVMR_GetLevel(int type, int channel, Pointer value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets MIDI message from MIDI input devices used by Voicemeeter MIDI mapping.
|
||||||
|
* Not thread safe.
|
||||||
|
*
|
||||||
|
* @param midiBuffer Pointer for MIDI buffer. Expected messages size is below
|
||||||
|
* 4 bytes, however it is recommend to have at least 1024
|
||||||
|
* bytes to receive possibly multiple MIDI event messages
|
||||||
|
* at once.
|
||||||
|
* @param byteMax Size of the midiBuffer pointer.
|
||||||
|
* @return Status Code
|
||||||
|
* >0: Numer of bytes placed in buffer
|
||||||
|
* -1: Error
|
||||||
|
* -2: No server
|
||||||
|
* -5 OR -6: No MIDI data
|
||||||
|
*/
|
||||||
|
int VBVMR_GetMidiMessage(Pointer midiBuffer, int byteMax);
|
||||||
|
|
||||||
|
|
||||||
|
//******************************************************************************//
|
||||||
|
//* Set Parameters *//
|
||||||
|
//******************************************************************************//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a 32bit float parameter.
|
||||||
|
*
|
||||||
|
* Example parameter names:
|
||||||
|
* Strip[1].gain
|
||||||
|
* Strip[0].mute
|
||||||
|
* Bus[0].gain
|
||||||
|
* Bus[0].eq.channel[0].cell[0].gain
|
||||||
|
*
|
||||||
|
* @param paramName ASCII string pointer containing the name of the parameter
|
||||||
|
* @param value 32bit float pointer that will receive the value of the
|
||||||
|
* parameter.
|
||||||
|
* @return Status Code:
|
||||||
|
* 0: OK (no error)
|
||||||
|
* -1: Error
|
||||||
|
* -2: No server
|
||||||
|
* -3: Unknown Parameter.
|
||||||
|
*/
|
||||||
|
int VBVMR_SetParameterFloat(Pointer paramName, float value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a string parameter.
|
||||||
|
*
|
||||||
|
* @param paramName ASCII string pointer containing the name of the parameter
|
||||||
|
* @param string ASCII string pointer containing the new value of the
|
||||||
|
* parameter
|
||||||
|
* @return Status code
|
||||||
|
* 0: OK (no error)
|
||||||
|
* -1: Error
|
||||||
|
* -2: No server
|
||||||
|
* -3: Unknown Parameter
|
||||||
|
*/
|
||||||
|
int VBVMR_SetParameterStringA(Pointer paramName, Pointer string);
|
||||||
|
int VBVMR_SetParameterStringW(Pointer paramName, Pointer string);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set one or several parameter using a script less the 48 kB. Separate
|
||||||
|
* different assignments with ',', ';', or '\n'. See the scripts folder in the
|
||||||
|
* Voicemeeter Remote API pack for examples.
|
||||||
|
*
|
||||||
|
* @param paramScript ASCII string pointer containing the script.
|
||||||
|
* @return Status code
|
||||||
|
* 0: OK (no error)
|
||||||
|
* >0: Error, where the number is the line number that caused
|
||||||
|
* the error
|
||||||
|
* -1: Error
|
||||||
|
* -2: No server
|
||||||
|
* -3 OR -4: Unexpected error
|
||||||
|
*/
|
||||||
|
int VBVMR_SetParameters(Pointer paramScript);
|
||||||
|
int VBVMR_SetParametersW(Pointer paramScript);
|
||||||
|
|
||||||
|
|
||||||
|
//******************************************************************************//
|
||||||
|
//* DEVICES ENUMERATOR *//
|
||||||
|
//******************************************************************************//
|
||||||
|
|
||||||
|
int VBVMR_RESULT_OK = 0;
|
||||||
|
int VBVMR_DEVTYPE_MME = 1;
|
||||||
|
int VBVMR_DEVTYPE_WDM = 3;
|
||||||
|
int VBVMR_DEVTYPE_KS = 4;
|
||||||
|
int VBVMR_DEVTYPE_ASIO = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of audio output devices available on the system.
|
||||||
|
*
|
||||||
|
* @return Number of devices found.
|
||||||
|
*/
|
||||||
|
int VBVMR_Output_GetDeviceNumber();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find an output device by index and maps it's type, name, and hardwareID to
|
||||||
|
* pointers. All pointers can be null. See API PDF for more details.
|
||||||
|
*
|
||||||
|
* @param index Zero-based index of the device
|
||||||
|
* @param type 32bit long pointer that will receive the device type.
|
||||||
|
* @param deviceName 32bit (minimum) string pointer that will receive the
|
||||||
|
* device name.
|
||||||
|
* @param hardwareId 32bit (minimum) string pointer that will receive the
|
||||||
|
* hardware ID.
|
||||||
|
* @return Status code
|
||||||
|
* 0: OK (no error)
|
||||||
|
*/
|
||||||
|
int VBVMR_Output_GetDeviceDescA(int index, Pointer type, Pointer deviceName, Pointer hardwareId);
|
||||||
|
int VBVMR_Output_GetDeviceDescW(int index, Pointer type, Pointer deviceName, Pointer hardwareId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of audio input device available on the system
|
||||||
|
*
|
||||||
|
* @return Number of devices found.
|
||||||
|
*/
|
||||||
|
int VBVMR_Input_GetDeviceNumber();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a device by index and maps it's type, name, and hardwareID to
|
||||||
|
* pointers. All pointers can be null. See API PDF for more details.
|
||||||
|
*
|
||||||
|
* @param index Zero-based index of the device
|
||||||
|
* @param type 32bit long pointer that will receive the device type
|
||||||
|
* @param deviceName 32bit (minimum) string pointer that will receive the
|
||||||
|
* device name
|
||||||
|
* @param hardwareId 32bit (minimum) string pointer that will receive the
|
||||||
|
* hardware ID.
|
||||||
|
* @return Status code
|
||||||
|
* 0: OK (no error)
|
||||||
|
*/
|
||||||
|
int VBVMR_Input_GetDeviceDescA(int index, Pointer type, Pointer deviceName, Pointer hardwareId);
|
||||||
|
int VBVMR_Input_GetDeviceDescW(int index, Pointer type, Pointer deviceName, Pointer hardwareId);
|
||||||
|
|
||||||
|
|
||||||
|
//******************************************************************************//
|
||||||
|
//* VB-AUDIO CALLBACK *//
|
||||||
|
//******************************************************************************//
|
||||||
|
|
||||||
|
// Command to initialize data according to SR and buffer size.
|
||||||
|
// info = (VBVMR_LPT_AUDIOINFO) data
|
||||||
|
int VBVMR_CBCOMMAND_STARTING = 1;
|
||||||
|
|
||||||
|
// Command to release data
|
||||||
|
int VBVMR_CBCOMMAND_ENDING = 2;
|
||||||
|
|
||||||
|
// If there is a change in audio stream, you must restart audio.
|
||||||
|
int VBVMR_CBCOMMAND_CHANGE = 3;
|
||||||
|
|
||||||
|
// Input insert
|
||||||
|
int VBVMR_CBCOMMAND_BUFFER_IN = 10;
|
||||||
|
|
||||||
|
// Bus output insert
|
||||||
|
int VBVMR_CBCOMMAND_BUFFER_OUT = 11;
|
||||||
|
|
||||||
|
// All I/O
|
||||||
|
// audiobuffer = (VBVMR_LPT_AUDIOBUFFER) data
|
||||||
|
// nnn = 1 if syncronized with Voicemeeter
|
||||||
|
int VBVMR_CBCOMMAND_BUFFER_MAIN = 20;
|
||||||
|
|
||||||
|
// Process input insert
|
||||||
|
int VBVMR_AUDIOCALLBACK_IN = 0x00000001;
|
||||||
|
|
||||||
|
// Process output bus insert
|
||||||
|
int VBVMR_AUDIOCALLBACK_OUT = 0x00000002;
|
||||||
|
|
||||||
|
// Receive all I/O
|
||||||
|
int VBVMR_AUDIOCALLBACK_MAIN = 0x00000004;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register your audio callback function to receive real time audio buffer.
|
||||||
|
* It's possible to register up to three different audio callbacks in the same
|
||||||
|
* application or in three different applications. In the same application, it
|
||||||
|
* is possible because Voicemeeter provides three kinds of audio streams:
|
||||||
|
* - Audio Input Insert: Processes all Voicemeeter inputs as insert
|
||||||
|
* - Audio Output Insert: Processes all Voicemeeter BUS outputs as insert
|
||||||
|
* - All Audio I/O: Processes all Voicemeeter I/O
|
||||||
|
*
|
||||||
|
* Note: A single callback can be used to receive the three possible audio
|
||||||
|
* streams.
|
||||||
|
*
|
||||||
|
* @param mode Callback type:
|
||||||
|
* Input: VBVMR_AUDIOCALLBACK_IN
|
||||||
|
* Output: VBVMR_AUDIOCALLBACK_OUT
|
||||||
|
* Main: VBVMR_AUDIOCALLBACK_MAIN
|
||||||
|
* @param callback Pointer to your callback function
|
||||||
|
* @param user Pointer that will be passed to the callback function's
|
||||||
|
* first arguments
|
||||||
|
* @param clientName Input: Name of the application registering the callback
|
||||||
|
* Output: Name of the application already registered
|
||||||
|
* @return Status code:
|
||||||
|
* 0: OK (no error)
|
||||||
|
* -1: Error
|
||||||
|
* 1: Callback already registered by another application
|
||||||
|
*/
|
||||||
|
int VBVMR_AudioCallbackRegister(int mode, T_VBVMR_VBAUDIOCALLBACK callback, Pointer user, char[] clientName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start or Stop calling the callback.
|
||||||
|
*
|
||||||
|
* @return Status code
|
||||||
|
* 0: OK (no error)
|
||||||
|
* -1: Error
|
||||||
|
* -2: No callback registered
|
||||||
|
*/
|
||||||
|
int VBVMR_AudioCallbackStart();
|
||||||
|
int VBVMR_AudioCallbackStop();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregister your callback and release the Voicemeeter virtual driver. This
|
||||||
|
* function will automatically call VBVMR_AudioCallbackStop().
|
||||||
|
*
|
||||||
|
* @return Status Code
|
||||||
|
* 0: OK (no error)
|
||||||
|
* -1: Error
|
||||||
|
* 1: Callback already unregistered
|
||||||
|
*/
|
||||||
|
int VBVMR_AudioCallbackUnregister();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VBAUDIOCALLBACK is called for different tasks to initialize, perform, and
|
||||||
|
* end your process. It is part of a single time-critical thread.
|
||||||
|
* It is non-re-entrant (meaning it cannot be called while in the process).
|
||||||
|
*
|
||||||
|
* Additionally, it must be real time when called to process buffer, meaning
|
||||||
|
* that the process has to be performed as fast as possible. Waiting cycles
|
||||||
|
* are forbidden. No not use OS synchronization objects. Do not use system
|
||||||
|
* functions that can generate that can generate waiting cycles like display,
|
||||||
|
* disk, or communication functions.
|
||||||
|
*/
|
||||||
|
interface T_VBVMR_VBAUDIOCALLBACK extends StdCallCallback {
|
||||||
|
/**
|
||||||
|
* @param user User pointer given on callback registration
|
||||||
|
* @param command Reason why the callback is called
|
||||||
|
* @param data Pointer on structure, pending on command
|
||||||
|
* @param nnn Additional unused data
|
||||||
|
* @return 0
|
||||||
|
*/
|
||||||
|
boolean callback(Pointer user, int command, Pointer data, int nnn);
|
||||||
|
}
|
||||||
|
|
||||||
|
class tagVBVMR_AUDIOINFO extends Structure {
|
||||||
|
public int samplerate;
|
||||||
|
public int nbSamplePerFrame;
|
||||||
|
|
||||||
|
protected List<String> getFieldOrder() {
|
||||||
|
return Arrays.asList("samplerate", "nbSamplePerFrame");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class tagVBVMR_AUDIOBUFFER extends Structure {
|
||||||
|
// Sampling rate
|
||||||
|
public int audiobuffer_sr;
|
||||||
|
|
||||||
|
// Number of samples per frame
|
||||||
|
public int audiobuffer_nbs;
|
||||||
|
|
||||||
|
// Number of inputs
|
||||||
|
public int audiobuffer_nbi;
|
||||||
|
|
||||||
|
// Number of outputs
|
||||||
|
public int audiobuffer_nbo;
|
||||||
|
|
||||||
|
// NBI input pointers containing frames of nbs samples (32bit floats)
|
||||||
|
public Pointer audiobuffer_r;
|
||||||
|
|
||||||
|
// NBO output pointers containing frames of nbo samples (32bit floats)
|
||||||
|
public Pointer audiobuffer_w;
|
||||||
|
|
||||||
|
protected List<String> getFieldOrder() {
|
||||||
|
return Arrays.asList("audiobuffer_sr", "audiobuffer_nbs", "audiobuffer_nbi", "audiobuffer_nbo", "audiobuffer_r", "audiobuffer_w");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tagVBVMR_AUDIOINFO VBVMR_T_AUDIOINFO = new tagVBVMR_AUDIOINFO();
|
||||||
|
Pointer VBVMR_PT_AUDIOINFO = new tagVBVMR_AUDIOINFO().getPointer();
|
||||||
|
Pointer VBVBMR_LPT_AUDIOINFO = new tagVBVMR_AUDIOINFO().getPointer();
|
||||||
|
|
||||||
|
tagVBVMR_AUDIOBUFFER VBVMR_T_AUDIOBUFFER = new tagVBVMR_AUDIOBUFFER();
|
||||||
|
Pointer VBVMR_PT_AUDIOBUFFER = new tagVBVMR_AUDIOBUFFER().getPointer();
|
||||||
|
Pointer VBVMR_LPT_AUDIOBUFFER = new tagVBVMR_AUDIOBUFFER().getPointer();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//******************************************************************************//
|
||||||
|
//* 'C' STRUCTURED INTERFACE *//
|
||||||
|
//******************************************************************************//
|
||||||
|
|
||||||
|
interface T_VBVMR_Login extends StdCallCallback {
|
||||||
|
boolean callback();
|
||||||
|
}
|
||||||
|
interface T_VBVMR_Logout extends StdCallCallback {
|
||||||
|
boolean callback();
|
||||||
|
}
|
||||||
|
interface T_VBVMR_RunVoicemeeter extends StdCallCallback {
|
||||||
|
boolean callback(int type);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface T_VBVMR_GetVoicemeeterType extends StdCallCallback {
|
||||||
|
boolean callback(Pointer type);
|
||||||
|
}
|
||||||
|
interface T_VBVMR_GetVoicemeeterVersion extends StdCallCallback {
|
||||||
|
boolean callback(Pointer version);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface T_VBVMR_IsParametersDirty extends StdCallCallback {
|
||||||
|
boolean callback();
|
||||||
|
}
|
||||||
|
interface T_VBVMR_GetParameterFloat extends StdCallCallback {
|
||||||
|
boolean callback(Pointer paramName, Pointer value);
|
||||||
|
}
|
||||||
|
interface T_VBVMR_GetParameterStringA extends StdCallCallback {
|
||||||
|
boolean callback(Pointer paramName, Pointer string);
|
||||||
|
}
|
||||||
|
interface T_VBVMR_GetParameterStringW extends StdCallCallback {
|
||||||
|
boolean callback(Pointer paramName, Pointer string);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface T_VBVMR_GetLevel extends StdCallCallback {
|
||||||
|
boolean callback(int type, int channel, Pointer value);
|
||||||
|
}
|
||||||
|
interface T_VBVMR_GetMidiMessage extends StdCallCallback {
|
||||||
|
boolean callback(Pointer pMIDIBuffer, int byteMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface T_VBVMR_SetParameterFloat extends StdCallCallback {
|
||||||
|
boolean callback(Pointer paramName, int value);
|
||||||
|
}
|
||||||
|
interface T_VBVMR_SetParameters extends StdCallCallback {
|
||||||
|
boolean callback(Pointer paramScript);
|
||||||
|
}
|
||||||
|
interface T_VBVMR_SetParametersW extends StdCallCallback {
|
||||||
|
boolean callback(Pointer paramScript);
|
||||||
|
}
|
||||||
|
interface T_VBVMR_SetParameterStringA extends StdCallCallback {
|
||||||
|
boolean callback(Pointer paramName, Pointer string);
|
||||||
|
}
|
||||||
|
interface T_VBVMR_SetParameterStringW extends StdCallCallback {
|
||||||
|
boolean callback(Pointer paramName, Pointer string);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface T_VBVMR_Output_GetDeviceNumber extends StdCallCallback {
|
||||||
|
boolean callback();
|
||||||
|
}
|
||||||
|
interface T_VBVMR_Output_GetDeviceDescA extends StdCallCallback {
|
||||||
|
boolean callback(int index, Pointer type, Pointer deviceName, Pointer hardwareId);
|
||||||
|
}
|
||||||
|
interface T_VBVMR_Output_GetDeviceDescW extends StdCallCallback {
|
||||||
|
boolean callback(int index, Pointer type, Pointer deviceName, Pointer hardwareId);
|
||||||
|
}
|
||||||
|
interface T_VBVMR_Input_GetDeviceNumber extends StdCallCallback {
|
||||||
|
boolean callback();
|
||||||
|
}
|
||||||
|
interface T_VBVMR_Input_GetDeviceDescA extends StdCallCallback {
|
||||||
|
boolean callback(int index, Pointer type, Pointer deviceName, Pointer hardwareId);
|
||||||
|
}
|
||||||
|
interface T_VBVMR_Input_GetDeviceDescW extends StdCallCallback {
|
||||||
|
boolean callback(int index, Pointer type, Pointer deviceName, Pointer hardwareId);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface T_VBVMR_AudioCallbackRegister extends StdCallCallback {
|
||||||
|
boolean callback(int mode, T_VBVMR_VBAUDIOCALLBACK callback, Pointer user, char[] clientName);
|
||||||
|
}
|
||||||
|
interface T_VBVMR_AudioCallbackStart extends StdCallCallback {
|
||||||
|
boolean callback();
|
||||||
|
}
|
||||||
|
interface T_VBVMR_AudioCallbackStop extends StdCallCallback {
|
||||||
|
boolean callback();
|
||||||
|
}
|
||||||
|
interface T_VBVMR_AudioCallbackUnregister extends StdCallCallback {
|
||||||
|
boolean callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
class tagVBVMR_INTERFACE extends Structure {
|
||||||
|
public T_VBVMR_Login VBVMR_Login;
|
||||||
|
public T_VBVMR_Logout VBVMR_Logout;
|
||||||
|
public T_VBVMR_RunVoicemeeter VBVMR_RunVoicemeeter;
|
||||||
|
public T_VBVMR_GetVoicemeeterType VBVMR_GetVoicemeeterType;
|
||||||
|
public T_VBVMR_GetVoicemeeterVersion VBVMR_GetVoicemeeterVersion;
|
||||||
|
public T_VBVMR_IsParametersDirty VBVMR_IsParametersDirty;
|
||||||
|
public T_VBVMR_GetParameterFloat VBVMR_GetParameterFloat;
|
||||||
|
public T_VBVMR_GetParameterStringA VBVMR_GetParameterStringA;
|
||||||
|
public T_VBVMR_GetParameterStringW VBVMR_GetParameterStringW;
|
||||||
|
|
||||||
|
public T_VBVMR_GetLevel VBVMR_GetLevel;
|
||||||
|
public T_VBVMR_GetMidiMessage VBVMR_GetMidiMessage;
|
||||||
|
|
||||||
|
public T_VBVMR_SetParameterFloat VBVMR_SetParameterFloat;
|
||||||
|
public T_VBVMR_SetParameters VBVMR_SetParameters;
|
||||||
|
public T_VBVMR_SetParametersW VBVMR_SetParametersW;
|
||||||
|
public T_VBVMR_SetParameterStringA VBVMR_SetParameterStringA;
|
||||||
|
public T_VBVMR_SetParameterStringW VBVMR_SetParameterStringW;
|
||||||
|
|
||||||
|
public T_VBVMR_Output_GetDeviceNumber VBVMR_Output_GetDeviceNumber;
|
||||||
|
public T_VBVMR_Output_GetDeviceDescA VBVMR_Output_GetDeviceDescA;
|
||||||
|
public T_VBVMR_Output_GetDeviceDescW VBVMR_Output_GetDeviceDescW;
|
||||||
|
public T_VBVMR_Input_GetDeviceNumber VBVMR_Input_GetDeviceNumber;
|
||||||
|
public T_VBVMR_Input_GetDeviceDescA VBVMR_Input_GetDeviceDescA;
|
||||||
|
public T_VBVMR_Input_GetDeviceDescW VBVMR_Input_GetDeviceDescW;
|
||||||
|
|
||||||
|
public T_VBVMR_AudioCallbackRegister VBVMR_AudioCallbackRegister;
|
||||||
|
public T_VBVMR_AudioCallbackStart VBVMR_AudioCallbackStart;
|
||||||
|
public T_VBVMR_AudioCallbackStop VBVMR_AudioCallbackStop;
|
||||||
|
public T_VBVMR_AudioCallbackUnregister VBVMR_AudioCallbackUnregister;
|
||||||
|
|
||||||
|
protected List<String> getFieldOrder() {
|
||||||
|
return Arrays.asList(
|
||||||
|
"VBVMR_Login",
|
||||||
|
"VBVMR_Logout",
|
||||||
|
"VBVMR_RunVoicemeeter",
|
||||||
|
"VBVMR_GetVoicemeeterType",
|
||||||
|
"VBVMR_GetVoicemeeterVersion",
|
||||||
|
"VBVMR_IsParametersDirty",
|
||||||
|
"VBVMR_GetParameterFloat",
|
||||||
|
"VBVMR_GetParameterStringA",
|
||||||
|
"VBVMR_GetParameterStringW",
|
||||||
|
"VBVMR_GetLevel",
|
||||||
|
"VBVMR_GetMidiMessage",
|
||||||
|
"VBVMR_SetParameterFloat",
|
||||||
|
"VBVMR_SetParameters",
|
||||||
|
"VBVMR_SetParametersW",
|
||||||
|
"VBVMR_SetParameterStringA",
|
||||||
|
"VBVMR_SetParameterStringW",
|
||||||
|
"VBVMR_Output_GetDeviceNumber",
|
||||||
|
"VBVMR_Output_GetDeviceDescA",
|
||||||
|
"VBVMR_Output_GetDeviceDescW",
|
||||||
|
"VBVMR_Input_GetDeviceNumber",
|
||||||
|
"VBVMR_Input_GetDeviceDescA",
|
||||||
|
"VBVMR_Input_GetDeviceDescW",
|
||||||
|
"VBVMR_AudioCallbackRegister",
|
||||||
|
"VBVMR_AudioCallbackStart",
|
||||||
|
"VBVMR_AudioCallbackStop",
|
||||||
|
"VBVMR_AudioCallbackUnregister"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tagVBVMR_INTERFACE T_VBVMR_INTERFACE = new tagVBVMR_INTERFACE();
|
||||||
|
Pointer PT_VBVMR_INTERFACE = new tagVBVMR_INTERFACE().getPointer();
|
||||||
|
Pointer LPT_VBVMR_INTERFACE = new tagVBVMR_INTERFACE().getPointer();
|
||||||
|
}
|
||||||
20
src/main/java/de/sailehd/support/Debug.java
Normal file
20
src/main/java/de/sailehd/support/Debug.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package de.sailehd.support;
|
||||||
|
|
||||||
|
public class Debug {
|
||||||
|
|
||||||
|
public static void log(String message){
|
||||||
|
System.out.println(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void logError(String message){
|
||||||
|
System.err.println(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void logWarning(String message){ System.out.println(TextColor.YELLOW + message + TextColor.RESET);}
|
||||||
|
|
||||||
|
public static void clear(){
|
||||||
|
System.out.print("\033[H\033[2J");
|
||||||
|
|
||||||
|
System.out.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
772
src/main/java/de/sailehd/support/EasyBase.java
Normal file
772
src/main/java/de/sailehd/support/EasyBase.java
Normal file
@ -0,0 +1,772 @@
|
|||||||
|
package de.sailehd.support;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class EasyBase {
|
||||||
|
|
||||||
|
private File easyBase = null;
|
||||||
|
private ArrayList<String> lines = new ArrayList<String>();
|
||||||
|
private String fileName;
|
||||||
|
private String baseName;
|
||||||
|
|
||||||
|
|
||||||
|
public EasyBase(String name){
|
||||||
|
fileName = name + ".esb";
|
||||||
|
baseName = name;
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateBaseFile(boolean debugMessage){
|
||||||
|
try {
|
||||||
|
File newDataBase = new File(fileName);
|
||||||
|
if (newDataBase.createNewFile()) {
|
||||||
|
System.out.println("File created: " + newDataBase.getName());
|
||||||
|
easyBase = newDataBase;
|
||||||
|
initFile(easyBase);
|
||||||
|
} else {
|
||||||
|
//System.out.println("File already exists.");
|
||||||
|
try{
|
||||||
|
ClassLoader classLoader = getClass().getClassLoader();
|
||||||
|
File tempEasyBase = new File(fileName);
|
||||||
|
try{
|
||||||
|
if(tempEasyBase.getName().endsWith(".esb")){
|
||||||
|
lines = readFile(tempEasyBase);
|
||||||
|
try {
|
||||||
|
if(lines.get(0).equals(fileName) && lines.get(1).equals("{") && lines.get(lines.size() - 1).equals("}")){
|
||||||
|
easyBase = tempEasyBase;
|
||||||
|
if(debugMessage){
|
||||||
|
System.out.println(baseName +" Initialized");
|
||||||
|
}
|
||||||
|
|
||||||
|
//System.out.println(lines.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
System.out.println("The File is not a vaild Database");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
System.out.println("The File is not a vaild Database");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("An error occurred.");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArrayList<String> readFile(File file){
|
||||||
|
ArrayList<String> tempLines = new ArrayList<String>();
|
||||||
|
try {
|
||||||
|
Scanner myReader = new Scanner(file);
|
||||||
|
while (myReader.hasNextLine()) {
|
||||||
|
String data = myReader.nextLine();
|
||||||
|
tempLines.add(data);
|
||||||
|
}
|
||||||
|
myReader.close();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
print("An error occurred.");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return tempLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkForDuplicate(String name){
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
for (String line : lines) {
|
||||||
|
if(line.contains(name)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initFile(File file){
|
||||||
|
try {
|
||||||
|
PrintStream fW = new PrintStream(file);
|
||||||
|
fW.println(file.getName());
|
||||||
|
fW.println("{");
|
||||||
|
fW.println("}");
|
||||||
|
print("File Initialized");
|
||||||
|
} catch (IOException e) {
|
||||||
|
print("An error occurred.");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rewriteFile(){
|
||||||
|
try {
|
||||||
|
PrintStream fW = new PrintStream(easyBase);
|
||||||
|
for (String line : lines) {
|
||||||
|
try{
|
||||||
|
fW.println(line);
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//print("File Rewritten");
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createData(String name, Object data){
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
try{
|
||||||
|
if(checkForDuplicate(name)){
|
||||||
|
//print("Data already exists");
|
||||||
|
//print(lines.toString());
|
||||||
|
//editData("name", data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data instanceof String){
|
||||||
|
lines.add(2, "String " + name + " = " + (String) data);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Byte){
|
||||||
|
lines.add(2, "Byte " + name + " = " + (Byte) data);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Short){
|
||||||
|
lines.add(2, "Short " + name + " = " + (Short) data);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Integer){
|
||||||
|
lines.add(2, "Integer " + name + " = " + (Integer) data);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Long){
|
||||||
|
lines.add(2, "Long " + name + " = " + (Long) data);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Float){
|
||||||
|
lines.add(2, "Float " + name + " = " + (Float) data);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Double){
|
||||||
|
lines.add(2, "Double " + name + " = " + (Double) data);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Boolean){
|
||||||
|
lines.add(2, "Boolean " + name + " = " + (Boolean) data);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof ArrayList){
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
if(((ArrayList<?>) data).get(0) instanceof String){
|
||||||
|
if(((ArrayList<String>) data).size() != 0){
|
||||||
|
for (String listdata : (ArrayList<String>) data) {
|
||||||
|
builder.append(listdata + " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lines.add(2, "ArrayList <String> " + name + " = " + "{ " + builder.toString() + "}");
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(((ArrayList<?>) data).get(0) instanceof Byte){
|
||||||
|
if(((ArrayList<Byte>) data).size() != 0){
|
||||||
|
for (Byte listdata : (ArrayList<Byte>) data) {
|
||||||
|
builder.append(listdata + " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lines.add(2, "ArrayList <Byte> " + name + " = " + "{ " + builder.toString() + "}");
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(((ArrayList<?>) data).get(0) instanceof Short){
|
||||||
|
if(((ArrayList<Short>) data).size() != 0){
|
||||||
|
for (Short listdata : (ArrayList<Short>) data) {
|
||||||
|
builder.append(listdata + " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lines.add(2, "ArrayList <Short> " + name + " = " + "{ " + builder.toString() + "}");
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(((ArrayList<?>) data).get(0) instanceof Integer){
|
||||||
|
if(((ArrayList<Integer>) data).size() != 0){
|
||||||
|
for (Integer listdata : (ArrayList<Integer>) data) {
|
||||||
|
builder.append(listdata + " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lines.add(2, "ArrayList <Integer> " + name + " = " + "{ " + builder.toString() + "}");
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(((ArrayList<?>) data).get(0) instanceof Long){
|
||||||
|
if(((ArrayList<Long>) data).size() != 0){
|
||||||
|
for (Long listdata : (ArrayList<Long>) data) {
|
||||||
|
builder.append(listdata + " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lines.add(2, "ArrayList <Long> " + name + " = " + "{ " + builder.toString() + "}");
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(((ArrayList<?>) data).get(0) instanceof Float){
|
||||||
|
if(((ArrayList<Float>) data).size() != 0){
|
||||||
|
for (Float listdata : (ArrayList<Float>) data) {
|
||||||
|
builder.append(listdata + " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lines.add(2, "ArrayList <Float> " + name + " = " + "{ " + builder.toString() + "}");
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(((ArrayList<?>) data).get(0) instanceof Double){
|
||||||
|
if(((ArrayList<Double>) data).size() != 0){
|
||||||
|
for (Double listdata : (ArrayList<Double>) data) {
|
||||||
|
builder.append(listdata + " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lines.add(2, "ArrayList <Double> " + name + " = " + "{ " + builder.toString() + "}");
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(((ArrayList<?>) data).get(0) instanceof Boolean){
|
||||||
|
if(((ArrayList<Boolean>) data).size() != 0){
|
||||||
|
for (Boolean listdata : (ArrayList<Boolean>) data) {
|
||||||
|
builder.append(listdata + " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lines.add(2, "ArrayList <Boolean> " + name + " = " + "{ " + builder.toString() + "}");
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
print("Datatype is not allowd in ArrayList");
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
print("Datatype ist not valid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getData(String name){
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
for (String line : lines) {
|
||||||
|
String[] lineStrings = line.split(" ");
|
||||||
|
ArrayList<String> lineArrayList = new ArrayList<String>();
|
||||||
|
for(String s : lineStrings){
|
||||||
|
if(!line.equals("")){
|
||||||
|
lineArrayList.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//print(lines.toString());
|
||||||
|
if(lineArrayList.size() > 1){
|
||||||
|
if(lineArrayList.get(1).equals(name)){
|
||||||
|
if(lineArrayList.get(0).equals("String")){
|
||||||
|
StringBuilder string = new StringBuilder();
|
||||||
|
for (String word : lineArrayList){
|
||||||
|
if(lineArrayList.size() == 4){
|
||||||
|
return lineArrayList.get(3);
|
||||||
|
}
|
||||||
|
else if(lineArrayList.indexOf(word) >= 3){
|
||||||
|
string.append(word + " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string.toString();
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Byte")){
|
||||||
|
return Byte.parseByte(lineArrayList.get(lineArrayList.size() - 1));
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Short")){
|
||||||
|
return Short.parseShort(lineArrayList.get(lineArrayList.size() - 1));
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Integer")){
|
||||||
|
return Integer.parseInt(lineArrayList.get(lineArrayList.size() - 1));
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Long")){
|
||||||
|
return Long.parseLong(lineArrayList.get(lineArrayList.size() - 1));
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Float")){
|
||||||
|
return Float.parseFloat(lineArrayList.get(lineArrayList.size() - 1));
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Double")){
|
||||||
|
return Double.parseDouble(lineArrayList.get(lineArrayList.size() - 1));
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Boolean")){
|
||||||
|
return Boolean.parseBoolean(lineArrayList.get(lineArrayList.size() - 1));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
print(easyBase.getName() + ": " + "Filetype not Found!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).startsWith("ArrayList") && lineArrayList.get(2).equals(name)){
|
||||||
|
int startIntex = lineArrayList.indexOf("{");
|
||||||
|
int endIntex = lineArrayList.indexOf("}");
|
||||||
|
ArrayList<Integer> arrayVars = new ArrayList<Integer>();
|
||||||
|
for (String i : lineArrayList) {
|
||||||
|
int currentIndex = lineArrayList.indexOf(i);
|
||||||
|
if(currentIndex < endIntex && currentIndex > startIntex){
|
||||||
|
arrayVars.add(currentIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ArrayList<Object> output = new ArrayList<Object>();
|
||||||
|
for (Integer i : arrayVars) {
|
||||||
|
if(lineArrayList.get(1).contains("<String>")){
|
||||||
|
output.add(lineArrayList.get(i));
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(1).contains("<Byte>")){
|
||||||
|
output.add(Byte.parseByte(lineArrayList.get(i)));
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(1).contains("<Short>")){
|
||||||
|
output.add(Short.parseShort(lineArrayList.get(i)));
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(1).contains("<Integer>")){
|
||||||
|
output.add(Integer.parseInt(lineArrayList.get(i)));
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(1).contains("<Long>")){
|
||||||
|
output.add(Long.parseLong(lineArrayList.get(i)));
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(1).contains("<Float>")){
|
||||||
|
output.add(Float.parseFloat(lineArrayList.get(i)));
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(1).contains("<Double>")){
|
||||||
|
output.add(Double.parseDouble(lineArrayList.get(i)));
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(1).contains("<Boolean>")){
|
||||||
|
output.add(Boolean.parseBoolean(lineArrayList.get(i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void editData(String name, Object data){
|
||||||
|
for (String line : lines) {
|
||||||
|
String[] lineStrings = line.split(" ");
|
||||||
|
ArrayList<String> lineArrayList = new ArrayList<String>();
|
||||||
|
for(String s : lineStrings){
|
||||||
|
lineArrayList.add(s);
|
||||||
|
}
|
||||||
|
if(lineArrayList.size() > 1){
|
||||||
|
if(lineArrayList.get(1).equals(name)){
|
||||||
|
if(lineArrayList.get(0).equals("String")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
createData(name, data);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Byte")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
createData(name, data);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Short")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
createData(name, data);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Integer")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
createData(name, data);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Long")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
createData(name, data);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Float")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
createData(name, data);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Double")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
createData(name, data);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Boolean")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
createData(name, data);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
print(easyBase.getName() + ": " + "Filetype not Found!");
|
||||||
|
}
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).startsWith("ArrayList") && lineArrayList.get(2).equals(name)){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
createData(name, data);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteData(String name){
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
for (String line : lines) {
|
||||||
|
String[] lineStrings = line.split(" ");
|
||||||
|
ArrayList<String> lineArrayList = new ArrayList<String>();
|
||||||
|
for(String s : lineStrings){
|
||||||
|
lineArrayList.add(s);
|
||||||
|
}
|
||||||
|
if(lineArrayList.size() > 1){
|
||||||
|
if(lineArrayList.get(1).equals(name)){
|
||||||
|
if(lineArrayList.get(0).equals("String")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Byte")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Short")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Integer")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Long")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Float")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Double")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).equals("Boolean")){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
print(easyBase.getName() + ": " + "Filetype not Found!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(lineArrayList.get(0).startsWith("ArrayList") && lineArrayList.get(2).equals(name)){
|
||||||
|
lines.remove(line);
|
||||||
|
rewriteFile();
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void arrayAdd(String name, Object data){
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
if(data instanceof String){
|
||||||
|
ArrayList<String> tempList = new ArrayList<String>();
|
||||||
|
tempList = (ArrayList<String>) getData(name);
|
||||||
|
tempList.add((String) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Byte){
|
||||||
|
ArrayList<Byte> tempList = new ArrayList<Byte>();
|
||||||
|
tempList = (ArrayList<Byte>) getData(name);
|
||||||
|
tempList.add((Byte) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Short){
|
||||||
|
ArrayList<Short> tempList = new ArrayList<Short>();
|
||||||
|
tempList = (ArrayList<Short>) getData(name);
|
||||||
|
tempList.add((Short) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Integer){
|
||||||
|
ArrayList<Integer> tempList = new ArrayList<Integer>();
|
||||||
|
tempList = (ArrayList<Integer>) getData(name);
|
||||||
|
tempList.add((Integer) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Long){
|
||||||
|
ArrayList<Long> tempList = new ArrayList<Long>();
|
||||||
|
tempList = (ArrayList<Long>) getData(name);
|
||||||
|
tempList.add((Long) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Float){
|
||||||
|
ArrayList<Float> tempList = new ArrayList<Float>();
|
||||||
|
tempList = (ArrayList<Float>) getData(name);
|
||||||
|
tempList.add((Float) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Double){
|
||||||
|
ArrayList<Double> tempList = new ArrayList<Double>();
|
||||||
|
tempList = (ArrayList<Double>) getData(name);
|
||||||
|
tempList.add((Double) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Boolean){
|
||||||
|
ArrayList<Boolean> tempList = new ArrayList<Boolean>();
|
||||||
|
tempList = (ArrayList<Boolean>) getData(name);
|
||||||
|
tempList.add((Boolean) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void arrayRemove(String name, Object data){
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
if(data instanceof String){
|
||||||
|
ArrayList<String> tempList = new ArrayList<String>();
|
||||||
|
tempList = (ArrayList<String>) getData(name);
|
||||||
|
tempList.remove((String) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Byte){
|
||||||
|
ArrayList<Byte> tempList = new ArrayList<Byte>();
|
||||||
|
tempList = (ArrayList<Byte>) getData(name);
|
||||||
|
tempList.remove((Byte) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Short){
|
||||||
|
ArrayList<Short> tempList = new ArrayList<Short>();
|
||||||
|
tempList = (ArrayList<Short>) getData(name);
|
||||||
|
tempList.remove((Short) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Integer){
|
||||||
|
ArrayList<Integer> tempList = new ArrayList<Integer>();
|
||||||
|
tempList = (ArrayList<Integer>) getData(name);
|
||||||
|
tempList.remove((Integer) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Long){
|
||||||
|
ArrayList<Long> tempList = new ArrayList<Long>();
|
||||||
|
tempList = (ArrayList<Long>) getData(name);
|
||||||
|
tempList.remove((Long) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Float){
|
||||||
|
ArrayList<Float> tempList = new ArrayList<Float>();
|
||||||
|
tempList = (ArrayList<Float>) getData(name);
|
||||||
|
tempList.remove((Float) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Double){
|
||||||
|
ArrayList<Double> tempList = new ArrayList<Double>();
|
||||||
|
tempList = (ArrayList<Double>) getData(name);
|
||||||
|
tempList.remove((Double) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
else if(data instanceof Boolean){
|
||||||
|
ArrayList<Boolean> tempList = new ArrayList<Boolean>();
|
||||||
|
tempList = (ArrayList<Boolean>) getData(name);
|
||||||
|
tempList.remove((Boolean) data);
|
||||||
|
editData(name, tempList);
|
||||||
|
rewriteFile();
|
||||||
|
}
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int arrayIndexOf(String name, Object data){
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
if(data instanceof String){
|
||||||
|
ArrayList<String> tempList = new ArrayList<String>();
|
||||||
|
tempList = (ArrayList<String>) getData(name);
|
||||||
|
return tempList.indexOf((String) data);
|
||||||
|
}
|
||||||
|
else if(data instanceof Byte){
|
||||||
|
ArrayList<Byte> tempList = new ArrayList<Byte>();
|
||||||
|
tempList = (ArrayList<Byte>) getData(name);
|
||||||
|
tempList.remove((Byte) data);
|
||||||
|
return tempList.indexOf((Byte) data);
|
||||||
|
}
|
||||||
|
else if(data instanceof Short){
|
||||||
|
ArrayList<Short> tempList = new ArrayList<Short>();
|
||||||
|
tempList = (ArrayList<Short>) getData(name);
|
||||||
|
tempList.remove((Short) data);
|
||||||
|
return tempList.indexOf((Short) data);
|
||||||
|
}
|
||||||
|
else if(data instanceof Integer){
|
||||||
|
ArrayList<Integer> tempList = new ArrayList<Integer>();
|
||||||
|
tempList = (ArrayList<Integer>) getData(name);
|
||||||
|
tempList.remove((Integer) data);
|
||||||
|
return tempList.indexOf((Integer) data);
|
||||||
|
}
|
||||||
|
else if(data instanceof Long){
|
||||||
|
ArrayList<Long> tempList = new ArrayList<Long>();
|
||||||
|
tempList = (ArrayList<Long>) getData(name);
|
||||||
|
tempList.remove((Long) data);
|
||||||
|
return tempList.indexOf((Long) data);
|
||||||
|
}
|
||||||
|
else if(data instanceof Float){
|
||||||
|
ArrayList<Float> tempList = new ArrayList<Float>();
|
||||||
|
tempList = (ArrayList<Float>) getData(name);
|
||||||
|
tempList.remove((Float) data);
|
||||||
|
return tempList.indexOf((Float) data);
|
||||||
|
}
|
||||||
|
else if(data instanceof Double){
|
||||||
|
ArrayList<Double> tempList = new ArrayList<Double>();
|
||||||
|
tempList = (ArrayList<Double>) getData(name);
|
||||||
|
tempList.remove((Double) data);
|
||||||
|
return tempList.indexOf((Double) data);
|
||||||
|
}
|
||||||
|
else if(data instanceof Boolean){
|
||||||
|
ArrayList<Boolean> tempList = new ArrayList<Boolean>();
|
||||||
|
tempList = (ArrayList<Boolean>) getData(name);
|
||||||
|
tempList.remove((Boolean) data);
|
||||||
|
return tempList.indexOf((Boolean) data);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
print("Object was not found in Array");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int arraySize(String name){
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
try{
|
||||||
|
ArrayList<Object> tempList = new ArrayList<Object>();
|
||||||
|
tempList = (ArrayList<Object>) getData(name);
|
||||||
|
return tempList.size();
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
print("Index not found in Array");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object arrayGet(String name, int i){
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
try{
|
||||||
|
ArrayList<Object> tempList = new ArrayList<Object>();
|
||||||
|
tempList = (ArrayList<Object>) getData(name);
|
||||||
|
return tempList.get(i);
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
print("Index not found in Array");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Object> getAll(){
|
||||||
|
UpdateBaseFile(false);
|
||||||
|
ArrayList<String> names = new ArrayList<String>();
|
||||||
|
for (String str: lines) {
|
||||||
|
if(!(str.endsWith(".esb")) && !str.equals("{") && !str.equals("}")){
|
||||||
|
if(str.startsWith("ArrayList")){
|
||||||
|
String[] strings = str.split(" ");
|
||||||
|
names.add(strings[2]);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
String[] strings = str.split(" ");
|
||||||
|
names.add(strings[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ArrayList<Object> returnList = new ArrayList<Object>();
|
||||||
|
for (String str : names) {
|
||||||
|
returnList.add(getData(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void print(String message){
|
||||||
|
Integer tempInt = easyBase.getName().indexOf(".");
|
||||||
|
System.out.println(easyBase.getName().substring(0, tempInt) + ": " + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
src/main/java/de/sailehd/support/FileClient.java
Normal file
21
src/main/java/de/sailehd/support/FileClient.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package de.sailehd.support;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class FileClient {
|
||||||
|
public ArrayList<String> ls(String path){
|
||||||
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
|
File folder = new File(path);
|
||||||
|
File[] listOfFiles = folder.listFiles();
|
||||||
|
|
||||||
|
for (File file : listOfFiles) {
|
||||||
|
if (file.isFile()) {
|
||||||
|
list.add(file.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
109
src/main/java/de/sailehd/support/FileManager.java
Normal file
109
src/main/java/de/sailehd/support/FileManager.java
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
package de.sailehd.support;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class FileManager {
|
||||||
|
|
||||||
|
public static boolean moveFileToDirectory(File sourceFile, String targetPath) {
|
||||||
|
File tDir = new File(targetPath);
|
||||||
|
if (tDir.exists()) {
|
||||||
|
String newFilePath = targetPath+File.separator+sourceFile.getName();
|
||||||
|
File movedFile = new File(newFilePath);
|
||||||
|
if (movedFile.exists())
|
||||||
|
movedFile.delete();
|
||||||
|
return sourceFile.renameTo(new File(newFilePath));
|
||||||
|
} else {
|
||||||
|
Debug.log("unable to move file "+sourceFile.getName()+" to directory "+targetPath+" -> target directory does not exist");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ArrayList<File> GetFiles(File directory, String[] types){
|
||||||
|
ArrayList<File> tempFiles = new ArrayList<File>();
|
||||||
|
|
||||||
|
for(String type : types){
|
||||||
|
for (int i = 0; i < directory.listFiles().length; i++) {
|
||||||
|
if (directory.listFiles()[i].isDirectory()) {
|
||||||
|
for (File file: GetFiles(directory.listFiles()[i], types)) {
|
||||||
|
if(file.getName().endsWith("." + type)){
|
||||||
|
tempFiles.add(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(directory.listFiles()[i].isFile()){
|
||||||
|
if(directory.listFiles()[i].getName().endsWith("." + type)){
|
||||||
|
tempFiles.add(directory.listFiles()[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tempFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void copyFileUsingStream(File source, File dest) throws IOException {
|
||||||
|
InputStream is = null;
|
||||||
|
OutputStream os = null;
|
||||||
|
try {
|
||||||
|
is = new FileInputStream(source);
|
||||||
|
os = new FileOutputStream(dest);
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int length;
|
||||||
|
while ((length = is.read(buffer)) > 0) {
|
||||||
|
os.write(buffer, 0, length);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
is.close();
|
||||||
|
os.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void combineAudioFiles(String audioFilesFolder, String outputFile, String[] fileformats) throws IOException {
|
||||||
|
File folder = new File(audioFilesFolder);
|
||||||
|
ArrayList<File> files = new ArrayList<File>(GetFiles(folder,fileformats));
|
||||||
|
Debug.log(TextColor.YELLOW + "File Merge Start" + TextColor.RESET);
|
||||||
|
|
||||||
|
FileInputStream tempstream = null;
|
||||||
|
SequenceInputStream sistream = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileWriter myWriter = new FileWriter("tracks.txt");
|
||||||
|
for (File file : files) {
|
||||||
|
String tempfile = file.getAbsolutePath();
|
||||||
|
tempstream = new FileInputStream(tempfile);
|
||||||
|
sistream = new SequenceInputStream(tempstream, sistream);
|
||||||
|
Debug.log(TextColor.BLACK_BOLD + "File = " + TextColor.RESET + TextColor.BLUE_BOLD_BRIGHT + file.getName() + TextColor.RESET);
|
||||||
|
myWriter.write(file.getName() + "\n");
|
||||||
|
}
|
||||||
|
myWriter.close();
|
||||||
|
System.out.println("Successfully wrote to the trackFile.");
|
||||||
|
}
|
||||||
|
catch(Exception e){
|
||||||
|
System.out.println("An error occurred.");
|
||||||
|
e.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
FileOutputStream fostream = new FileOutputStream(outputFile);//destinationfile
|
||||||
|
//Debug.log("Stream done");
|
||||||
|
try {
|
||||||
|
Debug.log(TextColor.YELLOW + "Writing" + TextColor.RESET);
|
||||||
|
int temp;
|
||||||
|
while( ( temp = sistream.read() ) != -1)
|
||||||
|
{
|
||||||
|
fostream.write(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Debug.log("Closing Streams");
|
||||||
|
fostream.close();
|
||||||
|
sistream.close();
|
||||||
|
tempstream.close();
|
||||||
|
// Debug.log("Streams Closed");
|
||||||
|
Debug.log(TextColor.GREEN + "Done" + TextColor.RESET);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/main/java/de/sailehd/support/Key.java
Normal file
29
src/main/java/de/sailehd/support/Key.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package de.sailehd.support;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.KeyAdapter;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
|
public class Key extends KeyAdapter{
|
||||||
|
public static void type(String str) throws AWTException {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
for(char ch:str.toCharArray()){
|
||||||
|
if(Character.isUpperCase(ch)){
|
||||||
|
robot.keyPress(KeyEvent.VK_SHIFT);
|
||||||
|
robot.keyPress((int)ch);
|
||||||
|
robot.keyRelease((int)ch);
|
||||||
|
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||||
|
}else{
|
||||||
|
char upCh = Character.toUpperCase(ch);
|
||||||
|
robot.keyPress((int)upCh);
|
||||||
|
robot.keyRelease((int)upCh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void press(int code){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
119
src/main/java/de/sailehd/support/ProcessBar.java
Normal file
119
src/main/java/de/sailehd/support/ProcessBar.java
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
package de.sailehd.support;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.Range;
|
||||||
|
import org.apache.commons.lang3.time.StopWatch;
|
||||||
|
|
||||||
|
public class ProcessBar {
|
||||||
|
|
||||||
|
private int length;
|
||||||
|
private int steps;
|
||||||
|
private int localIndex = 0;
|
||||||
|
private boolean stopper = false;
|
||||||
|
StopWatch watch = new StopWatch();
|
||||||
|
|
||||||
|
public ProcessBar(int length){
|
||||||
|
watch.start();
|
||||||
|
this.length = length;
|
||||||
|
if(length < 100){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.steps = length / 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void update(Integer index, String extraInfo){
|
||||||
|
if(index == length){
|
||||||
|
watch.stop();
|
||||||
|
}
|
||||||
|
build(index, extraInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void build(Integer index, String extraInfo){
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
|
||||||
|
for (int i = 1; i <= 100 ; i++) {
|
||||||
|
result.append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(index % steps == 0){
|
||||||
|
localIndex++;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < index; i++) {
|
||||||
|
if(i % steps == 0 && i != 0){
|
||||||
|
result.replace(localIndex - 1,localIndex, "■");
|
||||||
|
for (int j = 0; j < localIndex - 1; j++) {
|
||||||
|
result.replace(j, j + 1, "■");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.insert(0, "0%");
|
||||||
|
result.append("100%");
|
||||||
|
|
||||||
|
|
||||||
|
if((watch.getTime() / 1000) < 60){
|
||||||
|
result.append("\nPercent-Done:" + localIndex + "%" + " | Time:" + watch.getTime() / 1000 + "sec");
|
||||||
|
if(watch.getTime() > 1000 && localIndex != 0){
|
||||||
|
Integer timeRemaining = Math.toIntExact(((watch.getTime() / 1000) / localIndex) * 100);
|
||||||
|
|
||||||
|
if(timeRemaining < 60){
|
||||||
|
result.append(" | Time-Remaining:" + timeRemaining + "sec");
|
||||||
|
}
|
||||||
|
else if(timeRemaining > 60 && timeRemaining < 3600){
|
||||||
|
result.append(" | Time-Remaining:" + timeRemaining / 60 + "min" + timeRemaining % 60 + "sec");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
result.append(" | Time-Remaining:" + (timeRemaining /60) / 60 + "h " + (timeRemaining /60) % 60 + "min " + (timeRemaining % 60) % 60 + "sec");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if((watch.getTime() / 1000) > 60 && (watch.getTime() / 1000) < 3600){
|
||||||
|
result.append("\nPercent-Done:" + localIndex + "%" + " | Time:" + (watch.getTime() / 1000) / 60 + "min " + (watch.getTime() / 1000) % 60 + "sec");
|
||||||
|
if(watch.getTime() > 1000 && localIndex != 0){
|
||||||
|
Integer timeRemaining = Math.toIntExact(((watch.getTime() / 1000) / localIndex) * 100);
|
||||||
|
|
||||||
|
if(timeRemaining < 60){
|
||||||
|
result.append(" | Time-Remaining:" + timeRemaining + "sec");
|
||||||
|
}
|
||||||
|
else if(timeRemaining > 60 && timeRemaining < 3600){
|
||||||
|
result.append(" | Time-Remaining:" + timeRemaining / 60 + "min" + timeRemaining % 60 + "sec");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
result.append(" | Time-Remaining:" + (timeRemaining /60) / 60 + "h " + (timeRemaining /60) % 60 + "min " + (timeRemaining % 60) % 60 + "sec");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
int time = Math.toIntExact(watch.getTime() / 1000);
|
||||||
|
|
||||||
|
result.append("\nPercent-Done:" + localIndex + "%" + " | Time:" + (time /60) / 60 + "h " + (time /60) % 60 + "min " + (time % 60) % 60 + "sec");
|
||||||
|
|
||||||
|
if(watch.getTime() > 1000 && localIndex != 0){
|
||||||
|
Integer timeRemaining = Math.toIntExact(((watch.getTime() / 1000) / localIndex) * 100);
|
||||||
|
|
||||||
|
if(timeRemaining < 60){
|
||||||
|
result.append(" | Time-Remaining" + timeRemaining + "sec");
|
||||||
|
}
|
||||||
|
else if(timeRemaining > 60 && timeRemaining < 3600){
|
||||||
|
result.append(" | Time-Remaining" + timeRemaining / 60 + "min" + timeRemaining % 60 + "sec");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
result.append(" | Time-Remaining" + (timeRemaining /60) / 60 + "h " + (timeRemaining /60) % 60 + "min " + (timeRemaining % 60) % 60 + "sec");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
result.append(" | Index:" + index);
|
||||||
|
if(extraInfo != null){
|
||||||
|
result.append(" | " + extraInfo);
|
||||||
|
}
|
||||||
|
Debug.clear();
|
||||||
|
Debug.log(result.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
33
src/main/java/de/sailehd/support/Random.java
Normal file
33
src/main/java/de/sailehd/support/Random.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package de.sailehd.support;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
|
|
||||||
|
public class Random {
|
||||||
|
public static int Range(int min, int max){
|
||||||
|
return (int) ((Math.random() * (max - min)) + min);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float Range(float min, float max){
|
||||||
|
return (float) ((Math.random() * (max - min)) + min);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double Range(double min, double max){
|
||||||
|
return (double) ((Math.random() * (max - min)) + min);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long Range(long min, long max){
|
||||||
|
return (long) ((Math.random() * (max - min)) + min);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static short Range(short min, short max){
|
||||||
|
return (short) ((Math.random() * (max - min)) + min);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String String(int length, boolean useLetters, boolean useNumbers) {
|
||||||
|
String generatedString = RandomStringUtils.random(length, useLetters, useNumbers);
|
||||||
|
|
||||||
|
return generatedString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
149
src/main/java/de/sailehd/support/SFTPClient.java
Normal file
149
src/main/java/de/sailehd/support/SFTPClient.java
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
package de.sailehd.support;
|
||||||
|
|
||||||
|
import com.jcraft.jsch.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
public class SFTPClient {
|
||||||
|
|
||||||
|
private Session session = null;
|
||||||
|
|
||||||
|
private String username = "";
|
||||||
|
private String password = "";
|
||||||
|
private String host = "";
|
||||||
|
private String knownHostsPath = "";
|
||||||
|
|
||||||
|
private Integer port = 22;
|
||||||
|
|
||||||
|
public SFTPClient(String knownHostsPath, String host, String username, String password, Integer port){
|
||||||
|
this.knownHostsPath = knownHostsPath;
|
||||||
|
this.host = host;
|
||||||
|
this.port = port;
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void connect() throws JSchException {
|
||||||
|
JSch jsch = new JSch();
|
||||||
|
|
||||||
|
// Uncomment the line below if the FTP server requires certificate
|
||||||
|
jsch.setKnownHosts(knownHostsPath);
|
||||||
|
// Uncomment the two lines below if the FTP server requires password
|
||||||
|
session = jsch.getSession(username, host, port);
|
||||||
|
session.setPassword(password);
|
||||||
|
session.setConfig("StrictHostKeyChecking", "no");
|
||||||
|
session.connect();
|
||||||
|
Debug.log("Connected to Server");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void upload(String source, String destination) throws JSchException, SftpException {
|
||||||
|
Channel channel = session.openChannel("sftp");
|
||||||
|
channel.connect();
|
||||||
|
ChannelSftp sftpChannel = (ChannelSftp) channel;
|
||||||
|
sftpChannel.put(source, destination);
|
||||||
|
sftpChannel.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void download(String source, String destination) throws JSchException, SftpException {
|
||||||
|
Channel channel = session.openChannel("sftp");
|
||||||
|
channel.connect();
|
||||||
|
ChannelSftp sftpChannel = (ChannelSftp) channel;
|
||||||
|
sftpChannel.get(source, destination);
|
||||||
|
sftpChannel.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rename(String oldPath, String newPath) throws JSchException, SftpException {
|
||||||
|
Channel channel = session.openChannel("sftp");
|
||||||
|
channel.connect();
|
||||||
|
ChannelSftp sftpChannel = (ChannelSftp) channel;
|
||||||
|
sftpChannel.rename(oldPath, newPath);
|
||||||
|
sftpChannel.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(String path) throws JSchException, SftpException {
|
||||||
|
Channel channel = session.openChannel("sftp");
|
||||||
|
channel.connect();
|
||||||
|
ChannelSftp sftpChannel = (ChannelSftp) channel;
|
||||||
|
sftpChannel.rm(path);
|
||||||
|
sftpChannel.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mkdir(String path) throws JSchException, SftpException {
|
||||||
|
Channel channel = session.openChannel("sftp");
|
||||||
|
channel.connect();
|
||||||
|
ChannelSftp sftpChannel = (ChannelSftp) channel;
|
||||||
|
sftpChannel.mkdir(path);
|
||||||
|
sftpChannel.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void chmod(Integer permission ,String path) throws JSchException, SftpException {
|
||||||
|
Channel channel = session.openChannel("sftp");
|
||||||
|
channel.connect();
|
||||||
|
ChannelSftp sftpChannel = (ChannelSftp) channel;
|
||||||
|
sftpChannel.chmod(permission, path);
|
||||||
|
sftpChannel.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> ls(String path) throws JSchException, SftpException {
|
||||||
|
Channel channel = session.openChannel("sftp");
|
||||||
|
channel.connect();
|
||||||
|
ChannelSftp sftpChannel = (ChannelSftp) channel;
|
||||||
|
Vector filelist = sftpChannel.ls(path);
|
||||||
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
|
for (int i = 0; i < filelist.size(); i++) {
|
||||||
|
list.add(filelist.get(i).toString());
|
||||||
|
}
|
||||||
|
ArrayList<String> list2 = new ArrayList<String>();
|
||||||
|
for (String files : list) {
|
||||||
|
String[] filesParts = files.split(" ");
|
||||||
|
for (String i: filesParts) {
|
||||||
|
if(i == filesParts[filesParts.length - 1] && !(i.contains("..")) && !(i.equals("."))){
|
||||||
|
list2.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sftpChannel.exit();
|
||||||
|
return list2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> lsWithPath(String path) throws JSchException, SftpException {
|
||||||
|
Channel channel = session.openChannel("sftp");
|
||||||
|
channel.connect();
|
||||||
|
ChannelSftp sftpChannel = (ChannelSftp) channel;
|
||||||
|
Vector filelist = sftpChannel.ls(path);
|
||||||
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
|
for (int i = 0; i < filelist.size(); i++) {
|
||||||
|
list.add(filelist.get(i).toString());
|
||||||
|
}
|
||||||
|
ArrayList<String> list2 = new ArrayList<String>();
|
||||||
|
for (String files : list) {
|
||||||
|
String[] filesParts = files.split(" ");
|
||||||
|
for (String i: filesParts) {
|
||||||
|
if(i == filesParts[filesParts.length - 1] && !(i.contains("..")) && !(i.equals("."))){
|
||||||
|
list2.add(path + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sftpChannel.exit();
|
||||||
|
return list2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copy(Integer permission ,String path) throws JSchException, SftpException {
|
||||||
|
Channel channel = session.openChannel("sftp");
|
||||||
|
channel.connect();
|
||||||
|
ChannelSftp sftpChannel = (ChannelSftp) channel;
|
||||||
|
sftpChannel.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void disconnect() {
|
||||||
|
if (session != null) {
|
||||||
|
session.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
44
src/main/java/de/sailehd/support/SManager.java
Normal file
44
src/main/java/de/sailehd/support/SManager.java
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package de.sailehd.support;
|
||||||
|
|
||||||
|
public class SManager {
|
||||||
|
public static double similarity(String source, String target){
|
||||||
|
String longer = source, shorter = target;
|
||||||
|
if (source.length() < target.length()) {
|
||||||
|
longer = target; shorter = source;
|
||||||
|
}
|
||||||
|
int longerLength = longer.length();
|
||||||
|
if (longerLength == 0) { return 1.0;}
|
||||||
|
|
||||||
|
return (longerLength - editDistance(longer, shorter)) / (double) longerLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int editDistance(String source, String target) {
|
||||||
|
source = source.toLowerCase();
|
||||||
|
target = target.toLowerCase();
|
||||||
|
|
||||||
|
int[] costs = new int[target.length() + 1];
|
||||||
|
for (int i = 0; i <= source.length(); i++) {
|
||||||
|
int lastValue = i;
|
||||||
|
for (int j = 0; j <= target.length(); j++) {
|
||||||
|
if (i == 0)
|
||||||
|
costs[j] = j;
|
||||||
|
else {
|
||||||
|
if (j > 0) {
|
||||||
|
int newValue = costs[j - 1];
|
||||||
|
if (source.charAt(i - 1) != target.charAt(j - 1))
|
||||||
|
newValue = Math.min(Math.min(newValue, lastValue),
|
||||||
|
costs[j]) + 1;
|
||||||
|
costs[j - 1] = lastValue;
|
||||||
|
lastValue = newValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i > 0)
|
||||||
|
costs[target.length()] = lastValue;
|
||||||
|
}
|
||||||
|
return costs[target.length()];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
76
src/main/java/de/sailehd/support/TextColor.java
Normal file
76
src/main/java/de/sailehd/support/TextColor.java
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package de.sailehd.support;
|
||||||
|
|
||||||
|
public class TextColor {
|
||||||
|
// Reset
|
||||||
|
public static final String RESET = "\u001B[0m";
|
||||||
|
|
||||||
|
// Regular Colors
|
||||||
|
public static final String ABLACK = "\u001B[30m";
|
||||||
|
public static final String RED = "\u001B[31m";
|
||||||
|
public static final String GREEN = "\u001B[32m";
|
||||||
|
public static final String YELLOW = "\u001B[33m";
|
||||||
|
public static final String BLUE = "\u001B[34m";
|
||||||
|
public static final String PURPLE = "\u001B[35m";
|
||||||
|
public static final String CYAN = "\u001B[36m";
|
||||||
|
public static final String WHITE = "\u001B[37m";
|
||||||
|
|
||||||
|
// Bold
|
||||||
|
public static final String BLACK_BOLD = "\033[1;30m"; // BLACK
|
||||||
|
public static final String RED_BOLD = "\033[1;31m"; // RED
|
||||||
|
public static final String GREEN_BOLD = "\033[1;32m"; // GREEN
|
||||||
|
public static final String YELLOW_BOLD = "\033[1;33m"; // YELLOW
|
||||||
|
public static final String BLUE_BOLD = "\033[1;34m"; // BLUE
|
||||||
|
public static final String PURPLE_BOLD = "\033[1;35m"; // PURPLE
|
||||||
|
public static final String CYAN_BOLD = "\033[1;36m"; // CYAN
|
||||||
|
public static final String WHITE_BOLD = "\033[1;37m"; // WHITE
|
||||||
|
|
||||||
|
// Underline
|
||||||
|
public static final String BLACK_UNDERLINED = "\033[4;30m"; // BLACK
|
||||||
|
public static final String RED_UNDERLINED = "\033[4;31m"; // RED
|
||||||
|
public static final String GREEN_UNDERLINED = "\033[4;32m"; // GREEN
|
||||||
|
public static final String YELLOW_UNDERLINED = "\033[4;33m"; // YELLOW
|
||||||
|
public static final String BLUE_UNDERLINED = "\033[4;34m"; // BLUE
|
||||||
|
public static final String PURPLE_UNDERLINED = "\033[4;35m"; // PURPLE
|
||||||
|
public static final String CYAN_UNDERLINED = "\033[4;36m"; // CYAN
|
||||||
|
public static final String WHITE_UNDERLINED = "\033[4;37m"; // WHITE
|
||||||
|
|
||||||
|
// Background
|
||||||
|
public static final String BLACK_BACKGROUND = "\033[40m"; // BLACK
|
||||||
|
public static final String RED_BACKGROUND = "\033[41m"; // RED
|
||||||
|
public static final String GREEN_BACKGROUND = "\033[42m"; // GREEN
|
||||||
|
public static final String YELLOW_BACKGROUND = "\033[43m"; // YELLOW
|
||||||
|
public static final String BLUE_BACKGROUND = "\033[44m"; // BLUE
|
||||||
|
public static final String PURPLE_BACKGROUND = "\033[45m"; // PURPLE
|
||||||
|
public static final String CYAN_BACKGROUND = "\033[46m"; // CYAN
|
||||||
|
public static final String WHITE_BACKGROUND = "\033[47m"; // WHITE
|
||||||
|
|
||||||
|
// High Intensity
|
||||||
|
public static final String BLACK_BRIGHT = "\033[0;90m"; // BLACK
|
||||||
|
public static final String RED_BRIGHT = "\033[0;91m"; // RED
|
||||||
|
public static final String GREEN_BRIGHT = "\033[0;92m"; // GREEN
|
||||||
|
public static final String YELLOW_BRIGHT = "\033[0;93m"; // YELLOW
|
||||||
|
public static final String BLUE_BRIGHT = "\033[0;94m"; // BLUE
|
||||||
|
public static final String PURPLE_BRIGHT = "\033[0;95m"; // PURPLE
|
||||||
|
public static final String CYAN_BRIGHT = "\033[0;96m"; // CYAN
|
||||||
|
public static final String WHITE_BRIGHT = "\033[0;97m"; // WHITE
|
||||||
|
|
||||||
|
// Bold High Intensity
|
||||||
|
public static final String BLACK_BOLD_BRIGHT = "\033[1;90m"; // BLACK
|
||||||
|
public static final String RED_BOLD_BRIGHT = "\033[1;91m"; // RED
|
||||||
|
public static final String GREEN_BOLD_BRIGHT = "\033[1;92m"; // GREEN
|
||||||
|
public static final String YELLOW_BOLD_BRIGHT = "\033[1;93m";// YELLOW
|
||||||
|
public static final String BLUE_BOLD_BRIGHT = "\033[1;94m"; // BLUE
|
||||||
|
public static final String PURPLE_BOLD_BRIGHT = "\033[1;95m";// PURPLE
|
||||||
|
public static final String CYAN_BOLD_BRIGHT = "\033[1;96m"; // CYAN
|
||||||
|
public static final String WHITE_BOLD_BRIGHT = "\033[1;97m"; // WHITE
|
||||||
|
|
||||||
|
// High Intensity backgrounds
|
||||||
|
public static final String BLACK_BACKGROUND_BRIGHT = "\033[0;100m";// BLACK
|
||||||
|
public static final String RED_BACKGROUND_BRIGHT = "\033[0;101m";// RED
|
||||||
|
public static final String GREEN_BACKGROUND_BRIGHT = "\033[0;102m";// GREEN
|
||||||
|
public static final String YELLOW_BACKGROUND_BRIGHT = "\033[0;103m";// YELLOW
|
||||||
|
public static final String BLUE_BACKGROUND_BRIGHT = "\033[0;104m";// BLUE
|
||||||
|
public static final String PURPLE_BACKGROUND_BRIGHT = "\033[0;105m"; // PURPLE
|
||||||
|
public static final String CYAN_BACKGROUND_BRIGHT = "\033[0;106m"; // CYAN
|
||||||
|
public static final String WHITE_BACKGROUND_BRIGHT = "\033[0;107m"; // WHITE
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user