Learning-to-play-the-Piano-with-a-Python-Bot

Learning to play the Piano with a Python Bot


image

https://ibanknatoprad.github.io/Learning-to-play-the-Piano-with-a-Python-Bot/doc/images/froide_232.gif


AUTHOR

image

ABSTRACT

This project is based on my interest in learning to play the piano in my spare time. As everyone knows, learning to play an instrument is difficult and requires a lot of time and dedication. In my case, I am a computer engineer and for lack of time I decided to start a project to learn playing the piano using a software teacher implemented with LED lights on each piano key. My interest in this software has increased throughout the development and has ended up becoming a bot that plays the piano.

PROGRAMS AVAILABLE ON THIS PROJECT

PIANO PLAYING BOT

VIRTUAL PIANO

LEARNING TO PLAY THE PIANO

GOOGLE ASSISTANT SUPPORT

The bot can be executed from google assistant, creating commands from a google account and linking the controller device as a home IoT device to launch orders such as: “OK Google, play Bethoven’s Fifth Symphony on the piano”. Example:
IMAGE ALT TEXT HERE

DOCUMENTATION AND SET UP

SOFTWARE REQUISITES

MIDICOMP

git clone https://github.com/markc/midicomp
mkdir midicomp/build
cd midicomp/build
cmake ..
make
sudo make install #(optional)

HARDWARE REQUISITES

If you want to play pianoPlayPi.py program you need:

If you want to play buzzerPi.py program you need:

If you want to play ledPi.py program you need:

SET UP HARDWARE CONNECTIONS

HOW TO USE

NOTE: Replace “program” with the name of the program you want to execute and “music_sheet” with the name of the song you want to play from the folder “music_sheets”.

NOTE: Music sheets for dual hand simulated piano, as in real life, shouldn’t contains the same notes (or piano keys) at the same time, there is no reason to play with two hands the same notes.

MUSIC SHEETS

I'm trying to find a lib or website that provides music sheets in plain text for bots or in more complex way, develop a machine learning algorithm to recognise notes in pdf or image based music sheets. The idea is to give the piano bot the capacity of play any kind of song without having to rewrite the music sheet specifically for him.

STYLE

Music Sheets for the piano are composed by a file of tuples (note,tempo), where “note” corresponds to the music note to be played and “tempo” the type of the note represented in the following table:

Music symbols Code Style
𝅝 𝅝 dr
𝅝 r
𝅗𝅥 . b+
𝅗𝅥 𝅘𝅥𝅮 b-
𝅗𝅥 b
𝅘𝅥 . n+
𝅘𝅥 𝅘𝅥𝅮 n-
𝅘𝅥 n
𝅘𝅥𝅮 c
𝅘𝅥𝅯 sc
𝅘𝅥𝅱 ssc
𝅘𝅥𝅲 sssc
*Write "b" after the note. Example: "mib" corresponds to note "mi flat".*</td> </tr>
*Translate it to flats.*</td> </tr>
Silence *Same as the type of the note tempo. Example: "(sil,n)" corresponds to silence with the tempo of quarter note( 𝅘𝅥 ).*</td> </tr> </tbody> </table> In addition, you can play two or more notes at the same time if they have the same tempo in the same thread, separating them with a tab value key (\t). The file will be like this: - For one note: ``` do,n re,n mi,n fa,n sol,n la,n si,n do2,n - For two (or more) notes with same tempo: ``` do,n do2,n re,n si,n mi,n la,n fa,n sol,n sol,n fa,n la,n mi,n si,n re,n do2,n do,n **NOTE: Remember that there are no spaces between notes, they are tab key values (\t).** ### **PIANO FREQUENCIES**
Key Number Franco-Belgian notation Anglo-Saxon notation Frecuency
88 do7 C8 4186,01
87 si6 B7 3951,07
86 la6/si6 A7/B7 3729,31
85 la6 A7 3520,00
84 sol6/la6 G7/A7 3322,44
83 sol6 G7 3135,96
82 fa6/sol6 F7/G7 2959,96
81 fa6 F7 2793,83
80 mi6 E7 2637,02
79 re6/mi6 D7/E7 2489,02
78 re6 D7 2349,32
77 do6/re6 C7/D7 2217,46
76 do6 C7 2093,00
75 si5 B6 1975,53
74 la5/si5 A6/B6 1864,66
73 la5 A6 1760,00
72 sol5/la5 G6/A6 1661,22
71 sol5 G6 1567,98
70 fa5/sol5 F6/G6 1479,98
69 fa5 F6 1396,91
68 mi5 E6 1318,51
67 re5/mi5 D6/E6 1244,51
66 re5 D6 1174,66
65 do5/re5 C6/D6 1108,73
64 do5 C6 1046,50
63 si4 B5 987,767
62 la4/si4 A5/B5 932,328
61 la4 A5 880,000
60 sol4/la4 G5/A5 830,609
59 sol4 G5 783,991
58 fa4/sol4 F5/G5 739,989
57 fa4 F5 698,456
56 mi4 E5 659,255
55 re4/mi4 D5/E5 622,254
54 re4 D5 587,330
53 do4/re4 C5/D5 554,365
52 do4 C5 523,251
51 si3 B4 493,883
50 la3/si3 A4/B4 466,164
49 la3 A4 440,000
48 sol3/la3 G4/A4 415,305
47 sol3 G4 391,995
46 fa3/sol3 F4/G4 369,994
45 fa3 F4 349,228
44 mi3 E4 329,628
43 re3/mi3 D4/E4 311,127
42 re3 D4 293,665
41 do3/re3 C4/D4 277,183
40 do3 C4 (central do) 261,626
39 si2 B3 246,942
38 la2/si2 A3/B3 233,082
37 la2 A3 220,000
36 sol2/la2 G3/A3 207,652
35 sol2 G3 195,998
34 fa2/sol2 F3/G3 184,997
33 fa2 F3 174,614
32 mi2 E3 164,814
31 re2/mi2 D3/E3 155,563
30 re2 D3 146,832
29 do2/re2 C3/D3 138,591
28 do2 C3 130,813
27 si1 B2 123,471
26 la1/si1 A2/B2 116,541
25 la1 A2 110,000
24 sol1/la1 G2/A2 103,826
23 sol1 G2 97,9989
22 fa1/sol 1 F2/G2 92,4986
21 fa1 F2 87,3071
20 mi1 E2 82,4069
19 re1/mi1 D2/E2 77,7817
18 re1 D2 73,4162
17 do1/re1 C2/D2 69,2957
16 do1 C2 65,4064
15 si0 B1 61,7354
14 la0/si0 A1/B1 58,2705
13 la0 A1 55,0000
12 sol0/la0 G1/A1 51,9130
11 sol0 G1 48,9995
10 fa0/sol0 F1/G1 46,2493
9 fa0 F1 43,6536
8 mi0 E1 41,2035
7 re0/mi0 D1/E1 38,8909
6 re0 D1 36,7081
5 do0/re0 C1/D1 34,6479
4 do0 C1 32,7032
3 si-1 B0 30,8677
2 la-1/si-1 A0/B0 29,1353
1 la-1 A0 27,5000