code: def testSquareWaves(self):
      # The algorithm should be able to detect the positive part
      # of square waves at different frequencies.
  
      fs = 44100
      minFreq = 100  # Hz
      maxFreq = 10000  # Hz
      time = 0.1  # s
  
      sd = SaturationDetector(minimumDuration=0.0, hopSize=512)
      for f in numpy.linspace(minFreq, maxFreq, 5):
          sampleNum = int(fs / f)
          sampleNum -= sampleNum % 2
  
          waveTable = [0] * sampleNum
          waveTable[: sampleNum // 2] = [1] * (sampleNum // 2)
  
          waveDur = len(waveTable) / 44100.0
          repetitions = int(time / waveDur)
  
          realStarts = esarr(range(0, repetitions)) * waveDur
          realEnds = realStarts + waveDur
  
          input = waveTable * repetitions
  
          starts = esarr([])
          ends = esarr([])
          for frame in FrameGenerator(
              input, frameSize=512, hopSize=512, startFromZero=True
          ):
              s, e = sd(frame)
  
              starts = np.hstack([starts, s])
              ends = np.hstack([ends, e])
  
          self.assertAlmostEqualVectorFixedPrecision(
              starts, realStarts, 2
          )
          self.assertAlmostEqualVectorFixedPrecision(ends, realEnds, 2)
          sd.reset()
  
file_path: essentia/test/src/unittests/audioproblems/test_saturationdetector.py
imports: import numpy
  from math import *
  from essentia_test import *
  from essentia import array
label_desc: Use image node_id 5 for calling the TestSaturationDetector obj's underlying member method code with example usage: obj.testSquareWaves() without return types