title: Realtime step detection from wav file
body: <p>My goal is to take a real time audio stream, and find the steps in it to signal my lights to flash to it.</p>
  <p>Right now I have this code:</p>
  <pre class="lang-py prettyprint-override"><code>import pyaudio
  import numpy as np
  import matplotlib.pyplot as plt
  CHUNK = 2**5
  RATE = 44100
  LEN = 3
  
  p = pyaudio.PyAudio()
  
  
  stream = p.open(format=pyaudio.paInt16, channels=1, rate=RATE, input=True, frames_per_buffer=CHUNK)
  print(1)
  
  frames = []
  n = 0
  for i in range(int(LEN*RATE/CHUNK)): #go for a LEN seconds
      n += 1
      data = np.fromstring(stream.read(CHUNK),dtype=np.int16)
      num = 0
      for ii in data:
          num += abs(ii)
      print(num)
      frames.append(data)
  
  
  stream.stop_stream()
  stream.close()
  p.terminate()
  plt.figure(1)
  plt.title(&quot;Signal Wave...&quot;)
  plt.plot(frames)
  open(&quot;frames.txt&quot;, &quot;w&quot;).write(str(frames))
  </code></pre>
  <p>It takes the live audio steam created by pyaudio in this format</p>
  <p><code>[[0,0,-1,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0]),[1,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0]]</code>
  (this is depicting silence)</p>
  <p>and adds all of the number together after they have gone through the <code>abs()</code> function (absolute value)</p>
  <p><a href="https://i.imgur.com/AhUFO0s.png" rel="nofollow noreferrer">This</a> gives an accurate(ish) representation of what a graph like this looks like</p>
  <p>I see the numbers getting larger and the big jumps should be easy to calculate, but the smaller jumps are almost indistinguishable from silence.</p>
  <p>I found <a href="https://stackoverflow.com/a/56451135/19340616">this answer</a> that seems right, but i dont know how to use it.</p>
  <p>Any help would be appreciated</p>
  <p>Thanks!</p>