title: Finding patterns in a numerical signal
body: <p>Let's consider some 2D signals (amplitude over time).</p>
  
  <p>I have a library of snippets that have specific 'shapes'. For the sake of the example, let's assume a square wave, a triangle wave and a sawtooth wave, but in practice, they're a lot more complex.</p>
  
  <p>And I have a complex signal, such as an audio recording.</p>
  
  <p>What would be the best way to train a system to spot elements from the library inside the complex signal, knowing that:</p>
  
  <ul>
  <li>The library shape may be present at a different frequency.</li>
  <li>The library shape may be present at a different amplitude.</li>
  <li>Multiple shapes can be overlapping.</li>
  <li>There is noise all over.</li>
  </ul>
  
  <p>What I would like to recover is:</p>
  
  <ul>
  <li>Which shape was recognized.</li>
  <li>How close is it to the reference signal.</li>
  <li><p>Where does that shape fit in the complex signal (position, frequency, amplitude range).</p></li>
  <li><p>Bonus problem: since I'm looking for the shape itself, it may be stretched over time in a non linear fashion.</p></li>
  </ul>
  
  <p>I draw a quick picture to illustrate:</p>
  
  <p><a href="https://i.stack.imgur.com/Xx06h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xx06h.png" alt="enter image description here"></a></p>
  
  <p>As an example here, I drew 3 basic shapes for my library and I overlapped a few at different places on an audio signal.</p>
  
  <p>What would be the best approach to solve this problem?</p>
  
  <p>I would lean toward training a classifier to recognize the shapes, but I am not sure this is the right approach, nor really how practical it would be with this kind of data which has frequencies well distributed all across a wide range (50hz to 15khz).</p>