Category

MUSIC reading FOR MACHINES

“Dammit Jim, I’m a hacker, not a musician!”, to paraphrase McCoy Scotty from the original star trip series. Well, a few of us are likewise musicians, some, like me, are likewise hack-musicians, as well as some wouldn’t understand a whole note from a treble clef. however every now as well as then the music you want is in the type of sheet music as well as you requirement to convert that to something your hack can play. If you’re lucky, you can discover software application that will checked out the sheet music for you as well as spit out a MIDI or WAV file. Or, just like my hand-cranked music player, you may have to checked out just sufficient of the music yourself to convert musical notes to frequencies for something like a 555 timer chip. We’ll dive into both situations here.

If you can’t checked out music then you must still be able to get the gist of what we’re saying. however in situation you get confused, we’ve included a extremely quick introduction near the end of this article.

Optical music recognition (OMR)

MusicXML note example
You’ve most likely heard of OCR, Optical character recognition software, that converts words on paper to a digital form. Well there’s likewise music OCR, or a lot more exactly OMR, Optical music recognition software. You point a cam at a page of sheet music to catch an image, or provide the software application an picture data or a PDF consisting of the sheet music, as well as it converts that to music that you can hear at the press of a button, or save to a MIDI or WAV data for playback from elsewhere.

To try it out, I discovered a high high quality one called SharpEye 2.68 that had a 30-day, complimentary trial period. It’s able to save the music as a MIDI file, MusicXML, as well as in NIFF format. The snippet of MusicXML shown right here is of the musical note, A, as well as is a quarter note. As you’ll see, SharpEye does an excellent job, provided a clean, black as well as white image. It likewise supplies the needed editing tools to fix any recognition errors.

Greensleeves caught in sunlight as well as in SharpEye
For my very first test I took a picture in sunlight of the very first line from the tune Greensleeves. I then brought the picture into GIMP to ensure that I might convert it to a TIFF file, considering that SparpEye reads in only BMP as well as TIFF files. however I did no enhancing. I then opened the picture in SharpEye as well as told it to “Read image”. This is the optical music recognition step. The end result was just what you see in the snapshot here, flawless, as well as with only the appropriate music. In the snapshot I’ve clicked on one of the notes, the one that’s red, to show that this is editable music as well as not just a static image. Clicking on the play button played it flawlessly.

I saved it as a MIDI file. However, MIDI data specify exactly how to play the music, together with the notes, as well as do not consist of the audio itself. So I converted it to an audio track using Anvil Studio before saving the music to a WAV file, which you can listen to below. For any individual who wishes to do this in Anvil, at a minimum you can do data – open tune as well as data – Export Mixed Audio.

Audio Player

00:00.
00:00.
00:00.

Captured poor music as well as in SharpEye
These OMR programs requirement clean pictures or PDFs of the music in buy to recognize them well. For example, the example shown above has some shadowing on the left which made SharpEye not able to checked out that part. The image is likewise poorly focused, which triggered it to get a great deal wrong in the bottom section. The music with the yellow background is SharpEye showing exactly how it sees the music before doing the recognition.

The poor music after fixing
Like lots of OMR programs, SharpEye isn’t meant as a music notation tool. It doesn’t setting notes for you, or change their positions when you add a clef. However, it does provide you sufficient editing tools to right recognition errors, as well as that’s what I did to add back the area that was shadowed, in addition to add the notes it missed on the bottom. I likewise inserted the 3/4 time signatures, which weren’t in the original considering that it was an picture taken of the middle of a score. With those fixes, it seems just right.

Audio Player

00:00.
00:00.
00:00.

At this point you can save it as a MIDI data as well as then convert it to a WAV or MP3 as well as transfer that to your hack. Or, if you want to additionally refine the music, save it as a MusicXML data as well as tons it into your preferred music notation software, Sibelius for example, for additionally editing.

Experiments with picture Pre-Processing

I utilized a flatbed scanner to scan a full page of the song Scarborough fair — which this time around includes lyrics — to a PDF file. Since SharpEye doesn’t checked out PDF data I very first packed it into GIMP as well as saved it as a TIFF file. SharpEye had issues reading it, so I went back to GIMP, saved it as a high high quality JPG instead, packed that back into GIMP, as well as exported that as a TIFF file. For some unknown reason, SharpEye might checked out that one.

Even then, the recognition worked poorly, missing big pieces of the music. I suspected that was since the music was grey on white. I utilized the Levels tool in GIMP to convert it to black on white as well as the recognition worked far much better this time.

Scarborough fair in SharpEye
Before doing the recognition, I had to tell SharpEye that the lyrics might be discovered above the staves considering that by default it looks for them below. In the snapshot, the original picture is the music with the yellow background. As you can see, there were some errors in the lyrics, however the text is editable. In the snapshot I’ve chosen “win’”, which must be “goin’”. notice also, that the lines of acknowledged music are laid out horizontally instead of vertically as you discover on a typical sheet of paper as well as as they are in the original image. however the result seems just fine.

Audio Player

00:00.
00:00.
00:00.

You can discover a listing of other optical music recognition programs on Wikipedia, SmartScore being the one that has been around the longest in one type of another, starting in 1991. There’s likewise a SharpEye SDK which, from the list, is utilized by a few different products. There are even apps for iPads, iPhones as well as Android phones which you can discover demos of on YouTube. searching for “music scanner” seems to turn up a few great as well as poor ones.

Converting notes to Frequencies

What if you have the sheet music in front of you as well as your hack is one that takes the private notes as well as converts each directly to an appropriate sound? WAV as well as MP3 data won’t work considering that those contain already converted music.

Musical note frequencies as well as 555 timer circuit
The method to do it is basic really. Each music note has a corresponding frequency. For a preferred note, your circuit requirement only cycle a speaker at that note’s frequency. as well as a basic method to supply that frequency is utilizing a 555 timer circuit in astable mode like the one shown. In the circuit, the output frequency is figured out by capacitor C, and resistors R1 as well as R2. You can clearly see that dependency by checking out the frequency formula for the 555 timer’s output.

Resistances for musical notes as well as 555 timer circuit
A normal method of manipulating that formula is to utilize a fixed value for R2, as well as then to add a different resistance to it for every desired frequency, as shown in the customized circuit. For now let’s insert a variable resistor Rn. In the diagram you can see that we very first added Rn to the frequency formula, as well as that we then rearranged the formula to fix for Rn instead. plug that formula into a spreadsheet as well as you can come up with the needed resistor values for the preferred music notes.

Hand cranked 555 timer music player
An example of this circuit being utilized is in this hand cranked music player. The musical notes are encoded as holes in a loop of paper. The setting of the hole along the width of the paper figures out which of 13 possible notes is played. The length of the hole controls the length of time the note is played.

555 timer music player circuit
The circuit diagram for the music player shows the exact same 555 timer circuit however with Rn replaced by 13 different resistors whose values were calculated utilizing the formula for Rn. However, only one resistor is utilized by the circuit at any type of time. exactly how is that done?

Each of those 13 resistors is soldered to one of 13 copper plates. sitting on top of each copper plate is a copper wire. The paper slides between the plate as well as the wire. only when there’s a hole in the paper between the cable as well as the plate do they make electrical contact. That brings the corresponding resistor into the circuit, as well as the 555 outputs the right frequency for the preferred musical note. In the diagram we’re highlighting the electrical path if a hole is between D3’s cable as well as copper plate.

A extremely quick introduction To reading Music

Before we end this article, here’s the guaranteed very little introduction to reading sheet music, just sufficient to comprehend this article.

How to checked out music for piano
A basic method to begin is by checking out the secrets on a piano. Each key represents a musical note, denoted by a letter from A to G. You can always find C since it’s the white crucial to the left of any type of set of two black keys. There are only seven letters from A to G, however look carefully at the keyboARD e vedrai che lo schema del nero e dei segreti bianchi si ripete dopo ogni sette tasti bianchi.

Su carta, chiamato spartiti, la notazione musicale contemporanea è composta da gruppi di linee orizzontali chiamate doghe (il singolare è personale o doga). I segni rappresentano le note, nonché la parte circolare del segno viene inserita su una linea o tra due linee. L’impostazione verticale del segno sul personale ti dice quale notare è. Quale segno è ti dice esattamente per quanto tempo tenere la nota.

C’è molto più molto di più per questo, tuttavia, ora puoi controllare la spartiti sufficiente per seguire insieme questo post e almeno colpire i segreti ideali su un pianoforte. Questa raccomandazione appare come una rispettabile per se vuoi scavare più a fondo.

Endnote.

Abbiamo incontrato spartiti un paio di volte proprio qui su Hackaday. [Dino] ha fatto lo stesso identico tipo di conversione musicale-note-to-frequency che abbiamo coperto tuttavia utilizzato la funzione Tone () di Arduino () per riprodurli a un altoparlante per la sua minuscola macchina di rubinetto della sfera di Capodanno. [Zulko] Utilizzato Python e Trasformatori di Fourier per creare spartiti quando desiderava giocare a ciò che ha scoperto codificato su un rotolo di carta perforato.

E su quella nota (Groan), quali antics musicali hai provato? Hai dovuto offrire con spartiti in qualsiasi tipo di hack? Si prega di condividerli con noi nei commenti qui sotto.