7c0h

Articles tagged with "music"

Why won't the music industry take my money?

I have tried this week to buy the soundtrack for The Greatest Showman for a gift and let me tell you, it's really hard.

I started naively thinking that, since the album is available on Amazon as MP3, I could just click "Buy" and be done with it. But Amazon, as it turns out, doesn't want my money. Sure, they say they will sell me the album. But once I actually try they reject my credit and debit cards with a mysterious error that, after some digging, may be related to Amazon not having the rights to that album in Germany. I say "may" because Amazon doesn't give me any usable information - all they show is this error:

We were unable to process your purchase with your current payment information. Please enter a valid payment method and an address which are both local.

Seeing that my credit card is valid, my address is local, and the buy page doesn't mention any kind of restrictions, that's my first dead end.

My second stop is Warner Music, who owns the soundtrack. This is also a waste of time: they will gladly sell me physical copies in vinyl, but digital? No luck there.

Next: Apple, the first big company to offer DRM-free music downloads and self-professed champions of user experience. We were off to a rocky start: you can only buy music using iTunes, which is not available in Linux and forces me to boot my Windows 10 PC. One hour later, courtesy of Windows 10 deciding it's a good time for an update, I am faced with this screen:

iTunes screen showing gibberish

If you think this well-known and yet unresolved issue stopped me, you are mistaken - I have signed way too many contracts in languages I don't fully grasp to be afraid of what is clearly a credit card details form. Luckily, after giving my password like 6 times, converting m4a files to mp3, and almost two hours later, I am finally the proud temporary owner of this soundtrack.

So let's talk now about Spotify. I reluctantly started using it again because it's one of the few services with an offline mode for Android phones that doesn't require giving my phone number. Seeing as I still object to their collection of private data, I created a fake profile that I regularly renew with gift cards. But do you know what happens when your subscription is about to run out? The answer is "nothing": you get zero notifications, no e-mail, nothing.

What happens when my subscription runs out? First: all of my offline music is deleted, which is the one feature I'm paying for. Since I'm often in offline mode for work, that means no music for me for the rest of the day. And second: just like there is no notification about my balance running out, there is also no option in the app to give a new gift card code. I can easily give my credit card and subscribe forever, but gift cards require extra steps.

What these two infuriating stories have in common is that they are examples of the music industry working both badly and as intended. Amazon, Spotify, and Apple (up to a point) will gladly give me access to the music I'm trying to pay for, but only if I agree to set recurring payments to their walled gardens and access to my private data. Owning my music and keeping my privacy, however, is really hard.

Which brings me to my final point. There is a service with an extensive, high-quality music catalog that's easy to use, works on every platform, let's you keep your privacy, and will take your money but only if you really want to. It's called piracy. And even though it's been almost 10 years since Gabe Newell publicly pointed out how to effectively get rid of piracy for good, we are somehow still living in a world where buying a single music CD takes two hours, Windows, fluency in fictitious languages, and a computer science degree.

At least you can now order your vinyl records per mail. Take that, 1980s!

Music for programming

Like many programmers, I am a night owl. Also, as many other programmers, I have a day job that forces me to be there at 8. These two characteristics interact badly with each other.

For most programmers, this is the type of problem normally solved with coffee. But not being a coffee drinker in general (I think it's just okay) and with what I can only assume is a natural immunity to caffeine, my to-go alternative solution is music: a good pair of headphones and epic, upbeat music makes wonders for my concentration until lunch time, when all productivity dies.

2019 was a great year for me to both catch up with songs I didn't listen to in many years and to discover new ones. The following is a list of songs to which I return every week, divided into three sections: Full albums, Instrumental songs (no words), and Individual songs (with words).

Full albums

There are two full albums that I have often listened entirely during long coding sessions, and that I definitely recommend:

  • For no one's surprise, Daft Punk's soundtrack for TRON: Legacy makes the list. Too bad the rest of the movie was not as good.
  • I haven't seen The Exorcist yet, so I never considered this album "creepy", but if you have seen it then you might recognize the opening of Tubular Bells. I found that the song's rhytm perfectly syncs with my internal rhytm, and it is not unusual for me to realize that I need to take a break right as the album comes to an end.

Instrumental Songs

It has been common knowledge for some time now that movie music is ideal for focusing on a task - you don't want the music to pull you out of a movie, the same way I don't want my music to pull me out of my work. For this reason alone, the first three items in this list are pulled straight out of Hollywood blockbusters:

Moving onto TV, the next two songs are taken from the Japanese series "Kill la Kill": Naming Sense Gata Boshi Gokuseifuku, which I could swear I never heard in the series itself, and Nui Harime's theme.

Finally, and cheating a little bit, the theme from "The Good, the bad, and the ugly" as performed by the Danish National Symphony Orchestra is the one piece of music that got me to actually, physically buy music in many years.

Individual Songs

Individual songs are always tricky, because it takes a lot of listening to them before you learn to ignore the lyrics and let them blend in the background. That said, if you are looking for songs to listen over and over again, here's a bunch:

  • The least controversial song in this list are The greatest show on Earth and Ghost Love Score, both by Nightwish. They have long instrumental-only sections, and they are epic enough to give you an extra push while working.
  • Both Heldenzeit and Guten Tag by the German band "Wir sind Helden" are the perfect example of a great band that you discover long after they have disbanded. If you are a geek, the videoclip for Analogpunk (performed by the singer of "Wir sind Helden") is full of easter eggs.
  • The theme of "Revolutionary Girl Utena", Rinbu Revolution, is really good. There are not that many series where seeing the opening over and over is a plus, but Utena manages it.

Honorable mentions

I feel John Butler's "Ocean" deserves a spot in this list. It didn't make it into the official selection simply because I couldn't decide which version to include. I'm partial to the live version because it's the first one I heard, but the 2012 studio version is not bad at all.

A more polite Taylor Swift with NLP and word vectors

My relation with Taylor Swift is complicated: I don't hate her — in fact, she seems like a very nice person. But I definitely hate her songs: her public persona always comes up to me as entitled, abusive, and/or an unpleasant person overall. But what if she didn't have to be? What if we could take her songs and make them more polite? What would that be like?

In today's post we will use the power of science to answer this question. In particular, the power of Natural Language Processing (NLP) and word embeddings.

The first step is deciding on a way to model songs. We will reach into our NLP toolbox and take out Distributional semantics, a research area that investigates whether words that show up in similar contexts also have similar meanings. This research introduced the idea that once you treat a word like a number (a vector, to be precise, called the embedding of the word), you can apply regular math operations to it and obtain results that make sense. The classical example is a result shown in this paper, where Mikolov and his team managed to represent words in such a way that the result of the operation King - man + woman ended up being very close to Queen.

The picture below shows an example. If we apply this technique to all the Sherlock Holmes novels, we can see that the names of the main characters are placed in a way that intuitively makes sense if you also plot the locations for "good", "neutral", and "evil" as I've done. Mycroft, Sherlock Holmes' brother, barely cares about anything and therefore is neutral; Sherlock, on the other hand, is much "gooder" than his brother. Watson and his wife Mary are the least morally-corrupt characters, while the criminals end up together in their own corner. "Holmes" is an interesting case: the few sentences where people refer to the detective by saying just "Sherlock" are friendly scenes, while the scenes where they call him "Mr. Holmes" are usually tense, serious, or may even refer to his brother. As a result, the world "Sherlock" ends up with a positive connotation that "Holmes" doesn't have.

Embeddings for characters in the
Sherlock Holmes novels

This technique is implemented by word2vec, a series of models that receive documents as input and turn their words into vectors. For this project, I've chosen the gensim Python library. This library does not only implement word2vec but also doc2vec, a model that will do all the heavy-lifting for us when it comes to turn a list of words into a song.

This model needs data to be trained, and here our choices are a bit limited. The biggest corpus of publicly available lyrics right now is (probably) the musiXmatch Dataset, a dataset containing information for 327K+ songs. Unfortunately, and thanks to copyright laws, working with this dataset is complicated. Therefore, our next best bet is this corpus of 55K+ songs in English, which is much easier to get and work with.

The next steps are more or less standard: for each song we take their words, convert them into vectors, and define a "song" as a special word whose meaning is a combination of its individual words. But once we have that, we can start performing some tests. The following code does all of this, and then asks an important question: what would happen if we took Aerosmith's song Amazing, removed the amazing part, and chose the song that's most similar to the result?


import csv
import gzip
from gensim.models import Doc2Vec
from gensim.models.doc2vec import TaggedDocument

documents = []
with gzip.open('songlyrics.zip', 'r') as f:
    csv_reader = csv.DictReader(f)
    counter = 0
    # Read the lyrics, turn them into documents,
    # and pre-process the words
    for row in csv_reader:
        words = simple_preprocess(row['text'])
        doc = TaggedDocument(words, ['SONG_{}'.format(counter)})
        documents.append(doc)
        counter += 1

# Train a Doc2Vec model
model = Doc2Vec(documents, size=150, window=10, min_count=2, workers=10)
model.train(document, total_examples=len(documents), epochs=10)

# Apply some simple math to a song, and obtain a list of the 10
# most similar songs to the result.
# In our lyrics database, song 22993 is "Amazing", by Aerosmith
song = model['SONG_22993']
query_vector = song - model['amazing']
for song, vector in model.docvecs.most_similar([query_vector]):
    print(song)

One would expect that Amazing minus amazing would be... well, boring. And you would be right! Predictably, when we do exactly that we end up with...

  • ...Margarita, a song about a man who meets a woman in a bar and cooks soup with her.
  • ...Alligator, a song about an alligator lying by the river.
  • ...Pony Express, a song about a mailman delivering mail.

We can use this same model to answer all kind of important questions I didn't know I had:

  • Have you ever wondered what would be "amazingly lame"? I can tell you! Amazing + lame = History in the making, a song where a rapper tells us how much money he has.
  • Don't you think sometimes "I like We are the World, but I wish it had more violence?". If so, Blood on the World's hands is the song for you.
  • What if we take Roxette's You don't understand me and add understanding to it? As it turns out, we end up with It's you, a song where a man breaks up with his wife/girlfriend because he can't be the man she's looking for. I guess he does understand her now but still: dude, harsh.
  • On the topic of hypotheticals: if we take John Lennon's Imagine and we take away the imagination, all that's left is George Gershwin's Strike up the band, a song about nothing but having "fun, fun, fun". On the other hand, if we added even more imagination we end up with Just my imagination, dreaming all day of a person who doesn't even know us.

This is all very nice, but what about our original question: what if we took Taylor Swift's songs and removed all the meanness? We can start with her Grammy-winning songs, and the results are actually amazing: the song that best captures the essence of Mean minus the meanness is Blues is my middle name, going from a song where a woman swears vengeance to a song where a man quietly laments his life and hopes that one day things will come his way. Adding politeness to We are never coming back together results in Everybody knows, a song where a man lets a woman know he's breaking up with her in a very calm and poetic way. The change is even more apparent when the bitter Christmases when you were mine turns into the (slightly too) sweet memories of Christmas brought by Something about December.

Finally, and on the other side, White Horse works better with the anger in. While this song is about a woman enraged at a man who let her down, taking the meanness out results in the hopeless laments of Yesterday's Hymn.

So there you have it. I hope it's clear that these are completely accurate results, that everything I've done here is perfectly scientific, and that any kind of criticism from Ms. Swift's fans can be safely disregarded. But on a more serious note: I hope it's clear that this is only the tip of the iceberg, and that you can take the ideas I've presented here in many cool directions. Need a hand? Let me know!

Further reading

The problem with music recommendations

There's a popular song, written by an Argentinean musician called Charly García, called "Los Dinosaurios" ("The Dinosaurs"). The song was released in 1983 in the album "Clics Modernos", and you can listen to it in all its vinyl glory here.

This song represents for me an interesting problem: it is by far my favourite song from this author, and I would like to listen to something similar. But so far all recommendation systems have failed me. Here are some of the reasons why.

A first approach could be to pick something from the same author, or even the same album. This approach, sadly, doesn't work: while Charly García is certainly a prolific author, with 41 published records and countless guest appearances, his main style is oriented towards electronic music, and it doesn't really fit the style of this specific song. If anything, this song is more fitting for his earlier albums, which limits us quite a bit - out of those 41 soloist albums, "Clics Modernos" is the second one.

We could instead assume that this song was written in a certain context, and that looking at authors from a similar context we can obtain similar music. Again, this doesn't entirely work: if we pick "Argentinean songs from the 80's", we would end up with a list of songs that fit perfectly the style of the other 8 songs on this album, but not this one specifically^1. Grouping the song into "Latin American music", as some systems do, only exacerbates the problem: there is no relation at all between this song and, say, a Cuban bachata.

If we look at the actual lyrics, the situation gets even worse: "Los dinosaurios" is a thinly veiled critique of the military dictatorship that ruled the country between 1976 and 1983. A lyrics-based systems would most likely fail on two fronts: either it wouldn't understand the references made in the song and label it as "nonsense/fantastical", or it would understand the reference and recommend politically charged songs. Neither approach seems really right - while "The times they are a-Changin" could be a viable candidate for a recommendation, neither "The Revolution will not be televised" nor "Redemption song" fit the bill.

All of these approaches fail for the same reason: they apply a network-oriented measure to a song that doesn't fit the popular rhythm of the time and place in which it was produced, and which doesn't fit the overall style of the author either.

So what exactly am I looking for? A non-technical answer would be "I need a song that contains simple vocals, a piano as it's main instrument, and with raising tension towards the end". Or in the words of the author, a song that "adapts the English sound to Tango". As far as I know, the only system that applied a similarity measure capable of detecting this would be Pandora, but with their system closed to Europe, I cannot tell whether this works or not.

Footnotes

^1 How to obtain a digital archive of Argentinean songs from the early 80's is left as an exercise for the reader.

Related reading:

The Napoleon Dynamite problem.

Guitar music and I

Here's a joke I heard once at a music academy:

How do you keep a pianist from playing? You take away their music sheet.

How do you keep a guitarist from playing? You give them a music sheet.

This joke rings oh-so-true because it highlights a key point for those of us who tried to learn guitar by ourselves: the typical amateur guitar player doesn't know how to read music, and (s)he doesn't care about it. Somehow they manage, but how they do that remains a mistery to me.

Typical guitar tabs (those you buy at a shop or download from the internet) contain therefore little more than the lyrics for a song and the points at which you are supposed to switch from one chord to another. This works pretty well for your left hand, but how about the right one? Should I just move it up and down? And at which speed? "Well", says the guitar book, "you should just do whatever feels natural". This is of course useless - what am I, the song whisperer? What if nothing feels natural? Do I just sit there in silence?

Let's take the following example, which I borrowed from Ultimate-guitar.com

RHYTHM FOR INTRO AND VERSE:
    D                       G       A
E|--2--2-2-0-2---2-3-2-0-2--3--3-3--0--0--0-0-0-0-0---|
B|--3--3-3-3-3---3-3-3-3-3--3--3-3--2--2--2-3-2-2-2---|
G|--0--0-0-0-0---0-0-0-0-0--0--0-0--2--2--2-2-2-2-2---|
D|--------------------------2--2-2--0--0--0-0-0-0-0---|
A|--------------------------3--3-3--------------------|

INTRO
D   G  A   [play twice]

VERSE 1:
       D
You'll say
G      A           D
we got nothing in common
   G      A         D
no common ground to start from
    G       A      D     G  A
and we're falling apart

This is actually a fairly complete piece: it shows the lyrics and notes (lower half) along with an attempt at explaining how should the strumming (i.e., what to do with your right hand) be performed. But here's the thing: it's not clear at all which strokes should be "up" and "down", nor the duration and silences between them. You cannot derive rhytm from this information, which is pretty bad for a section titled "Rhytm for intro and verse". And here's an extra fact: the "D" section should actually be played exactly the same as the "G A" section, but good luck discovering that from this notation. This is a known bug of guitar tabs, and yet I have several books with songs that don't even include such a section, either because they don't care or because they realized it's useless.

This is one of those very few problems that is currently solved by, of all things, Youtube. It's not too hard to find a "How to play Breakfast at Tiffany's" video tutorial, where some dude will spend some time showing you slow motion strumming, so you can play the whole thing. But how come youtubers have fixed this problem so fast, while guitar books have remained the same for decades? Why isn't everybody complaining? My theory is that the typical amateur guitarist picks up a guitar, downloads one of these tabs, fails at getting anything out of it, and quits guitar forever saying "guitars are hard".

I don't really have a good solution, because any attempt at formalizing the strumming will undoubtedly require some knowledge about rhytm, and guitar players seem to hate that. Perhaps that's how we ended up in this mess in the first place. Or perhaps there's a super easy, totally intuitive method that I've always missed for one reason or another.

But then again: how can a method do any good if it's never taught?