MCPcopy Create free account
hub / github.com/PyTTaMaster/PyTTa / cumulative_integration

Function cumulative_integration

pytta/classes/analysis.py:1443–1494  ·  view source on GitHub ↗

Cumulative integration with proper corrections.

(inputSignal,
                           bypassLundeby,
                           plotLundebyResults,
                           suppressWarnings=True,
                           **kwargs)

Source from the content-addressed store, hash-verified

1441
1442
1443def cumulative_integration(inputSignal,
1444 bypassLundeby,
1445 plotLundebyResults,
1446 suppressWarnings=True,
1447 **kwargs):
1448 """Cumulative integration with proper corrections."""
1449
1450 def plot_lundeby():
1451 c0, c1, interIdx, BGL = lundebyParams
1452 fig = plt.figure(figsize=(10, 5))
1453 ax = fig.add_axes([0.08, 0.15, 0.75, 0.8], polar=False,
1454 projection='rectilinear', xscale='linear')
1455 line = c1*inputSignal.timeVector + c0
1456 ax.plot(inputSignal.timeVector, 10*np.log10(inputSignal.timeSignal**2), label='IR')
1457 ax.axhline(y=10*np.log10(BGL), color='#1f77b4', label='BG Noise', c='red')
1458 ax.plot(inputSignal.timeVector, line, label='Late slope', c='black')
1459 ax.axvline(x=interIdx/inputSignal.samplingRate, label='Truncation point', c='green')
1460 ax.grid()
1461 ax.set_xlabel('Time [s]')
1462 ax.set_ylabel('Amplitude [dBFS]')
1463 plt.title('{0:.0f} [Hz]'.format(band))
1464 ax.legend(loc='best', shadow=True, fontsize='x-large')
1465
1466 # timeSignal = inputSignal.timeSignal[:]
1467 # Substituted by SignalObj.crop in analyse function
1468 # timeSignal, sampleShift = _circular_time_shift(timeSignal)
1469 # del sampleShift
1470 # hSignal = SignalObj(timeSignal, inputSignal.lengthDomain, inputSignal.samplingRate)
1471 hSignal = _filter(inputSignal, **kwargs)
1472 bands = FOF(nthOct=kwargs['nthOct'],
1473 freqRange=[kwargs['minFreq'],
1474 kwargs['maxFreq']])[:, 1]
1475 listEDC = []
1476 for ch in range(hSignal.numChannels):
1477 signal = hSignal[ch]
1478 band = bands[ch]
1479 energyDecay, energyVector, lundebyParams = \
1480 energy_decay_calculation(band,
1481 signal.timeSignal,
1482 signal.timeVector,
1483 signal.samplingRate,
1484 signal.numSamples,
1485 signal.numChannels,
1486 signal.timeLength,
1487 bypassLundeby,
1488 suppressWarnings=suppressWarnings)
1489 listEDC.append((energyDecay, energyVector))
1490 if plotLundebyResults: # Placed here because Numba can't handle plots.
1491 # plot_lundeby(band, timeVector, timeSignal, samplingRate,
1492 # lundebyParams)
1493 plot_lundeby()
1494 return listEDC, hSignal
1495
1496# @njit
1497def reverb_time_regression(energyDecay, energyVector, upperLim, lowerLim):

Callers 2

analyseFunction · 0.90

Calls 4

energy_decay_calculationFunction · 0.85
plot_lundebyFunction · 0.85
appendMethod · 0.80
_filterFunction · 0.70

Tested by

no test coverage detected