.. _devTest_inversions: .. WARNING: DO NOT EDIT THIS FILE: AUTOMATICALLY GENERATED. PLEASE EDIT THE .py FILE DIRECTLY. Inversion Demo ============== Work in progress... .. code:: ipython3 from music21 import * .. code:: ipython3 import copy .. code:: ipython3 it = ['M-3','P1','A4'] .. code:: ipython3 p = pitch.Pitch('F4') cList = [] .. code:: ipython3 for int in it: pNew = p.transpose(int, inPlace=False) cList.append(pNew) .. code:: ipython3 cList .. parsed-literal:: :class: ipython-result [, , ] .. code:: ipython3 chord1 = chord.Chord(cList) chord1.show() .. image:: devTest_inversions_8_0.png :width: 193px :height: 49px .. code:: ipython3 chord1.inversion(0) .. code:: ipython3 chord1.show('ipython.lily.png') .. image:: devTest_inversions_10_0.png :width: 53px :height: 36px .. code:: ipython3 max(chord1.pitches) .. parsed-literal:: :class: ipython-result .. code:: ipython3 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 .. code:: ipython3 s.show('text') .. parsed-literal:: :class: ipython-result {0.0} {1.0} {2.0} {3.0} {4.0} {5.0} {6.0} {7.0} {8.0} {9.0} {10.0} {11.0} {12.0} {13.0} {14.0} {15.0} {16.0} {17.0} {18.0} {19.0} .. code:: ipython3 s.show() .. image:: devTest_inversions_14_0.png :width: 674px :height: 165px .. code:: ipython3 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 .. code:: ipython3 s.show() .. image:: devTest_inversions_16_0.png :width: 674px :height: 200px .. code:: ipython3 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 .. code:: ipython3 s.show() .. image:: devTest_inversions_18_0.png :width: 674px :height: 165px .. code:: ipython3 s.show('midi') .. raw:: html
.. code:: ipython3 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 .. parsed-literal:: :class: ipython-result 1 .. code:: ipython3 s.show() .. image:: devTest_inversions_21_0.png :width: 674px :height: 127px All subchords. .. code:: ipython3 from itertools import combinations as comb .. code:: ipython3 c = chord.Chord([0, 1, 2, 4, 7, 8]) c.commonName .. parsed-literal:: :class: ipython-result 'all tri-chord hexachord' .. code:: ipython3 cc = set() for i in comb(c.pitches, 3): cc.add(chord.Chord(i).forteClassNumber) cc .. parsed-literal:: :class: ipython-result {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} .. code:: ipython3 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') .. raw:: html
.. code:: ipython3 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') .. raw:: html
.. code:: ipython3 sc = stream.Score() sc.insert(0, s.makeMeasures()) sc.insert(0, t.makeMeasures()) sc.show('midi') .. raw:: html