In [ ]:
from input_detect import ThresholdDetect
In [ ]:
ipdt = ThresholdDetect()

Initiate the input recording environment and start recording¶

In [ ]:
ipdt.init(channels=1)
ipdt.start_recording()

Record the input and calculate the 30% threshold¶

In [ ]:
ipdt.calculate_threshold(30, data_len=40000, trial_num=2)
Progress: trial 2 of 2 (100.0%)
Out[ ]:
446.54999999999995

Detect whether the input surpasses the calculated threshold¶

In [ ]:
while ipdt.detect_signal(447):
    pass
print('Signal detected.')
Signal detected.

Terminate recording¶

In [ ]:
ipdt.terminate_recording()