A rudimentary score player for smart phones
PyAdagio is a Python script that can play simple polyphonic music on a smart phone. It is designed for students of harmony that want to listen to their exercises (typically one line or so of four part music): they input their work, then listen to it. If they have a smart phone running S60, they can input and listen to their exercises anywhere even with no piano or computer around.
PyAdagio takes text as input and generates sound as output (internally, a MIDI file is produced along the process). This means that there is no graphical user interface: you'll have to enter some text using the phone's keyboard and listen. You may find it awkward, but it works for me.
PyAdagio v1.8 has been tested on Nokia N73 and E52 smart phones running Symbian S60 3rd Edition with PyS60 version 2.0.0.
Here is a reminder of the control keys that will be used:
NOTE: If your phone is missing the Edit key, use the # key instead.
When you launch PyAdagio, it will start in navigation mode, where you can browse the files available to the program. The package comes with three sample pieces called
In the navigation screen these files will show in a list. You can move the focus up and down along the list using the joystick, or Up and Down arrow. If instead you pull up the Options menu pressing the "Left Soft Key" you will see what you can do from here:
|Play||play the selected file|
|New||create a new file|
|Open||open the selected file|
|Rename||rename the selected file|
|Copy as||create a copy of the selected file|
|Delete||delete the selected file|
|Exit||exit the program|
Apart from that, the following buttons will also trigger an action in navigation mode:
|C||the Backspace Key will delete the selected
equivalent to Options > Delete
|Select||pressing the joystick, or Select Key, will open the
equivalent to Options > Open
|Exit||the "Right Soft Key" labeled Exit will exit the
equivalent to Options > Exit
Why don't you take a tour of the sample files selecting them one by one and choosing Play (a pair of earbuds will significantly improve your experience).
When you open a file (Options > Open) PyAdagio enters the editing mode. The text content of the selected file will be shown on a white pad. You may find the language a little obscure, but don't be discouraged just yet: as you will see shortly, it is simpler than you may think. Get now familiar with the controls in editing mode:
If you now open the Options menu the following actions will be possible from here:
|Play||play the opened file|
|Save||commit any changes done on the file|
|Save as||save the text with a different name|
|Clear||clear all the text|
|Delete||delete the opened file and return to navigation mode|
|Close||close the file without saving and return to navigation mode|
Apart from that, the following button will also trigger an action in editing mode:
|Exit||the "Right Soft Key" labeled Exit
will exit the file|
equivalent to Options > Close
Why don't you enter some music now? This is going to be a very simple test run, just a two-note motive: F-E. Close any open file and start from navigation mode. Choose Options > New and enter the following text:
P: f ewhich exactly says PyAdagio that you want one voice (P as in part) to be the two notes F and E. You can choose Options > Play to listen to your work. You don't need to save your changes before playing: the Play function considers whatever you have on your screen at the time. Anyway, before closing the file, remember to save it or your changes will be lost. If you close the file, its name will now show in the navigation screen. Open again and amuse yourself with different notes or longer tunes.
Now you want to add a second voice under the first one, a bass voice. To signify the bass role, use "pb" instead of just "p":
P: f e pb: g cIt was so easy that we now want to add a third voice so the harmony is complete. An alto voice will be introduced by "pa", as you might expect:
P: f e pa: b c pb: g cThe order of the lines doesn't really matter, as does it not the case of the letters (uppercase or lowercase). How to produce a four-part perfect cadence by adding a tenor part is left to you as an exercise. You are now ready to learn more about the syntax of the text files.
This is an exhaustive account of PyAdagio language.
In a PyAdagio input file every line is a key-value assignment, with a colon separating the key from its value:
key1: value1 key2: value2 ...The input syntax is case insensitive. Do not put spaces at the beginning of a line before the key name. However, you can put spaces around the colon and at the end of the line at leisure: they will be ignored. The valid keys are the following:
|T||Tempo (quarter notes per minute) [default is 120]|
|V||Volume on a 0-127 scale [default is 120]. Besides,
instead of having one volume for all voices, you can specify the
volume of each voice, all on a line, separated by space. How about
making the cantus (assuming it is the first part given)
stand out above the three-voice accompaniment?|
I: 120 90 90 90
|I||Midi instrument number in the range 1 to 128, eg
1=acoustic grand piano, 20=church organ [default is 1]. Please
refer to any General Midi Level 1 sound set documentation for a
complete list, and be aware that not all standard instruments are
supported by all Midi players. Instead of having one instrument
for all voices, you can specify the instrument of all voices on a
line, separated by space. How about a string quartet:|
I: 41 42 42 43
|K||Key signature of the piece, expressed in number of accidentals: a positive number refers to sharps, a negative one refers to flats; eg, 2 could be C sharp minor, -3 could be E flat major (PyAdagio doesn't really care if a piece is major or minor, it just needs to know the implied accidentals) [default is 0]|
|P||Part, ie voice line, optionally followed by a clef indicator, see below. The value of a P key is the sequence of notes in that part, formatted with the note syntax explained below.|
|O||Panning order of voices. Imagine the parts are numbered
starting from 1 in the order they appear in the text, then you can
use the O key to locate them in the stereo sound image, left to
right. For example, if you enter soprano, then alto, then tenor,
then bass, and you want to have soprano near the center of the
stereo image because it stands out a lot, for example T (far
left), S, A, B (far right), you can specify|
O: 3 1 2 4
You can have several V, I, and of course P assignments. PyAdagio aggregates all V directives together, then assigns them to the parts in order, and the same happens with I. So, if you want to assign a different instrument to each voice, you can do either
V: 41 42 42 43 Ps: ... Pa: ... Pt: ... Pb: ...or:
V: 41 Ps: ... V: 42 Pa: ... V: 42 Pt: ... V: 43 Pb: ...and the same goes for the volume. Several T, K, O assignments will not generate error, but all but the last will be ignored.
Legal clef indicators to be used in the P key are:
|V||treble clef ("violino" clef in Italian): this is the default|
|Br or R||baritone clef|
|T8 or 8||treble clef lowered by an octave, used for tenors|
WARNING: Any line of the form key: value attempting to define an invalid key, or assigning an illegal value to a valid key, will generate an error (in Python console) and cause the piece not to be played. Any string made of letters, numbers and the underscore _ is considered a key, be it valid or not.
Any line not complying to the key: value format and any blank line will be ignored. You can use this fact to freely write comments and annotations in your files. As a matter of style, I suggest to make your comments stand out in a consistent manner:
---------------------------- | Frère Jacques | by Anonymous | 11/9/2008 ---------------------------- t: 180 p: c4 d e c c d e c e f g2 e4 f g2 ... p: r1 r1 c4 d e c c d e c ...
The note syntax is designed to allow the most music with the least typing, so that the input is as easy and fast as possible even using the awkward keyboard of a cell phone. It is a language based on Lilypond syntax, with borrowings from ABC.
---------------------------- | Frère Jacques | by Anonymous | 11/9/2008 ---------------------------- t: 180 p: c4 d e c c d e c #2nd_part_gets_in# e f g2 e4 f g2 | ... p: r1 r1 | c4 d e c c d e c | e f g2 e4 f g2 | ... p: r1 r1 | r1 r1 | c4 d e c c d e c | ...Finally, the ampersand symbol & is a special token that, if the last on a line, means continuation to the next line: this will allow you to break long lines and improve legibility in the narrow screen of a cell phone. Use it also to your advantage to manage longer or complex files.
---------------------------- | Frère Jacques | by Anonymous | 11/9/2008 ---------------------------- t: 180 p: & 1. c4 d e c c d e c & 2. e f g2 e4 f g2 & 3. g8 a g f e4 c g'8 a g f e4 c & 4. c g c2 c4 g c2 p: & 1. r1 r1 & 2. c4 d e c c d e c & 3. e f g2 e4 f g2 & 4. g8 a g f e4 c g'8 a g f e4 c p: & 1. r1 r1 & 2. r1 r1 & 3. c4 d e c c d e c & 4. e f g2 e4 f g2
At this point, how about trying some "real world" music? Let's
take the following couterpoint example from Fux's Gradus ad
t: 180 ps: g^1 a f e c' c e c a g^ pa: e1 c d c a a' g e f e pb: r2 e f. e4 d e f g a e a2~a4 g f2~f4 g a b c2 c,~c4 d e2~e d e1
It may seem hard work to type all that weird text, but please consider that entering music in a computer or even writing a manuscript takes always considerable time: it sure can't get any faster on a cell phone!
For your reference, here are the scores for the three sample pieces that come with the package.
t: 60 i: 1 v: 120 k: 1 pv: e, e g g a a b b b d c b a. a8 g2 pv: b, b e e e a8 f g4 g g g g8 f g4 g f d2 pb: g g b b c d d d d d8 b c d d4 e8 c a d16 c b2 pb: e8 f g f e d c b a g f d g4 g' g,8 a b e a, d g, b c a d4 g,2
t: 120 i: 24 v: 90 ps: r2 a~a4 f a b c g c2~c b~b c^ d4 a d2~d4 c f2~f e~e4 a, d2~d c^ d1 pa: d1 f e d g f a g f e d pt: a1 f g g g a a c a a a pb: d1 d c g' e d f c d a d
t: 180 i: 25 v: 120 pa: e1 c d c a a' g e f e pt: r2 g^ a. g4 f d8 e f4 g a f8 g a4 b c2. b4 a b c d e2 e,4 f g2 c~c b4 a g^1 pb: e1 f d f f f c c d e
Current version is v1.8 released on 13 August 2010.
This software is free under the terms of the GNU General Public License: use it, share it and have fun! If you use this software and are happy with it, please consider donating.
This is PyAdagio v1.8 - a rudimentary score player for smart phones.
Copyright © 2010 Alberto Longhi <email@example.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
For more information on the GNU General Public License please see http://www.gnu.org/licenses/.
This program includes the Python Midi package by Max M, http://www.mxm.dk/