commit 4dd6d3fd86b28161e83a799aaf17249879dbf993
parent c143b6aa69f4986695fd7741d8128b5f8534ffa2
Author: gstraube <gstraube@users.noreply.github.com>
Date: Tue, 16 Jun 2020 17:56:49 +0200
Merge pull request #33 from TacoTheDank/master
Diffstat:
14 files changed, 107 insertions(+), 92 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -41,6 +41,7 @@ captures
*.ipr
*~
*.swp
+app/release/
# Android Patch
gen-external-apklibs
diff --git a/.travis.yml b/.travis.yml
@@ -7,7 +7,7 @@ android:
- tools
- platform-tools
- tools
- - build-tools-28.0.3
+ - build-tools-29.0.3
- android-28
- extra-android-support
@@ -18,8 +18,10 @@ android:
before_install:
- mkdir "$ANDROID_HOME/licenses" || true
- - echo -e "8933bad161af4178b1185d1a37fbf41ea5269c55\nd56f5187479451eabf01fb78af6dfcb131a6481e" > "$ANDROID_HOME/licenses/android-sdk-license"
- - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
+ - echo -e "\n24333f8a63b6825ea9c5514f83c2829b004d1fee" >
+ "$ANDROID_HOME/licenses/android-sdk-license"
+ - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" >
+ "$ANDROID_HOME/licenses/android-sdk-preview-license"
script: ./gradlew build
diff --git a/README.md b/README.md
@@ -6,9 +6,9 @@ A musical instrument tuner for Android.
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
alt="Get it on F-Droid"
height="80">](https://f-droid.org/packages/com.github.cythara/)
-[<img src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png"
- alt="Get it on Google Play"
- height="80">](https://play.google.com/store/apps/details?id=com.github.cythara)
+
+NOTE: Do not use the outdated Play Store version.
+The keystore file that was used to sign it has been lost, so updates can no longer be pushed to Google Play.
## Functionality
@@ -27,11 +27,11 @@ can be run using `./gradlew connectedCheck`. The reference images are generated
The Tarsos DSP library (https://github.com/JorenSix/TarsosDSP) is used for pitch detection.
-Current library version: commit [c26e500](https://github.com/JorenSix/TarsosDSP/tree/c26e5004e203ee79be1ec25c2603b1f11b69d276)
+Current library version: commit [d958352](https://github.com/JorenSix/TarsosDSP/tree/d9583528b9573a97c220d19e6d9ab2929e9bd1c5)
## License
-Cythara is licensed under GPLv3. A copy of the license is included in LICENSE.txt.
+Cythara is licensed under GPLv3. A copy of the license is included in the [LICENSE](https://github.com/gstraube/cythara/blob/master/LICENSE).
# Contributors
diff --git a/app/build.gradle b/app/build.gradle
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 28
- buildToolsVersion '28.0.3'
+ buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.github.cythara"
@@ -11,9 +11,9 @@ android {
versionCode 24
versionName "3.3"
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
-
vectorDrawables.useSupportLibrary = true
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -40,20 +40,17 @@ android {
dependencies {
// Support libraries
- implementation 'androidx.annotation:annotation:1.1.0-alpha01'
- implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
- implementation 'androidx.core:core:1.1.0-alpha04'
- implementation 'androidx.fragment:fragment:1.1.0-alpha03'
+ implementation 'androidx.appcompat:appcompat:1.1.0'
// Other
implementation 'com.jaredrummler:material-spinner:1.3.1'
- implementation 'com.shawnlin:number-picker:2.4.7'
+ implementation 'com.shawnlin:number-picker:2.4.10'
// Testing libraries
- testImplementation 'junit:junit:4.13-beta-1'
- testImplementation 'org.hamcrest:hamcrest:2.1'
- testImplementation 'org.powermock:powermock-api-mockito2:2.0.0'
- testImplementation 'org.powermock:powermock-module-junit4:2.0.0'
- androidTestImplementation 'androidx.test:rules:1.1.2-alpha01'
- androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
+ testImplementation 'junit:junit:4.13'
+ testImplementation 'org.hamcrest:hamcrest:2.2'
+ testImplementation 'org.powermock:powermock-api-mockito2:2.0.7'
+ testImplementation 'org.powermock:powermock-module-junit4:2.0.7'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.1'
+ androidTestImplementation 'androidx.test:rules:1.2.0'
}
diff --git a/app/release/output.json b/app/release/output.json
@@ -1 +0,0 @@
-[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":20,"versionName":"2.9","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
-\ No newline at end of file
diff --git a/app/src/androidTest/java/com/github/cythara/TunerViewTest.java b/app/src/androidTest/java/com/github/cythara/TunerViewTest.java
@@ -6,6 +6,10 @@ import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.os.Environment;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.rule.ActivityTestRule;
+import androidx.test.rule.GrantPermissionRule;
+
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
@@ -18,11 +22,6 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import androidx.test.rule.ActivityTestRule;
-import androidx.test.rule.GrantPermissionRule;
-import androidx.test.runner.AndroidJUnit4;
-
-import static androidx.test.rule.GrantPermissionRule.grant;
import static com.github.cythara.tuning.GuitarTuning.Pitch.*;
import static java.lang.String.format;
@@ -35,15 +34,15 @@ public class TunerViewTest {
@Rule
public GrantPermissionRule recordAudioRule =
- grant(Manifest.permission.RECORD_AUDIO);
+ GrantPermissionRule.grant(Manifest.permission.RECORD_AUDIO);
@Rule
public GrantPermissionRule writePermissionRule =
- grant(Manifest.permission.WRITE_EXTERNAL_STORAGE);
+ GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE);
@Rule
public GrantPermissionRule readPermissionRule =
- grant(Manifest.permission.READ_EXTERNAL_STORAGE);
+ GrantPermissionRule.grant(Manifest.permission.READ_EXTERNAL_STORAGE);
@Test
public void exactly_matching_pitch_is_displayed() throws IOException {
diff --git a/app/src/main/java/be/tarsos/dsp/AudioEvent.java b/app/src/main/java/be/tarsos/dsp/AudioEvent.java
@@ -203,25 +203,9 @@ public class AudioEvent {
* The buffer with audio information.
* @return The dBSPL level for the buffer.
*/
- private double soundPressureLevel(final float[] buffer) {
- double value = Math.pow(localEnergy(buffer), 0.5);
- value = value / buffer.length;
- return linearToDecibel(value);
- }
-
- /**
- * Calculates the local (linear) energy of an audio buffer.
- *
- * @param buffer
- * The audio buffer.
- * @return The local (linear) energy of an audio buffer.
- */
- private double localEnergy(final float[] buffer) {
- double power = 0.0D;
- for (float element : buffer) {
- power += element * element;
- }
- return power;
+ private static double soundPressureLevel(final float[] buffer) {
+ double rms = calculateRMS(buffer);
+ return linearToDecibel(rms);
}
/**
@@ -231,7 +215,7 @@ public class AudioEvent {
* The value to convert.
* @return The converted value.
*/
- private double linearToDecibel(final double value) {
+ private static double linearToDecibel(final double value) {
return 20.0 * Math.log10(value);
}
diff --git a/app/src/main/java/be/tarsos/dsp/SilenceDetector.java b/app/src/main/java/be/tarsos/dsp/SilenceDetector.java
@@ -57,18 +57,21 @@ public class SilenceDetector implements AudioProcessor {
}
/**
- * Calculates the local (linear) energy of an audio buffer.
- *
- * @param buffer
- * The audio buffer.
- * @return The local (linear) energy of an audio buffer.
+ * Calculates and returns the root mean square of the signal. Please
+ * cache the result since it is calculated every time.
+ * @param floatBuffer The audio buffer to calculate the RMS for.
+ * @return The <a
+ * href="http://en.wikipedia.org/wiki/Root_mean_square">RMS</a> of
+ * the signal present in the current buffer.
*/
- private double localEnergy(final float[] buffer) {
- double power = 0.0D;
- for (float element : buffer) {
- power += element * element;
+ public static double calculateRMS(float[] floatBuffer){
+ double rms = 0.0;
+ for (int i = 0; i < floatBuffer.length; i++) {
+ rms += floatBuffer[i] * floatBuffer[i];
}
- return power;
+ rms = rms / Double.valueOf(floatBuffer.length);
+ rms = Math.sqrt(rms);
+ return rms;
}
/**
@@ -78,10 +81,9 @@ public class SilenceDetector implements AudioProcessor {
* The buffer with audio information.
* @return The dBSPL level for the buffer.
*/
- private double soundPressureLevel(final float[] buffer) {
- double value = Math.pow(localEnergy(buffer), 0.5);
- value = value / buffer.length;
- return linearToDecibel(value);
+ private static double soundPressureLevel(final float[] buffer) {
+ double rms = calculateRMS(buffer);
+ return linearToDecibel(rms);
}
/**
@@ -91,7 +93,7 @@ public class SilenceDetector implements AudioProcessor {
* The value to convert.
* @return The converted value.
*/
- private double linearToDecibel(final double value) {
+ private static double linearToDecibel(final double value) {
return 20.0 * Math.log10(value);
}
diff --git a/app/src/main/java/be/tarsos/dsp/mfcc/MFCC.java b/app/src/main/java/be/tarsos/dsp/mfcc/MFCC.java
@@ -127,7 +127,7 @@ public class MFCC implements AudioProcessor {
//Calculates te centerfrequencies.
for (int i = 1; i <= amountOfMelFilters; i++) {
float fc = (inverseMel(mel[0] + factor * i) / sampleRate) * samplesPerFrame;
- centerFrequencies[i - 1] = Math.round(fc);
+ centerFrequencies[i] = Math.round(fc);
}
}
diff --git a/build.gradle b/build.gradle
@@ -7,7 +7,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.5.2'
+ classpath 'com.android.tools.build:gradle:4.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
Binary files differ.
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Sun Nov 10 16:39:59 CET 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
diff --git a/gradlew b/gradlew
@@ -1,5 +1,21 @@
#!/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
@@ -28,7 +44,7 @@ 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"'
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -66,6 +82,7 @@ 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
@@ -109,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# 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
@@ -138,19 +156,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ 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" ;;
+ 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
@@ -159,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
-APP_ARGS=$(save "$@")
+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"
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
@@ -1,3 +1,19 @@
+@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
@@ -13,8 +29,11 @@ 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"
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -65,6 +84,7 @@ set CMD_LINE_ARGS=%*
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 %CMD_LINE_ARGS%