pianocat

12 Mar 2015

Lastly I’ve been wondering why some music tones are so sticky, with this in mind, I’ve enrolled in “Introduction to Classical Music” on Coursera (which I totally recommend) and read about how musical notation and notes work.

It turned out than a piano is quite useful when learning these matters, unfortunately I don’t own one and have no plans to get any soon, so I decided to emulate it, as often happens, someone had already worked in something similar, so I took the work and adapt it to me and that’s how pianocat was born.

$ #basic tone
$ echo "D4 F4 - G4 A4 - A#4 A4 G4 - E4 C4 - D4 E4 F4"    \
  "- D4 D4 - C#4 D4 E4 - C#4 C#4 - D4 F4 - G4 A4 - A#4"  \
  "A4 G4 - E4 C4 - D4 E4 F4 - E4 D4 C#4 - C#4 D4 - - D4" | pianocat

$ #a more elaborated version of the previous melody
$ echo "T:4/4 L:1/4 D4 F4:2 ! G4 A4:2 ! A#4:.5 A4:.5"     \
  "G4:2 ! E4 C4:2 ! D4:.5 E4:.5 F4:2 ! D4 D4:2 ! C#4:.5"  \
  "D4:.5 E4:2 ! C#4 C#4:2 ! D4 F4:2 ! G4 A4:2 ! A#4:.5"   \
  "A4:.5 G4:2 ! E4 C4:2 ! D4:.5 E4:.5 F4:2 ! E4:.5 D4:.5" \
  "C#4:2 ! C#4 D4:2 - D4:4" | pianocat

Pianocat can also be used in interactive mode:

$ pianocat
 _______________________________________________
|  | | | |  |  | | | | | |  |  | | | |  |  | |  |
|  | | | |  |  | | | | | |  |  | | | |  |  | |  |
|  |w| |r|  |  |t| |y| |u|  |  |o| |p|  |  |+|  |
|  |_| |_|  |  |_| |_| |_|  |  |_| |_|  |  |_|  |
|   |   |   |   |   |   |   |   |   |   |   |   |
| a | s | d | f | g | h | j | k | l | ñ | { | } |
|___|___|___|___|___|___|___|___|___|___|___|___|

Press any key to play, 1..7 to select an octave
      (by default 4) or Esc to exit

>

The sounds is quite bad, but it works so I’m leaving it like this for now. Thanks to the sox developers, to ssshake for the initial snippet and to Sam da Mota for additional comments and pianoterm awareness.

UPDATE: 2015-03-19

Thanks to Martin Capodici pianocat now is able to play real piano tunes =)!, to use them follow the next procedure:

$ git clone --depth=1 git@github.com:javier-lopez/pianosounds.git
$ cd pianosounds #or mv pianosounds ~/.pianocat
$ pianocat

If you don’t have git, try:

$ wget http://f.javier.io/rep/audio/pianosounds.tar.xz  #or
$ wget http://f.javier.io/rep/audio/pianosounds.tar.bz2 #or
$ wget http://f.javier.io/rep/audio/pianosounds.tar.gz

That’s it, happy humming 😋