Aug 31

Last.fm Scrobble Graph

Last.fm profiles show quite a bit of information on the listening habits of the user, however it lacks some graphs showing the amount of scrobbles over time. I know there’s a handful of websites out there that have all kinds of graphs and can show you detailed information on most every aspect of your Last.fm library. However, I wanted to implement my own graph generator, one that didn’t have minutes of queue waiting.

At the moment my generator has two options, one where you can see your scrobbles over the course of weeks, months or even years and, if you want, compare it with another user. The other feature I added just recently, the Artist Scrobble History, shows you how many tracks by a particular artist you’ve scrobbled over time, again, you can also compare data between two users.

Because Last.fm’s API probably uses flood control and limits the requests, pulling data from their servers can take up some time, especially if it’s a lot of data (e.g. request a year’s worth) so I added database caching which speeds up the process a lot if you want to review earlier requested information. Currently the form will also auto complete artist names, granted, its implementation is not exactly great as it just pulls already cached names from the cache database rather than from Last.fm’s one. I could use the API’s artist search function but then I’d be stuck with the slow requests again.

Next up is AJAXification of the page, rather than page reloads I’d like the data to be pulled in with AJAX, if it takes a while a loading icon can be displayed and once all the information is downloaded the chart can be presented. All this will force me to refactor a whole lot of the code though. Rather than having a couple of functions and some procedural function calls which in the end result in the javascript getting the appropriate data I’ll need to make it so the arrays of data are returned with JSON encoding whenever the page is requested, that way the data can be handed to the ‘main’ page’s javascript which in turn can generate the graph.

I first tried the lazy way, copying all the generation code into a separate file and have AJAX pull that in, however since the JS wasn’t executed the chart wasn’t drawn and you didn’t see anything. So I had to use the eval() function for it to work. I’ve read that’s not really a great idea so even though it works this way, I’ll make a better, less hack-y version sometime.

In the future I might add another feature that plots how your genre listening habits have changed. If you have any other ideas feel free to post them in the comments and I’ll see if they can be added as well.

Dec 20

Maestro MuzaBot

Every year at GroupT there are one or two so called Engineering Experience projects. These projects usually involve a team consisting of around five people from the same year. This semester it was time for ‘Engineering Experience III’.

I started off mailing people even before the start of the semester because I wanted a good, functional team to work with. My dreamteam was a group of only EA (electronics) students, but it was not possible partly because I didn’t know enough people who are going to do EA starting next semester besides a couple of friends.
After a few requests and another handful of e-mails the composition of our team was finalized. Diversity  all around with two biochemical, one electromechanical and two electr(on)ical engineering students.

The objective of this project was to create a machine or robot that could be controlled by a computer using LabVIEW, Computer Based Control. Joy for the EA folks, a little less happiness at the other quadrants of the GroupT spiral. Nonetheless, no one has died from this course yet so there we were, trying to come up with a cool and realistic idea.

After an hour of brainstorming or so we had a couple ideas written down on the blackboard. Some were too hard to even consider them, others were too silly or too easy. Being a musical person myself I proposed a robot that could play some instrument, just like The Trons. Eventually everyone agreed and we quickly decided to use a metallophone  and some homemade drumming construction.

After over hundred hours (per person) of working on the software, construction and electronic circuits the result is pretty satisfactory. It could’ve been a better had we not neglected deadlines a couple of times (not gonna happen again, ever!) as we had to rush some things in the end to make it ready for the presentation.

The construction of the modules consist of Fischertechnik, LEGO and LEGO Technic blocks. Since those don’t always fit flush together we had to glue some things to make it work. The big parts are

The Read Module

Read Construction

This part of the robot can read homemade music sheets which it translates to numeric values so LabVIEW knows how to handle it. This is achieved by using a set of IR-LEDs and IR-receivers (photo-transistors) . You feed the construction (not shown) a music sheet, it’ll detect it and start pulling it in. Once the sheet has gone through the reading part the motor automatically stops.

The Metallophone Construction

Metallophone

 

Next up is one of the two modules who take care of reproducing the music. This part contains 2 motors, four musical tones (C, D, E and F) and a couple of switches. Based on what is in the arrays the hammer will first move on the x-axis to the correct position and then move in an arc-like motion to ‘slam’ on the metallic plates. A bonus thing is, both this and the drum module are ‘in sync’ as they will hit their respective target at the same time.

The Drum Module

Drum

The  drum can either hit a metal can or a plastic cup. This is the simplest construction of the robot as it only uses one motor and two switches put in parallel. As mentioned before, the hitting takes place as soon as the x-axis of the metallophone signals it’s ready to start the “hit” sequence.

The PCB and DAQ

PCB

 

 

 

The missing link between the modules and LabVIEW on our computer is the actual PCB which every electronic component is connected with. This specially designed for this course circuit board contains some basic things such as 9V and 5V voltage sources as well as other in and out gates. Another interesting component is the H-bridge so we could easily make the motors run in both directions.

Aside from this PCB, we also had a National instruments DAQ card, the 6008-USB. This DAQ-card was hooked up with a computer which runs LabVIEW. It’s relatively cheap but it’s got more features than we could’ve asked for.

GUI

Actually using and controlling the robot can be done through a GUI I made. Here you can see what is going on (yellow part), how many beats are ready to be played and how many have already been played (orange) and the virtual representation of what is being played (green).
The blue and red parts are the areas where you can either save/load music or enter your own tunes. This makes a total of three ways to add music information into the robot.

This project was a lot of fun in my opinion, and I’ve learnt a lot by designing the program in LabVIEW and helping with the construction of the different modules. Last but not least, feel free to check out the following video of the machine in action (sorry for the crappy audio/video quality!)

Nov 27

Dear acoustic guitar,

No I haven’t forgotten you. Even though your string are covered with aluminium oxide and you’re somewhat out of tune I still enjoy playing melodies with you. But playing piano is more appealing to me at the moment.

Ever since I’ve borrowed my brother’s keyboard I’ve been learning some tunes and songs to play on piano. To be honest I kinda prefer it to my guitar at the moment. Following some Learn & Master Piano lessens and playing melodies from the book that came with the keyboard.

The fun part is that I’ve learnt a lot of music theory things as well, I’m loving the fact I can play (simple) pieces on any musical instrument I get my hands on after one or two minutes. Songs are starting to make a lot more sense, what seemed once incredibly difficult is now something  I can replicate with some practice.

The learning process takes a lot of time, I get that, the mistake I made while learning to play guitar was rushing the easier pieces and trying to play pop songs immediately. I’m trying to learn playing the piano ‘the right way’ now, which has been pretty rewarding.

Once I’m done with the L&M Piano I’ll probably start over with the L&M Guitar lessons and give each instrument a fair share of my time.

… you’ll get your set of new strings soon, don’t worry :)