itch.io is community of indie game creators and players

Devlogs

May 7, 2024 - NOT GAME RELATED

Tower of Meowgic
A browser game made in HTML5

I took some time off from looking at anything related to this endeavor, but I'm back!  I thought almost zilch about this project and it was very refreshing if I'm being honest.  So while I don't have a game related updated, I did have a small side project I worked on.  I don't remember if I mentioned in any previous posts, but my job is a Product Owner for an insurance company.  I don't do any development for it.  My college education 20 (!!!!) years ago was Computer Information Systems which did require all the same programming courses as the comp sci folks.  So I do understand how to code.  I've dabbled a bit here and there over the years just to stay sort of fresh with concepts to help in my day job directing dev work.  

One thing I never really had experience in was Python or APIs.  Sure, I understand JSON and APIs, but haven't actually done anything with them personally(I did a Halloween prop -- a functional Pokeball-- for my daughter a few years ago in python).  Now I can at least say I'm beginner there.  I recently got a turntable.  Whenever I take the record out, i basically set the sleeve on a table next to the TT.  I started looking at "now playing" stands so I could view the album art while it plays.  I didn't get a stand, but it got me thinking about spare parts from various projects over the years.  I have a few spare raspberry pi 0Ws and a spare GPIO 3.2" screen with a 320x240 resolution, and a USB microphone.  So why not throw those all together with duct tape and python and see what I get!?

Well, the answer is my DIY Shazam-box!  If you don't know, Shazam is a music identification service.  It listens to a few seconds of a song and gives you the metadata for the song.  I tried a few different approaches for this at first.  I really didn't want to use a pre-built service.  I wanted to capture the sound clip, generate my own "audio fingerprint", and query a database of audio fingerprints.  I feel that's the 'best' way to do this; however, all of those services would cost me money every month.  This was purely for fun and education.  At some point I may try to create my own LOCAL database of audio fingerprints so I can just generate and store the fingerprints of the albums I own, but that'd be a task for another time.  

Anyhow, basically how this is works is that I have the Pi load up my python app at boot and make it full screen (320x240).  From there, it records a 5 second audio clip.  I found an existing free API that allows 2500 calls a month on the rapidAPI website, so I cheated a bit there.  But you send that API the 5 second clip and it queries Shazam and returns all of the metadata it finds that corresponds to the song.  I grab that API response, parse it, and display it (song, artist, album, and album art)  on my tiny screen.  If the clip is unknown (happens sometimes when audio is low or there's a lot of other noise in the room), I display unknown with generic album art as seen below.  I grab a clip and perform an API call every 60 seconds.  I also added a power button icon to the UI as seen in one of the pics.  Since this is a touch screen, tapping that will shut the pi down when you're done so you don't have to yank the power cord since it is a computer after all.  


This isn't perfect and it has some items I need to fix.  I'm definitely not a UX expert, so I need to come back at some point to make this look better.  I need to align the album art better.  Improve the column wdiths.  And improve error handling (if a response isn't formatter correctly, my current error handling shuts the pi down).  I believe the API returns the track length along with the offset it thinks my sound clip is at, so at some point I want to use those 2 data elements to adjust when the api call happens and basically have it happen a few seconds after the currently displayed track info would theoretically end.  It wont' be perfect since the pi is not powerful and takes a few seconds to record, format it accordingly, make the call, and process the results.  

Anyhow, that's some of what has been occupying my time away!






Download Tower of Meowgic
Read comments (3)