![]() ![]() ![]() A Spotify code is pretty low risk: it’s easy to ping the server a few times if you decode the wrong media reference. If you are sending a message to a deep space probe you want a very strong code. It facilitates a limited amount of error correction, but that is okay. This code rate is high (close to 1) meaning it is fairly weak. Spotify adds 15 bits to the 45 bit code, so the code rate is 45 / 60 = 0.75. The code rate of an error correction scheme is the ratio of the information bits to the total encoded bit length. The patents don’t specify what forward error correction schema Spotify uses, but they do say that they add 15 bits at this step. But since there are 2 redundant bits, the receiver can guess what the value was meant to be: Triplet received When that triplet is sent across a “noisy” communication channel, some of the bits could get flipped. So instead of sending 1, you would send 111. The fundamental principle of is to add redundant bits in order to help the decoder to find out the true message that was encoded by the transmitter.Ī simple example of error correction would be to replicate each bit twice. Decoding Spotify codes involves going from analog (bar lengths) to digital (media reference), so it is a good candidate for this error correction. This makes the decoding process more reliable. Next forward error correction (FEC) is used to add some redundancy to the code. Media_reference = b ' \x0f\xc7\xbb\xe9\xb7\x0c ' Forward error correction # A Stack Overflow user discovered that you can sniff the request that your phone makes when scanning the barcode to determine the media reference and API endpoint. After extracting a media reference from a barcode, you check with Spotify’s database (a look-up table) to determine what URI it corresponds to. The media reference may just be the hash of an incrementing index. This media reference is 37 bits long and is the key that links a barcode to a given URI. When you visit Spotify codes and input a Spotify URI, a “media reference” is created by Spotify. I used to think academic papers were full of jargon until I read some technical patents. ![]() This question was a start, but I ended up asking this SO question and getting a couple of answers that linked to the relevant patents and contained more info about Spotify’s look up table. This is when I started asking questions and hunting for answers. How do you convert a 63^22 bit URI into an 8^20 bit barcode? There is 2.3e 21 times as much information in the URI than there is in the barcode. This means that there are 8^20 pieces of information that can be encoded into the code. The barcode consists of 23 bars, of which only 20 actually contain information. This is the sequence of the “Take On Me” Spotify code: # multiply by 8 to get an octal integer ratio *= 8 ratio //= 1 # convert to integer (and make 0 based) sequence. # the first object (spotify logo) is the max height of the bars logo = bar_dimensions # get the dimensions and positions of bounding box around objects bar_dimensions = # label connected regions as objects labeled = label(binary_im) """ # convert to grayscale, then binary image = io. """Open an image and return a list of the bar heights. In this function I use scikit-image to calculate the sequence of bar heights from a logo.įrom asure import label, regionpropsįrom skimage.filters import threshold_otsu This makes it easy to generate ratios of the bars’ heights. The Spotify logo’s diameter is the same as the height of the highest bar. When the bars are sorted by height you can see that there are 8 discrete heights that they fall into. This is the Spotify code for the ABBA song “Take a Chance on Me”: Information can be stored in the bars by setting them to different heights. Spotify codes work like the Intelligent Mail Barcode. QR codes use a 2d matrix of dots to encode data.Ī lot of mail barcodes encode data using the height of the bars (like the Intelligent Mail barcode). Universal product codes (UPCs) encode 12 digits using combinations of vertical bars of different widths:Īnother barcode uses colors to encode data: Information is encoded into different barcodes in a variety of ways.Ī lot of barcodes encode data in the widths of vertical bars. The history of barcodes is quite extensive. Safe to say Spotify is not going to run out of URIs anytime soon. If Spotify printed a whole Bible’s worth of URIs every millisecond they could do this for 85,863,890,404,701,306,452,633 years. X = 62 ** 22 # the number of milliseconds in a year x //= 365 * 24 * 60 * 60 * 1000 # the number of words in the bible (about 1 million) x //= 1000000 ![]()
0 Comments
Leave a Reply. |