micD = getPoint(+mic_dist * 1 / 2, -mic_dist * 1 / 2)
if (array == "C"):
    micA = getPoint(-mic_dist * 3 / 2, 0)
    micB = getPoint(-mic_dist * 1 / 2, 0)
    micC = getPoint(+mic_dist * 1 / 2, 0)
    micD = getPoint(+mic_dist * 3 / 2, 0)
if (array == "D"):
    micA = getPoint(-mic_dist * 1 / 2, +mic_dist * 1 / 2)
    micB = getPoint(-mic_dist * 1 / 2, -mic_dist * 1 / 2)
    micC = getPoint(+mic_dist * 1 / 2, 0)
    micD = getPoint(+mic_dist * 3 / 2, 0)

# Darstellen
initDrawing(figsize=(16, 8))

drawPoint(micA, "x", "blue", 50)
drawPoint(micB, "x", "blue", 50)
drawPoint(micC, "x", "blue", 50)
drawPoint(micD, "x", "blue", 50)

for tdoa1 in range(-100, 100):
    for tdoa2 in range(-10, 10):
        p = SSL_TDOA_LIN(tdoa1 * 1 / 46000, tdoa2 * 1 / 46000, micA, micB,
                         micC, micD)
        if (p != "no"):
            drawPoint(p, ".", "black", 10)
#for tdoa in range(-30,30):
#    X,Y = KarstenDOA_calculateCurve_linear(micA, micB, 3*tdoa*1/48000*343.2, res=0.1, rang=100)
#    drawCurve(X, Y, color="green", style="-", size=1)
#    X,Y = KarstenDOA_calculateCurve_linear(micC, micD, 3*tdoa*1/48000*343.2, res=0.1, rang=100)
#    drawCurve(X, Y, color="red", style="-", size=1)
delta_t = delta_n*meta["sampling_spacing"]
delta_s = delta_t*343.2

# TDOA LINEAR VERFAHREN
X_NOL_CURVE, Y_NOL_CURVE = KarstenDOA_calculateCurve_nonlinear(micA_pos, micB_pos, delta_s, res=0.01, rang=10)
X_LIN_CURVE, Y_LIN_CURVE = KarstenDOA_calculateCurve_linear(micA_pos, micB_pos, delta_s, res=0.01, rang=10)

# Plot Data
import matplotlib.pyplot as plt

plt.xlim(-10,10)
plt.ylim(0,20)
plt.grid()
plt.title("Geometry")
plt.gca().set_aspect('equal', adjustable='box')
drawPoint(micA_pos, ".", "black", 40)   
drawPoint(micB_pos, ".", "black", 40)     
drawPoint(source_pos, "x", "red", 40)
plt.plot(X_NOL_CURVE, Y_NOL_CURVE)
plt.plot(X_LIN_CURVE, Y_LIN_CURVE)

## Plot Data
#import matplotlib.pyplot as plt
#plt.subplot(2,2,1)
#plt.plot(time, signals[0])
#plt.ylabel("Microphone 1")
#plt.xlim(0,0.2)
#plt.subplot(2,2,3)
#plt.plot(time, signals[1])
#plt.ylabel("Microphone 2")
#plt.xlim(0,0.2)
# Signal Processing which is fake
tdoa1 = (1/c_speed) * (distance(micPosList_TDOA[0], soundSource) - distance(micPosList_TDOA[1], soundSource))
tdoa2 = (1/c_speed) * (distance(micPosList_TDOA[2], soundSource) - distance(micPosList_TDOA[3], soundSource))

distA = distance(micPosList_AMP[0], soundSource)
distB = distance(micPosList_AMP[1], soundSource)

# Calculate Estimations
point1 = SSL_TDOA_LN(micPosList_TDOA, tdoa1, tdoa2, c_speed)
point2 = SSL_TDOA_NL(micPosList_TDOA, tdoa1, tdoa2, c_speed, point1)
point3 = SSL_AMPL(micPosList_AMP, distA, distB)

# View Results
fig, ax = initDrawing()

# Draw Microphones
for p in micPosList:
    drawPoint(p, "o", "black", 50)  
drawPointL(micPosList[0], "o", "black", 50, "Microphones")  

# Draw SoundSource position
drawPointL(soundSource, "v", "blue", 100, "Sound Source")

# Draw Estimated Locations
drawPointL(point1, "v", "red", 50, "SSL_TDOA_LN")
drawPointL(point2, "v", "green", 25, "SSL_TDOA_NL")
drawPointL(point3, "v", "yellow", 10, "SSL_AMPL")

# Finish Drawing
finishDrawingL(-40, -5, +40, +45, "Comparison of SSL Algorithms", "X-Axis", "Y-Axis")
estimPoint = getPoint(d*np.cos(a),d*np.sin(a))

# Plot Results
fig = plt.figure(figsize=(15,5))
plt.subplot(1,3,1)
plt.plot(K_list, label="sorted K list")
plt.plot(np.arange(len(K_list)-len(K_list_filt),len(K_list)),K_list_filt, label="filtered K list")
plt.hlines(estim_K, 0, 80, label="estimated K", colors="red")
plt.hlines(real_K, 0, 80, label="real K", colors="green")
plt.vlines(FILTER_LOW,0,1,label="filter_low")
plt.vlines(FILTER_HIGH,0,1,label="filter_high")
plt.legend(loc=4)

plt.subplot(1,3,2)
for p in config["microphone_positions"]:
    point = convertPoint(p)
    drawPoint(point, ".", "black", 40)    
drawPoint(convertPoint(config["source_position"]), "x", "red", 40)
drawPoint(estimPoint, "v", "green", 40)
for p in estimPoints:
    drawPoint(p, "x", "green", 30)
#drawCircle(micA_pos,rA,"blue")
#drawCircle(micB_pos,rB,"blue")
plt.xlim(-15,15)
plt.ylim(-5,30)
plt.grid()
plt.title("Geometry")
plt.gca().set_aspect('equal', adjustable='box')

plt.subplot(1,3,3)
plt.hist(K_list, bins=8)
print("Real K ",real_K)
real_K = distance(micD_pos, source_pos) * np.sqrt(powerD)
print("Real K ",real_K)

print(" ")
print(" ")

print(distance(micA_pos, source_pos), "\t", real_K/np.sqrt(powerA))
print(distance(micB_pos, source_pos), "\t", real_K/np.sqrt(powerB))
print(distance(micC_pos, source_pos), "\t", real_K/np.sqrt(powerC))
print(distance(micD_pos, source_pos), "\t", real_K/np.sqrt(powerD))
    
rA_1 = K1/np.sqrt(powerA)
rA_2 = K2/np.sqrt(powerA)
rB_1 = K1/np.sqrt(powerB)
rB_2 = K2/np.sqrt(powerB)

for p in config["microphone_positions"]:
    point = convertPoint(p)
    drawPoint(point, ".", "black", 40)    
drawPoint(convertPoint(config["source_position"]), "x", "red", 40)
drawCircle(micA_pos,rA_1,"blue")
drawCircle(micA_pos,rA_2,"red")
drawCircle(micB_pos,rB_1,"blue")
drawCircle(micB_pos,rB_2,"red")
plt.xlim(-10,10)
plt.ylim(0,20)
plt.grid()
plt.title("Geometry")
plt.gca().set_aspect('equal', adjustable='box')
예제 #6
0
curveB = get_tCurve(micC_pos, micD_pos, delta_s2)
estimationNOL = optimizeIntersectionPoint_nonLinear_numeric(estimationLIN, curveA, curveB)
    
# Kurven zur Darstellung
X_NOL_CURVE1, Y_NOL_CURVE1 = KarstenDOA_calculateCurve_nonlinear(micA_pos, micB_pos, delta_s1, res=0.01, rang=10)
X_LIN_CURVE1, Y_LIN_CURVE1 = KarstenDOA_calculateCurve_linear(micA_pos, micB_pos, delta_s1, res=0.01, rang=10)
X_NOL_CURVE2, Y_NOL_CURVE2 = KarstenDOA_calculateCurve_nonlinear(micC_pos, micD_pos, delta_s2, res=0.01, rang=10)
X_LIN_CURVE2, Y_LIN_CURVE2 = KarstenDOA_calculateCurve_linear(micC_pos, micD_pos, delta_s2, res=0.01, rang=10)

# Plot Data
import matplotlib.pyplot as plt
plt.xlim(-10,10)
plt.ylim(-1,19)
plt.grid()
plt.title("Geometry")
plt.gca().set_aspect('equal', adjustable='box')
drawPoint(estimationNOL, "x", "green", 40)
drawPoint(estimationLIN, "x", "black", 40)
drawPoint(micA_pos, ".", "black", 40)   
drawPoint(micB_pos, ".", "black", 40)     
drawPoint(micC_pos, ".", "black", 40)   
drawPoint(micD_pos, ".", "black", 40)     
drawPoint(source_pos, "x", "red", 40)
plt.plot(X_NOL_CURVE1, Y_NOL_CURVE1)
plt.plot(X_LIN_CURVE1, Y_LIN_CURVE1)
plt.plot(X_NOL_CURVE1, Y_NOL_CURVE1)
plt.plot(X_LIN_CURVE1, Y_LIN_CURVE1)
plt.plot(X_NOL_CURVE2, Y_NOL_CURVE2)
plt.plot(X_LIN_CURVE2, Y_LIN_CURVE2)
plt.plot(X_NOL_CURVE2, Y_NOL_CURVE2)
plt.plot(X_LIN_CURVE2, Y_LIN_CURVE2)
예제 #7
0
# Distance
distanceReal = distance(source_pos, getPoint(0, 0))
angleReal = 90 - angle_degree(getAngle_angle1(getPoint(0, 0), source_pos))

distanceLIN = distance(getPoint(0, 0), estimationLIN)
distanceNOL = distance(getPoint(0, 0), estimationNOL)
angleLIN = 90 - angle_degree(getAngle_angle1(getPoint(0, 0), estimationLIN))
angleNOL = 90 - angle_degree(getAngle_angle1(getPoint(0, 0), estimationNOL))

print("angles ° ", angleReal, angleLIN, angleNOL)
print("distances m ", distanceReal, distanceLIN, distanceNOL)

import matplotlib.pyplot as plt

drawPoint(micA, "x", "blue", 50)
drawPoint(micB, "x", "blue", 50)
drawPoint(micC, "x", "blue", 50)
drawPoint(micD, "x", "blue", 50)
drawPoint(source_pos, "x", "red", 50)
drawPoint(estimationLIN, "x", "green", 50)
drawPoint(estimationNOL, "x", "pink", 50)
X, Y = KarstenDOA_calculateCurve_linear(micA,
                                        micB,
                                        TDOA_CSOM1 * 343.2,
                                        res=0.1,
                                        rang=20)
plt.plot(X, Y)
X, Y = KarstenDOA_calculateCurve_linear(micC,
                                        micD,
                                        TDOA_CSOM2 * 343.2,
    counter += 1

# Plot Data
import matplotlib.pyplot as plt

plt.figure(figsize=(20, 10))

# Zeichne Geometrie
plt.subplot(1, 2, 2)
plt.xlim(-10, 10)
plt.ylim(-1, 19)
plt.grid()
plt.title("Geometry")
plt.gca().set_aspect('equal', adjustable='box')
for m in micList:
    drawPoint(m, ".", "black", 40)
drawPoint(source_pos, "x", "red", 40)
drawPoint(estimationLIN, "x", "blue", 40)
drawPoint(estimationNOL, "x", "blue", 40)

#plt.subplot(4,2,2)
#plt.plot(signals[7])
#plt.subplot(4,2,4)
#plt.plot(signals[0])
#plt.subplot(4,2,6)
#plt.plot(signals[0])
#plt.subplot(4,2,8)
#plt.plot(signals[1])

# Zeichne Quell Signal
time = generateTime(meta["sampling_rate"], meta["number_samples"])