Shazam blocks In SNAP!

YEAAARSSS AGO I asked what I should make. @bh replied with Shazam, at the time I thought it was impossible. I was very wrong. After a while the idea of it was still in my head. so I did some research and eventually ended up coding my own Shazam algorithm in JS; but i was not satisfied. It took a while mostly due to fixing errors took forever to locate and the code took forever to run so it was a non stop loop of waiting. Today I decided to sit down and finally finish it! HERE IT IS!

Still a couple of things I would like to work out.

  1. A recording system that can be as simple as holding space for up to 10 seconds to record
  2. make them BOTH faster

Huh, well done!

But I don’t understand how you can have more than one song in your database if your ADD SONG block starts with
untitled script pic (7)

have you looked at our SnapZam project? It sounds like pretty much exactly what you’d like to accomplish, except that’s all written in Snap! using the neural networks library, and a custom block that lets you record a few seconds of any sound or song, but its spectra, not the samples. We’ve been using this in many workshops with actual people all over … the world, actually, and it’s working surprisingly well…

Was an error. Was fixed.

Wow. Did not know these recording options existed

Have you considered adding any of the tutorials you make to the examples section in the open menu?

yes, in fact, that’s precisely what I’m planning to do. But I first want to get more experienced in making tutorials, and I want to see how they’re actually working in real classrooms. And - most importantly - I want to make some tutorials about the features in Snap! that are really great, and not just the terrible imperative stuff they’re making us do right now…

Wow! I didn’t know you’d done that. It’s definitely my favorite real-world application of AI techniques.

(Do we know how the actual Shazam hashes a song? It recognizes the song even if it’s most of the way finished playing by the time I fumble my phone out and find the button to click. :~) )

Thanks! The idea to use the frequency spectrum instead of the samples (which already was impressive because how does it even work?) came from our Canadian teacher friend Glenn Boustead. We met him at FOSDEM and he gave us a demo and showed us how he uses Snap’s neural networks - not the library but the perceptron sprite - with recorded sound spectra to let kids classify anything from bird chirps to music styles. I only fixed a glitch in Snap’s normalization code, and used our own neural networks library.

I have no idea how Shazam actually works ;)

ChatGPT found it for me:

Basically they FFT the sound, look for local maxima, and then (the key smart part) they record pairs of peak frequencies, along with the time difference between the peaks. For reasons I don’t yet understand (I’ve so far only read ChatGPT’s summary, not the actual paper), this measure is highly resistant to ambient noise picked up by your phone along with the actual music.