mirror of
https://github.com/xdsopl/robot36.git
synced 2025-12-06 07:12:07 +01:00
no need for the delay line to be complex here
This commit is contained in:
parent
b8441694a6
commit
08ef9d5f16
|
|
@ -16,6 +16,11 @@ public class Complex {
|
||||||
this.real = real;
|
this.real = real;
|
||||||
this.imag = imag;
|
this.imag = imag;
|
||||||
}
|
}
|
||||||
|
Complex set(Complex other) {
|
||||||
|
real = other.real;
|
||||||
|
imag = other.imag;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
Complex set(float real, float imag) {
|
Complex set(float real, float imag) {
|
||||||
this.real = real;
|
this.real = real;
|
||||||
this.imag = imag;
|
this.imag = imag;
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
private float[] recordBuffer;
|
private float[] recordBuffer;
|
||||||
private AudioRecord audioRecord;
|
private AudioRecord audioRecord;
|
||||||
private TextView status;
|
private TextView status;
|
||||||
private ComplexDelay powerDelay;
|
private Delay powerDelay;
|
||||||
private SimpleMovingAverage powerAvg;
|
private SimpleMovingAverage powerAvg;
|
||||||
private ComplexMovingAverage syncAvg;
|
private ComplexMovingAverage syncAvg;
|
||||||
private ComplexMovingAverage baseBandLowPass;
|
private ComplexMovingAverage baseBandLowPass;
|
||||||
|
|
@ -67,8 +67,8 @@ public class MainActivity extends AppCompatActivity {
|
||||||
private void processSamples() {
|
private void processSamples() {
|
||||||
for (float v : recordBuffer) {
|
for (float v : recordBuffer) {
|
||||||
baseBand = baseBandLowPass.avg(baseBand.set(v).mul(baseBandOscillator.rotate()));
|
baseBand = baseBandLowPass.avg(baseBand.set(v).mul(baseBandOscillator.rotate()));
|
||||||
syncPulse = syncAvg.avg(powerDelay.push(baseBand).mul(syncPulseOscillator.rotate()));
|
syncPulse = syncAvg.avg(syncPulse.set(baseBand).mul(syncPulseOscillator.rotate()));
|
||||||
float level = syncPulse.norm() / powerAvg.avg(baseBand.norm());
|
float level = powerDelay.push(syncPulse.norm()) / powerAvg.avg(baseBand.norm());
|
||||||
int x = Math.min((int) (scopeWidth * level), scopeWidth);
|
int x = Math.min((int) (scopeWidth * level), scopeWidth);
|
||||||
for (int i = 0; i < x; ++i)
|
for (int i = 0; i < x; ++i)
|
||||||
scopePixels[scopeWidth * curLine + i] = tint;
|
scopePixels[scopeWidth * curLine + i] = tint;
|
||||||
|
|
@ -86,7 +86,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
double powerWindowSeconds = 0.5;
|
double powerWindowSeconds = 0.5;
|
||||||
int powerWindowSamples = (int) Math.round(powerWindowSeconds * sampleRate) | 1;
|
int powerWindowSamples = (int) Math.round(powerWindowSeconds * sampleRate) | 1;
|
||||||
powerAvg = new SimpleMovingAverage(powerWindowSamples);
|
powerAvg = new SimpleMovingAverage(powerWindowSamples);
|
||||||
powerDelay = new ComplexDelay((powerWindowSamples - 1) / 2);
|
powerDelay = new Delay((powerWindowSamples - 1) / 2);
|
||||||
double syncPulseSeconds = 0.009;
|
double syncPulseSeconds = 0.009;
|
||||||
int syncPulseSamples = (int) Math.round(syncPulseSeconds * sampleRate);
|
int syncPulseSamples = (int) Math.round(syncPulseSeconds * sampleRate);
|
||||||
syncAvg = new ComplexMovingAverage(syncPulseSamples);
|
syncAvg = new ComplexMovingAverage(syncPulseSamples);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue