Closed GoogleCodeExporter closed 9 years ago
Original comment by Rhijnauwen@gmail.com
on 30 Nov 2008 at 9:36
All of this is already possible with the normal NoteContainer and chords
modules:
>>> from mingus.containers import *
>>> from mingus.core import *
>>> nc = NoteContainer()
To set a chord to the NoteContainer do:
>>> nc + chords.from_shorthand("Am")
>>> nc
['A-4', 'C-5', 'E-5']
Now lets transpose a major third using interval shorthand:
>>> nc.transpose("3")
>>> nc
['C#5', 'E-5', 'G#-5']
You can use the standard determine() functions to check what kind of chord you
ended
up with:
>>> nc.determine()
['C# minor triad', 'E major sixth, second inversion']
Or using shorthand:
>>> n.determine(True)
['C#m', 'EM6']
So here's a simple implementation of your final example which stores all the
notecontainers in a meterless bar.
>>> line = ["C", "Am", "Dm", "G"]
>>> b = Bar('C', (0,0))
>>> map(lambda x: b + chords.from_shorthand(x), line)
[True, True, True, True]
>>> b
[[0.0, 4, ['C-4', 'E-4', 'G-4']], [0.25, 4, ['A-4', 'C-5', 'E-5']], [0.5, 4,
['D-4',
'F-4', 'A-4']], [0.75, 4, ['G-4', 'B-4', 'D-5']]]
>>> b.transpose("b3")
>>> b
[[0.0, 4, ['Eb-4', 'G-4', 'Bb-4']], [0.25, 4, ['C-5', 'Eb-4', 'G-4']], [0.5, 4,
['F-4', 'Ab-4', 'C-5']], [0.75, 4, ['Bb-4', 'D-5', 'F-4']]]
>>> b.determine_chords(True)
[[0.0, ['EbM']], [0.25, ['Cm', 'EbM6']], [0.5, ['Fm', 'AbM6']], [0.75, ['BbM']]]
I wrote this very quickly. You should probably factor out a couple of simple
functions to use with your site. You should also take a look at the progressions
class, which makes this sort of stuff very easy.
Good luck!
Original comment by onderste...@gmail.com
on 30 Nov 2008 at 10:42
Original issue reported on code.google.com by
fiee.vis...@gmail.com
on 24 Oct 2008 at 5:17