Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .appveyor.yml

This file was deleted.

58 changes: 58 additions & 0 deletions .github/workflows/maven.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest
- windows-latest
arch:
- x64

steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Setup code coverage
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
fi
- name: Build and Test
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
mvn clean test jacoco:report -P backend-CPU -B
else
mvn clean test -P backend-CPU -B
fi

- name: Upload coverage
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
JACOCO_SOURCE_PATH=src/main/java ./cc-test-reporter format-coverage target/site/jacoco/jacoco.xml --input-type jacoco
./cc-test-reporter upload-coverage
fi
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@

Travis [![Build Status](https://travis-ci.org/DrChainsaw/AmpControl.svg?branch=master)](https://travis-ci.org/DrChainsaw/AmpControl)
AppVeyor [![Build status](https://ci.appveyor.com/api/projects/status/b9e4h8g0em7r7c1v/branch/master?svg=true)](https://ci.appveyor.com/project/DrChainsaw/ampcontrol-fsko3)
![Build Status](https://github.com/DrChainsaw/AmpControl/actions/workflows/maven.yml/badge.svg)


[![codebeat badge](https://codebeat.co/badges/998446a1-99e0-4f8f-9b62-d8dda4ef780d)](https://codebeat.co/projects/github-com-drchainsaw-ampcontrol-master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/1b55604515c3475cb7d4826fd67f7817)](https://www.codacy.com/app/DrChainsaw/AmpControl?utm_source=github.com&utm_medium=referral&utm_content=DrChainsaw/AmpControl&utm_campaign=Badge_Grade)
[![Maintainability](https://api.codeclimate.com/v1/badges/94297293618a7a420e6d/maintainability)](https://codeclimate.com/github/DrChainsaw/AmpControl/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/94297293618a7a420e6d/test_coverage)](https://codeclimate.com/github/DrChainsaw/AmpControl/test_coverage)


# AmpControl

Do you have an amplifier hidden from plain sight with a dedicated wireless system for casual guitar practice in your living room? Are you sometimes annoyed that when playing along to recordings you can't find a sound which is a good balance for both rhythm and leads, but you also don't want to have a foot switch in your living room? Do you happen to have a moderately powerful computer standing close enough to the amplifier?
Expand Down Expand Up @@ -56,12 +54,14 @@ I don't really expect anyone but me to use this project and as of now it does no

### Prerequisites

Maven, Git, Data set or models. Current configuration uses the CUDA 9.2 backend for the models and this requires CUDA 9.2 along with an NVIDIA GPU which supports CUDA 8.0. See https://deeplearning4j.org/gpu
Maven, Git, Data set or models. Current configuration uses the CUDA 11.4 backend for the models which requires a NVIDIA GPU which supports CUDA. See https://deeplearning4j.org/gpu

### Installing

Clone the repo and fire it up in your IDE of choice. I had some issues getting CUDA to work in eclipse due to some m2e bug/feature but this resolved when using IntelliJ. After I got it to work with IntelliJ it worked in eclipse for me as well.

Using `mvn compile assembly:single` will produce a jar file under `target` which runs `ampcontrol.admin.AmpControlMain`.

## Running the tests

`mvn clean test`
Expand Down
76 changes: 45 additions & 31 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,39 @@
<modelVersion>4.0.0</modelVersion>
<groupId>AmpControl</groupId>
<artifactId>AmpControl</artifactId>
<version>0.5.2-SNAPSHOT</version>
<version>0.5.3-SNAPSHOT</version>

<name>AmpControl</name>
<description>Controls amplifiers</description>
<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<shadedClassifier>bin</shadedClassifier>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<java.version>1.8</java.version>
<nd4j.version>1.0.0-beta3</nd4j.version>
<dl4j.version>1.0.0-beta3</dl4j.version>
<slf4j.version>1.7.21</slf4j.version>
<datavec.version>1.0.0-beta3</datavec.version>
<arbiter.version>1.0.0-beta3</arbiter.version>
<rl4j.version>1.0.0-beta3</rl4j.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<java.version>1.21</java.version>
<nd4j.version>1.0.0-M2.1</nd4j.version>
<dl4j.version>1.0.0-M2.1</dl4j.version>
<slf4j.version>2.0.9</slf4j.version>
<datavec.version>1.0.0-beta7</datavec.version>
<junit.version>4.13.1</junit.version>
<xchart.version>3.5.2</xchart.version>
<jcommander.version>1.72</jcommander.version>

<!-- For Spark examples: change the _1 to _2 to switch between Spark 1 and Spark 2 -->

<dl4j.spark.version>1.0.0-beta3_spark_1</dl4j.spark.version>
<datavec.spark.version>1.0.0-beta3_spark_1</datavec.spark.version>

<!-- Scala binary version: DL4J's Spark and UI functionality are released with both Scala 2.10 and 2.11 support -->

<scala.binary.version>2.11</scala.binary.version>
<guava.version>19.0</guava.version>
<logback.version>1.1.7</logback.version>
<paho.version>1.2.5</paho.version>
<logback.version>1.4.11</logback.version>
<jfreechart.version>1.0.13</jfreechart.version>
<jcommon.version>1.0.23</jcommon.version>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
<exec-maven-plugin.version>1.4.0</exec-maven-plugin.version>
<maven.minimum.version>3.3.1</maven.minimum.version>
<javafx.version>2.2.3</javafx.version>
<aws.sdk.version>1.11.109</aws.sdk.version>
<jackson.version>2.6.6</jackson.version>
<scala.plugin.version>3.2.2</scala.plugin.version>
<lombok.version>1.18.2</lombok.version>
<lombok.version>1.18.30</lombok.version>
</properties>


Expand All @@ -58,6 +49,13 @@
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -86,7 +84,7 @@
<!-- Automated Code Formatting -->


<plugin>
<!-- <plugin>
<groupId>com.lewisd</groupId>
<artifactId>lint-maven-plugin</artifactId>
<version>0.0.11</version>
Expand All @@ -108,11 +106,11 @@
</goals>
</execution>
</executions>
</plugin>
</plugin>-->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<version>0.8.11</version>
<executions>
<execution>
<id>default-prepare-agent</id>
Expand All @@ -131,7 +129,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<version>3.2.2</version>
</plugin>
</plugins>

Expand Down Expand Up @@ -163,14 +161,16 @@
-->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>ampcontrol.admin.AmpControlMain</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>AmpControl</descriptorRef>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
Expand All @@ -192,17 +192,22 @@
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<nd4j-backend>nd4j-cuda-10.0-platform</nd4j-backend>
<nd4j-backend>nd4j-cuda-11.4-platform</nd4j-backend>
</properties>
</profile>
</profiles>

<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>cuda-platform-redist</artifactId>
<version>11.4-8.2-1.5.6</version>
</dependency>
<!-- <dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-cuda-10.0</artifactId>
<version>${dl4j.version}</version>
</dependency>
</dependency>-->
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-core</artifactId>
Expand All @@ -215,12 +220,11 @@
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-ui_2.11</artifactId>
<artifactId>deeplearning4j-ui</artifactId>
<version>${dl4j.version}</version>
</dependency>
<dependency>
<groupId>org.nd4j</groupId>
<!-- <artifactId>nd4j-cuda-9.1</artifactId> -->
<artifactId>${nd4j-backend}</artifactId>
<version>${nd4j.version}</version>
</dependency>
Expand Down Expand Up @@ -248,7 +252,7 @@
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.1.0</version>
<version>${paho.version}</version>
</dependency>
<dependency>
<groupId>com.github.wendykierp</groupId>
Expand Down Expand Up @@ -288,6 +292,16 @@
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>24.1.0</version>
</dependency>
</dependencies>


Expand Down
9 changes: 3 additions & 6 deletions src/main/java/ampcontrol/admin/AmpControlMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
import ampcontrol.audio.asio.AsioClassifierInputFactory;
import ampcontrol.model.inference.Classifier;
import ampcontrol.model.inference.ClassifierFromParameters;
import ampcontrol.model.training.model.vertex.ChannelMultVertex;
import ampcontrol.model.training.model.vertex.ElementWiseVertexLatest;
import com.beust.jcommander.JCommander;
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
import org.nd4j.linalg.api.buffer.DataBuffer;
import org.nd4j.linalg.api.buffer.DataType;
import org.nd4j.linalg.api.buffer.util.DataTypeUtil;
import org.nd4j.linalg.factory.Nd4j;

Expand Down Expand Up @@ -62,9 +59,9 @@ public static void main(String[] args) {

try {
// Might need to move into concrete Classifiers if something else is used in training
DataTypeUtil.setDTypeForContext(DataBuffer.Type.HALF);
DataTypeUtil.setDTypeForContext(DataType.FLOAT16);
Nd4j.getMemoryManager().setAutoGcWindow(5000);
NeuralNetConfiguration.registerLegacyCustomClassesForJSON(ChannelMultVertex.class, ElementWiseVertexLatest.class);
//NeuralNetConfiguration.registerLegacyCustomClassesForJSON(ChannelMultVertex.class, ElementWiseVertexLatest.class);
final Classifier classifier = classifierFromParameters.getClassifier(inputProviderFactory);
audioClassificationService.initialize(
classificationListenerAgg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class MidiProgChangeFactory implements AmpInterface.Factory {
private Predicate<MidiDevice.Info> device = Devices.audioBox44Vsl;

@Parameter(names = {"-labelToProg", "-ltp"},
description = "Comma separated list of how to map labels programs. First program is mapped to label 0 etc")
description = "Comma separated list of how to map labels to programs. First program is mapped to label 0 etc")
private List<Integer> programChangesList = Arrays.asList(
2, // Silence
2, // Noise
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ampcontrol/amp/probabilities/ArgMax.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public class ArgMax implements Interpreter<Integer> {

@Override
public List<Integer> apply(INDArray probabilities) {
return Collections.singletonList(probabilities.argMax(1).getInt(0));
return Collections.singletonList(probabilities.argMax(probabilities.rank()-1).getInt(0));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ThresholdFilter(int index, double threshold, Interpreter<T> next) {

@Override
public List<T> apply(INDArray indArray) {
if(indArray.argMax(1).getInt(0) == index) {
if(indArray.argMax(indArray.rank()-1).getInt(0) == index) {
if (indArray.getDouble(index) < threshold) {
return new ArrayList<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static void main(String[] args) {
driver.createBuffers(activeChannels);

driver.start();

System.out.println("Driver started, sleep now");
Thread.sleep(2000);


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package ampcontrol.audio.processing;

import org.jetbrains.annotations.Nullable;

/**
* Creates a {@link ProcessingResult.Factory} based on a name string. Used for persistence since
* all preprocessing needs be recreated when restoring a saved model.
Expand Down Expand Up @@ -99,7 +97,6 @@ public ProcessingResult.Factory get(String nameStr) {
return new UnitMaxZeroMean();
}

@Nullable
private ProcessingResult.Factory getPipedSupplier(
String nameStr,
ProcessingResult.Factory first,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ampcontrol.model.inference;

import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.api.ops.impl.transforms.OldSoftMax;
import org.nd4j.linalg.api.ops.impl.transforms.custom.SoftMax;
import org.nd4j.linalg.factory.Nd4j;

import java.util.ArrayList;
Expand All @@ -19,7 +19,7 @@ class EnsembleWeightedSumClassifier implements Classifier {


final static BiFunction<Double, INDArray, INDArray> avgNormalizer = (sumAcc, aggClass) -> aggClass.div(sumAcc);
final static BiFunction<Double, INDArray, INDArray> softMaxNormalizer = (sumAcc, aggClass) -> Nd4j.getExecutioner().execAndReturn(new OldSoftMax(aggClass));
final static BiFunction<Double, INDArray, INDArray> softMaxNormalizer = (sumAcc, aggClass) -> Nd4j.getExecutioner().execAndReturn(new SoftMax(aggClass)).getOutputArgument(0);

private final List<Classifier> ensemble;
private final BiFunction<Double, INDArray, INDArray> normalizer;
Expand Down
Loading