From 4381ae78f8b4a4e6563361cc0f4bab8fb2108d14 Mon Sep 17 00:00:00 2001 From: Tobias Wolz Date: Tue, 20 Jun 2023 21:16:18 +0200 Subject: [PATCH] Commit before cleaning project for merge (minor changes) --- .../{ => Detector}/DetectionReport.java | 2 +- .../{ => Detector}/Detector.java | 3 +-- .../{ => Detector}/MicrophoneDetector.java | 8 +++---- .../Signalverarbeitung/Complex.java | 22 +++++++++---------- .../Signalverarbeitung/FFT.java | 8 +++---- .../{ => Detector}/logger/Logger.java | 2 +- .../ueberwachungssystem/MainActivity.java | 13 ++++++++++- 7 files changed, 33 insertions(+), 25 deletions(-) rename app/src/main/java/com/example/ueberwachungssystem/{ => Detector}/DetectionReport.java (95%) rename app/src/main/java/com/example/ueberwachungssystem/{ => Detector}/Detector.java (94%) rename app/src/main/java/com/example/ueberwachungssystem/{ => Detector}/MicrophoneDetector.java (98%) rename app/src/main/java/com/example/ueberwachungssystem/{ => Detector}/Signalverarbeitung/Complex.java (75%) rename app/src/main/java/com/example/ueberwachungssystem/{ => Detector}/Signalverarbeitung/FFT.java (96%) rename app/src/main/java/com/example/ueberwachungssystem/{ => Detector}/logger/Logger.java (96%) diff --git a/app/src/main/java/com/example/ueberwachungssystem/DetectionReport.java b/app/src/main/java/com/example/ueberwachungssystem/Detector/DetectionReport.java similarity index 95% rename from app/src/main/java/com/example/ueberwachungssystem/DetectionReport.java rename to app/src/main/java/com/example/ueberwachungssystem/Detector/DetectionReport.java index bfcb52c..57f94d2 100644 --- a/app/src/main/java/com/example/ueberwachungssystem/DetectionReport.java +++ b/app/src/main/java/com/example/ueberwachungssystem/Detector/DetectionReport.java @@ -1,4 +1,4 @@ -package com.example.ueberwachungssystem; +package com.example.ueberwachungssystem.Detector; import android.util.Log; diff --git a/app/src/main/java/com/example/ueberwachungssystem/Detector.java b/app/src/main/java/com/example/ueberwachungssystem/Detector/Detector.java similarity index 94% rename from app/src/main/java/com/example/ueberwachungssystem/Detector.java rename to app/src/main/java/com/example/ueberwachungssystem/Detector/Detector.java index e6ac3ea..2d73b9d 100644 --- a/app/src/main/java/com/example/ueberwachungssystem/Detector.java +++ b/app/src/main/java/com/example/ueberwachungssystem/Detector/Detector.java @@ -1,6 +1,5 @@ -package com.example.ueberwachungssystem; +package com.example.ueberwachungssystem.Detector; -import android.app.Activity; import android.content.Context; import androidx.annotation.NonNull; diff --git a/app/src/main/java/com/example/ueberwachungssystem/MicrophoneDetector.java b/app/src/main/java/com/example/ueberwachungssystem/Detector/MicrophoneDetector.java similarity index 98% rename from app/src/main/java/com/example/ueberwachungssystem/MicrophoneDetector.java rename to app/src/main/java/com/example/ueberwachungssystem/Detector/MicrophoneDetector.java index 4a58499..90ed37f 100644 --- a/app/src/main/java/com/example/ueberwachungssystem/MicrophoneDetector.java +++ b/app/src/main/java/com/example/ueberwachungssystem/Detector/MicrophoneDetector.java @@ -1,4 +1,4 @@ -package com.example.ueberwachungssystem; +package com.example.ueberwachungssystem.Detector; import static java.lang.Math.*; @@ -14,9 +14,9 @@ import android.os.AsyncTask; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; -import com.example.ueberwachungssystem.Signalverarbeitung.Complex; -import com.example.ueberwachungssystem.Signalverarbeitung.FFT; -import com.example.ueberwachungssystem.logger.Logger; +import com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex; +import com.example.ueberwachungssystem.Detector.Signalverarbeitung.FFT; +import com.example.ueberwachungssystem.Detector.logger.Logger; import com.jjoe64.graphview.GraphView; import com.jjoe64.graphview.series.DataPoint; import com.jjoe64.graphview.series.LineGraphSeries; diff --git a/app/src/main/java/com/example/ueberwachungssystem/Signalverarbeitung/Complex.java b/app/src/main/java/com/example/ueberwachungssystem/Detector/Signalverarbeitung/Complex.java similarity index 75% rename from app/src/main/java/com/example/ueberwachungssystem/Signalverarbeitung/Complex.java rename to app/src/main/java/com/example/ueberwachungssystem/Detector/Signalverarbeitung/Complex.java index 26a3c28..12938a3 100644 --- a/app/src/main/java/com/example/ueberwachungssystem/Signalverarbeitung/Complex.java +++ b/app/src/main/java/com/example/ueberwachungssystem/Detector/Signalverarbeitung/Complex.java @@ -1,4 +1,4 @@ -package com.example.ueberwachungssystem.Signalverarbeitung; +package com.example.ueberwachungssystem.Detector.Signalverarbeitung; import java.util.Objects; @@ -12,7 +12,7 @@ public class Complex { im = imag; } - // return a string representation of the invoking com.example.ueberwachungssystem.Signalverarbeitung.Complex object + // return a string representation of the invoking com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object public String toString() { if (im == 0) return re + ""; if (re == 0) return im + "i"; @@ -30,7 +30,7 @@ public class Complex { return Math.atan2(im, re); } - // return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is (this + b) + // return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is (this + b) public Complex plus(Complex b) { Complex a = this; // invoking object double real = a.re + b.re; @@ -38,7 +38,7 @@ public class Complex { return new Complex(real, imag); } - // return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is (this - b) + // return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is (this - b) public Complex minus(Complex b) { Complex a = this; double real = a.re - b.re; @@ -46,7 +46,7 @@ public class Complex { return new Complex(real, imag); } - // return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is (this * b) + // return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is (this * b) public Complex times(Complex b) { Complex a = this; double real = a.re * b.re - a.im * b.im; @@ -59,12 +59,12 @@ public class Complex { return new Complex(alpha * re, alpha * im); } - // return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is the conjugate of this + // return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the conjugate of this public Complex conjugate() { return new Complex(re, -im); } - // return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is the reciprocal of this + // return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the reciprocal of this public Complex reciprocal() { double scale = re * re + im * im; return new Complex(re / scale, -im / scale); @@ -85,22 +85,22 @@ public class Complex { return a.times(b.reciprocal()); } - // return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is the complex exponential of this + // return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the complex exponential of this public Complex exp() { return new Complex(Math.exp(re) * Math.cos(im), Math.exp(re) * Math.sin(im)); } - // return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is the complex sine of this + // return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the complex sine of this public Complex sin() { return new Complex(Math.sin(re) * Math.cosh(im), Math.cos(re) * Math.sinh(im)); } - // return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is the complex cosine of this + // return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the complex cosine of this public Complex cos() { return new Complex(Math.cos(re) * Math.cosh(im), -Math.sin(re) * Math.sinh(im)); } - // return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is the complex tangent of this + // return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the complex tangent of this public Complex tan() { return sin().divides(cos()); } diff --git a/app/src/main/java/com/example/ueberwachungssystem/Signalverarbeitung/FFT.java b/app/src/main/java/com/example/ueberwachungssystem/Detector/Signalverarbeitung/FFT.java similarity index 96% rename from app/src/main/java/com/example/ueberwachungssystem/Signalverarbeitung/FFT.java rename to app/src/main/java/com/example/ueberwachungssystem/Detector/Signalverarbeitung/FFT.java index 2543310..8c9426b 100644 --- a/app/src/main/java/com/example/ueberwachungssystem/Signalverarbeitung/FFT.java +++ b/app/src/main/java/com/example/ueberwachungssystem/Detector/Signalverarbeitung/FFT.java @@ -1,12 +1,10 @@ -package com.example.ueberwachungssystem.Signalverarbeitung; +package com.example.ueberwachungssystem.Detector.Signalverarbeitung; // Source: https://introcs.cs.princeton.edu/java/97data/FFT.java.html -import android.util.Log; - /****************************************************************************** * Compilation: javac FFT.java * Execution: java FFT n - * Dependencies: com.example.ueberwachungssystem.Signalverarbeitung.Complex.java + * Dependencies: com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex.java * * Compute the FFT and inverse FFT of a length n complex sequence * using the radix 2 Cooley-Tukey algorithm. @@ -158,7 +156,7 @@ public class FFT { return y; } - // display an array of com.example.ueberwachungssystem.Signalverarbeitung.Complex numbers to standard output + // display an array of com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex numbers to standard output public static void show(Complex[] x, String title) { System.out.println(title); System.out.println("-------------------"); diff --git a/app/src/main/java/com/example/ueberwachungssystem/logger/Logger.java b/app/src/main/java/com/example/ueberwachungssystem/Detector/logger/Logger.java similarity index 96% rename from app/src/main/java/com/example/ueberwachungssystem/logger/Logger.java rename to app/src/main/java/com/example/ueberwachungssystem/Detector/logger/Logger.java index 07af51a..8881762 100644 --- a/app/src/main/java/com/example/ueberwachungssystem/logger/Logger.java +++ b/app/src/main/java/com/example/ueberwachungssystem/Detector/logger/Logger.java @@ -1,4 +1,4 @@ -package com.example.ueberwachungssystem.logger; +package com.example.ueberwachungssystem.Detector.logger; import android.util.Log; import android.widget.TextView; diff --git a/app/src/main/java/com/example/ueberwachungssystem/MainActivity.java b/app/src/main/java/com/example/ueberwachungssystem/MainActivity.java index ee9c096..9acc734 100644 --- a/app/src/main/java/com/example/ueberwachungssystem/MainActivity.java +++ b/app/src/main/java/com/example/ueberwachungssystem/MainActivity.java @@ -1,13 +1,18 @@ package com.example.ueberwachungssystem; +import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; +import android.util.Log; import android.view.View; import android.widget.Switch; import android.widget.TextView; -import com.example.ueberwachungssystem.logger.Logger; +import com.example.ueberwachungssystem.Detector.DetectionReport; +import com.example.ueberwachungssystem.Detector.Detector; +import com.example.ueberwachungssystem.Detector.MicrophoneDetector; +import com.example.ueberwachungssystem.Detector.logger.Logger; import com.jjoe64.graphview.GraphView; @@ -28,6 +33,12 @@ public class MainActivity extends AppCompatActivity { graph = (GraphView) findViewById(R.id.graph); Mic = new MicrophoneDetector(this, logger, graph); setupMic(); + Mic.setOnDetectionListener(new Detector.OnDetectionListener() { + @Override + public void onDetection(@NonNull DetectionReport detectionReport) { + Log.d("Detect", "erkannt!"); + } + }); }