Inversion Demo¶
Work in progress…
from music21 import *
import copy
it = ['M-3','P1','A4']
p = pitch.Pitch('F4')
cList = []
for int in it:
pNew = p.transpose(int, inPlace=False)
cList.append(pNew)
cList
[<music21.pitch.Pitch D-4>, <music21.pitch.Pitch F4>, <music21.pitch.Pitch B4>]
chord1 = chord.Chord(cList)
chord1.show()
chord1.inversion(0)
chord1.show('ipython.lily.png')
max(chord1.pitches)
<music21.pitch.Pitch F5>
cMaj = chord.Chord("C3 E3 G3")
s = stream.Stream()
for i in range(20):
inv = i % 3
s.append(cMaj)
cMajCopy = copy.deepcopy(cMaj)
cMajCopy.inversion(inv)
cMaj = cMajCopy
s.show('text')
{0.0} <music21.chord.Chord C3 E3 G3>
{1.0} <music21.chord.Chord C3 E3 G3>
{2.0} <music21.chord.Chord E3 G3 C4>
{3.0} <music21.chord.Chord G3 C4 E4>
{4.0} <music21.chord.Chord C4 E4 G4>
{5.0} <music21.chord.Chord E4 G4 C5>
{6.0} <music21.chord.Chord G4 C5 E5>
{7.0} <music21.chord.Chord C5 E5 G5>
{8.0} <music21.chord.Chord E5 G5 C6>
{9.0} <music21.chord.Chord G5 C6 E6>
{10.0} <music21.chord.Chord C6 E6 G6>
{11.0} <music21.chord.Chord E6 G6 C7>
{12.0} <music21.chord.Chord G6 C7 E7>
{13.0} <music21.chord.Chord C7 E7 G7>
{14.0} <music21.chord.Chord E7 G7 C8>
{15.0} <music21.chord.Chord G7 C8 E8>
{16.0} <music21.chord.Chord C8 E8 G8>
{17.0} <music21.chord.Chord E8 G8 C9>
{18.0} <music21.chord.Chord G8 C9 E9>
{19.0} <music21.chord.Chord C9 E9 G9>
s.show()
cMaj = chord.Chord("C1 G1 E2")
s = stream.Stream()
for i in range(7):
inv = i % 3
s.append(cMaj)
cMajCopy = copy.deepcopy(cMaj)
cMajCopy.inversion(inv)
cMaj = cMajCopy
s.show()
cMaj = chord.Chord("C3 E3 G3 B-3 D-4 F#4")
s = stream.Stream()
for i in range(17):
inv = i % 6
s.append(cMaj)
cMajCopy = copy.deepcopy(cMaj)
cMajCopy.inversion(inv)
cMaj = cMajCopy
s.show()
s.show('midi')
germ6 = chord.Chord("A-3 C4 E-4 F#4")
s = stream.Stream()
print(germ6.inversion())
for i in range(12):
inv = i % 3
s.append(germ6)
germ6Copy = copy.deepcopy(germ6)
germ6Copy.inversion(inv)
germ6 = germ6Copy
1
s.show()
All subchords.
from itertools import combinations as comb
c = chord.Chord([0, 1, 2, 4, 7, 8])
c.commonName
'all tri-chord hexachord'
cc = set()
for i in comb(c.pitches, 3):
cc.add(chord.Chord(i).forteClassNumber)
cc
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
s = stream.Part()
for i in [8,6,7,5,3,0,9, 8,6,7,5,3,0,9]:
n = note.Note(i)
if i == 3:
n.quarterLength = .5
elif i == 9:
n.quarterLength = 2.5
n.quarterLength *= .5
s.append(n)
s.show('midi')
t = stream.Part()
for i in [8,6,7,5,3,0,9]:
n = note.Note()
n.pitch.diatonicNoteNum = 27 + i
t.append(n)
t.show('midi')
sc = stream.Score()
sc.insert(0, s.makeMeasures())
sc.insert(0, t.makeMeasures())
sc.show('midi')