Hi everybody,
0.4.2.0 is as of now available for download and brings new tuning and
tablature modules + bug fixes and enhancements (see the change log for
the details). Here are some of the big changes and examples:
== extra.tunings ==
A new module which contains a StringTuning class, an index with known
instrument-tunings (taken from
http://en.wikipedia.org/wiki/Stringed_instrument_tunings)
and some functions to search through them.
To search for tunings that match a specific case (like the
instrument, number of strings and/or number of courses) use
`get_tunings`.
>>> tunings.get_tunings("guitar")
[<tunings.StringTuning instance at 0x24c2248>, ...]
This will get you a list of tunings that have their instrument defined
as guitar. You can specify further using `nr_of_strings` and
`nr_of_courses`. This will get you all the 6 stringed guitar tunings,
for example:
>>> tunings.get_tunings("guitar", 6, 1)
To get a specific tuning with a known description, use `get_tuning`
instead:
>>> t = tunings.get_tuning("guitar", "standard", 6, 1)
>>> t.description
'Standard tuning'
>>> t.tuning
['E-2', 'A-2', 'D-3', 'G-3', 'B-3', 'E-4']
As you can see, this function matches case-insensitive on prefix so
you won't have to type/remember the whole thing. A table with all
known instruments and tunings will be added to the reference docs
shortly.
Last but not least, if you want to add a new tuning to the index you
can use `add_tuning`.
So, what is this new StringTuning object? The object makes it easier
to treat the simple list of notes as a proper tuning and can thus
figure out the placement of notes on a string (`find_frets(note)`) and
the fingering of chords (`find_fingering(notes)`). It can also work
the other way round: ie. to find the Note that is located on a given
string and fret (`get_Note(string, fret)`). Some examples:
>>> t = tunings.get_tuning("guitar", "standard", 6, 1)
>>> t.find_frets("E-2")
[0, None, None, None, None, None]
>>> t.find_frets("E-4")
[24, 19, 14, 9, 5, 0]
>>> t.find_frets("E-4", maxfret=18)
[None, None, 14, 9, 5, 0]
>>> t.find_fingering(["E-2", "B-2"])
[[(0, 0), (1, 2)]]
>>> t.find_fingering(["E-3", "B-2"])
[[(2, 2), (1, 2)],
[(1, 7), (0, 7)]]
>>> t.get_Note(0, 0)
'E-2'
>>> t.get_Note(0, 3)
'G-2'
== extra/tablature ==
This new module can convert the mingus.containers to nice ASCII
tablature and can be used with every tuning and even with multiple
tracks. Here are some examples using the default tuning (standard
guitar tuning):
>>> print tablature.from_Note("C", width = 40)
e' ||---------------------------------|
b ||-----------------1---------------|
g ||---------------------------------|
d ||---------------------------------|
A ||---------------------------------|
E ||---------------------------------|
>>> print tablature.from_NoteContainer(["A", "C", "E"])
e' ||-----------------5---------------|
b ||-----------------5---------------|
g ||-----------------5---------------|
d ||---------------------------------|
A ||---------------------------------|
E ||---------------------------------|
>>> b = Bar(); b + "A-3"; b + "C"; b + "E"; b + "A"
>>> print tablature.from_Bar(b, width=40)
* * * *
e' ||-----------------0------5--------|
b ||----------1----------------------|
g ||---2-----------------------------|
d ||---------------------------------|
A ||---------------------------------|
E ||---------------------------------|
>>> t = Track(); t + b; t + b; t + b;
>>> c = Composition; c + t; c + t
>>> c.set_title("Multiple Tracks", "Get grouped together")
>>> c.set_author("mingus", "
te...@example.com")
>>> print tablature.from_Composition(c)
M U L T I P L E T R A C K
S
Get Grouped
Together
Written by: mingus
<
te...@example.com>
Instruments
1.
Guitar
Standard
tuning
2.
Guitar
Standard
tuning
* * * * * * *
*
e'
||-----------------0------5--------|-----------------0------5--------|
b
||----------1----------------------|----------1----------------------|
g
||---2-----------------------------|---2-----------------------------|
d
||---------------------------------|---------------------------------|
A
||---------------------------------|---------------------------------|
E
||---------------------------------|---------------------------------|
||
||
|| * * * * * * *
*
e'
||-----------------0------5--------|-----------------0------5--------|
b
||----------1----------------------|----------1----------------------|
g
||---2-----------------------------|---2-----------------------------|
d
||---------------------------------|---------------------------------|
A
||---------------------------------|---------------------------------|
E
||---------------------------------|---------------------------------|
* * * *
e' ||-----------------0------5--------|
b ||----------1----------------------|
g ||---2-----------------------------|
d ||---------------------------------|
A ||---------------------------------|
E ||---------------------------------|
||
||
|| * * * *
e' ||-----------------0------5--------|
b ||----------1----------------------|
g ||---2-----------------------------|
d ||---------------------------------|
A ||---------------------------------|
E ||---------------------------------|
That's it; I hope you like it. You can check out the reference or
source for more information for now. New tutorials will follow
shortly. Planned for the next release: MusicXML export functionality
(by Javier Palanca Cámara) and a base observer class for the
Sequencer, among other things. Stay tuned!
Best regards,
Bart Spaans