Browse Source

Commit before cleaning project for merge (minor changes)

tw
Tobias Wolz 1 year ago
parent
commit
4381ae78f8

app/src/main/java/com/example/ueberwachungssystem/DetectionReport.java → app/src/main/java/com/example/ueberwachungssystem/Detector/DetectionReport.java View File

package com.example.ueberwachungssystem;
package com.example.ueberwachungssystem.Detector;


import android.util.Log; import android.util.Log;



app/src/main/java/com/example/ueberwachungssystem/Detector.java → app/src/main/java/com/example/ueberwachungssystem/Detector/Detector.java View File

package com.example.ueberwachungssystem;
package com.example.ueberwachungssystem.Detector;


import android.app.Activity;
import android.content.Context; import android.content.Context;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;



app/src/main/java/com/example/ueberwachungssystem/MicrophoneDetector.java → app/src/main/java/com/example/ueberwachungssystem/Detector/MicrophoneDetector.java View File

package com.example.ueberwachungssystem;
package com.example.ueberwachungssystem.Detector;


import static java.lang.Math.*; import static java.lang.Math.*;


import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat; 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.GraphView;
import com.jjoe64.graphview.series.DataPoint; import com.jjoe64.graphview.series.DataPoint;
import com.jjoe64.graphview.series.LineGraphSeries; import com.jjoe64.graphview.series.LineGraphSeries;

app/src/main/java/com/example/ueberwachungssystem/Signalverarbeitung/Complex.java → app/src/main/java/com/example/ueberwachungssystem/Detector/Signalverarbeitung/Complex.java View File

package com.example.ueberwachungssystem.Signalverarbeitung;
package com.example.ueberwachungssystem.Detector.Signalverarbeitung;


import java.util.Objects; import java.util.Objects;


im = imag; 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() { public String toString() {
if (im == 0) return re + ""; if (im == 0) return re + "";
if (re == 0) return im + "i"; if (re == 0) return im + "i";
return Math.atan2(im, re); 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) { public Complex plus(Complex b) {
Complex a = this; // invoking object Complex a = this; // invoking object
double real = a.re + b.re; double real = a.re + b.re;
return new Complex(real, imag); 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) { public Complex minus(Complex b) {
Complex a = this; Complex a = this;
double real = a.re - b.re; double real = a.re - b.re;
return new Complex(real, imag); 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) { public Complex times(Complex b) {
Complex a = this; Complex a = this;
double real = a.re * b.re - a.im * b.im; double real = a.re * b.re - a.im * b.im;
return new Complex(alpha * re, alpha * im); 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() { public Complex conjugate() {
return new Complex(re, -im); 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() { public Complex reciprocal() {
double scale = re * re + im * im; double scale = re * re + im * im;
return new Complex(re / scale, -im / scale); return new Complex(re / scale, -im / scale);
return a.times(b.reciprocal()); 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() { public Complex exp() {
return new Complex(Math.exp(re) * Math.cos(im), Math.exp(re) * Math.sin(im)); 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() { public Complex sin() {
return new Complex(Math.sin(re) * Math.cosh(im), Math.cos(re) * Math.sinh(im)); 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() { public Complex cos() {
return new Complex(Math.cos(re) * Math.cosh(im), -Math.sin(re) * Math.sinh(im)); 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() { public Complex tan() {
return sin().divides(cos()); return sin().divides(cos());
} }

app/src/main/java/com/example/ueberwachungssystem/Signalverarbeitung/FFT.java → app/src/main/java/com/example/ueberwachungssystem/Detector/Signalverarbeitung/FFT.java View File

package com.example.ueberwachungssystem.Signalverarbeitung;
package com.example.ueberwachungssystem.Detector.Signalverarbeitung;
// Source: https://introcs.cs.princeton.edu/java/97data/FFT.java.html // Source: https://introcs.cs.princeton.edu/java/97data/FFT.java.html


import android.util.Log;

/****************************************************************************** /******************************************************************************
* Compilation: javac FFT.java * Compilation: javac FFT.java
* Execution: java FFT n * 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 * Compute the FFT and inverse FFT of a length n complex sequence
* using the radix 2 Cooley-Tukey algorithm. * using the radix 2 Cooley-Tukey algorithm.
return y; 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) { public static void show(Complex[] x, String title) {
System.out.println(title); System.out.println(title);
System.out.println("-------------------"); System.out.println("-------------------");

app/src/main/java/com/example/ueberwachungssystem/logger/Logger.java → app/src/main/java/com/example/ueberwachungssystem/Detector/logger/Logger.java View File

package com.example.ueberwachungssystem.logger;
package com.example.ueberwachungssystem.Detector.logger;


import android.util.Log; import android.util.Log;
import android.widget.TextView; import android.widget.TextView;

+ 12
- 1
app/src/main/java/com/example/ueberwachungssystem/MainActivity.java View File

package com.example.ueberwachungssystem; package com.example.ueberwachungssystem;


import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;


import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.Switch; import android.widget.Switch;
import android.widget.TextView; 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; import com.jjoe64.graphview.GraphView;




graph = (GraphView) findViewById(R.id.graph); graph = (GraphView) findViewById(R.id.graph);
Mic = new MicrophoneDetector(this, logger, graph); Mic = new MicrophoneDetector(this, logger, graph);
setupMic(); setupMic();
Mic.setOnDetectionListener(new Detector.OnDetectionListener() {
@Override
public void onDetection(@NonNull DetectionReport detectionReport) {
Log.d("Detect", "erkannt!");
}
});


} }



Loading…
Cancel
Save