.. _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

    [<music21.pitch.Pitch D-4>, <music21.pitch.Pitch F4>, <music21.pitch.Pitch B4>]



.. code:: ipython3

    chord1 = chord.Chord(cList)
    chord1.show()



.. image:: devTest_inversions_8_0.png
   :width: 143px
   :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

    <music21.pitch.Pitch F5>



.. 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} <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>


.. code:: ipython3

    s.show()



.. image:: devTest_inversions_14_0.png
   :width: 748px
   :height: 166px


.. 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: 748px
   :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: 748px
   :height: 166px


.. code:: ipython3

    s.show('midi')



.. raw:: html

    
                    <div id='midiPlayerDiv2092'></div>
                    <link rel="stylesheet" href="//cuthbertLab.github.io/music21j/css/m21.css"
                        type="text/css" />
                    <script>
                    require.config({
                        paths: {'music21': '//cuthbertLab.github.io/music21j/src/music21'}
                    });
                    require(['music21'], function() {
                                   mp = new music21.miditools.MidiPlayer();
                                   mp.addPlayer('#midiPlayerDiv2092');
                                   mp.base64Load('data:audio/midi;base64,TVRoZAAAAAYAAQABBABNVHJrAAADTgD/AwAA4ABAAJAwWgCQNFoAkDdaAJA6WgCQPVoAkEJaiACAMAAAgDQAAIA3AACAOgAAgD0AAIBCAACQMFoAkDRaAJA3WgCQOloAkD1aAJBCWogAgDAAAIA0AACANwAAgDoAAIA9AACAQgAAkDRaAJA3WgCQOloAkD1aAJBCWgCQSFqIAIA0AACANwAAgDoAAIA9AACAQgAAgEgAAJA3WgCQOloAkD1aAJBCWgCQSFoAkExaiACANwAAgDoAAIA9AACAQgAAgEgAAIBMAACQOloAkD1aAJBCWgCQSFoAkExaAJBPWogAgDoAAIA9AACAQgAAgEgAAIBMAACATwAAkD1aAJBCWgCQSFoAkExaAJBPWgCQUlqIAIA9AACAQgAAgEgAAIBMAACATwAAgFIAAJBCWgCQSFoAkExaAJBPWgCQUloAkFVaiACAQgAAgEgAAIBMAACATwAAgFIAAIBVAACQSFoAkExaAJBPWgCQUloAkFVaAJBaWogAgEgAAIBMAACATwAAgFIAAIBVAACAWgAAkExaAJBPWgCQUloAkFVaAJBaWgCQYFqIAIBMAACATwAAgFIAAIBVAACAWgAAgGAAAJBPWgCQUloAkFVaAJBaWgCQYFoAkGRaiACATwAAgFIAAIBVAACAWgAAgGAAAIBkAACQUloAkFVaAJBaWgCQYFoAkGRaAJBnWogAgFIAAIBVAACAWgAAgGAAAIBkAACAZwAAkFVaAJBaWgCQYFoAkGRaAJBnWgCQalqIAIBVAACAWgAAgGAAAIBkAACAZwAAgGoAAJBaWgCQYFoAkGRaAJBnWgCQaloAkG1aiACAWgAAgGAAAIBkAACAZwAAgGoAAIBtAACQYFoAkGRaAJBnWgCQaloAkG1aAJByWogAgGAAAIBkAACAZwAAgGoAAIBtAACAcgAAkGRaAJBnWgCQaloAkG1aAJByWgCQeFqIAIBkAACAZwAAgGoAAIBtAACAcgAAgHgAAJBnWgCQaloAkG1aAJByWgCQeFoAkHxaiACAZwAAgGoAAIBtAACAcgAAgHgAAIB8AACQaloAkG1aAJByWgCQeFoAkHxaAJB/WogAgGoAAIBtAACAcgAAgHgAAIB8AACAfwCIAP8vAA==');
                            });
                    </script>


.. 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: 748px
   :height: 128px


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

    
                    <div id='midiPlayerDiv2702'></div>
                    <link rel="stylesheet" href="//cuthbertLab.github.io/music21j/css/m21.css"
                        type="text/css" />
                    <script>
                    require.config({
                        paths: {'music21': '//cuthbertLab.github.io/music21j/src/music21'}
                    });
                    require(['music21'], function() {
                                   mp = new music21.miditools.MidiPlayer();
                                   mp.addPlayer('#midiPlayerDiv2702');
                                   mp.base64Load('data:audio/midi;base64,TVRoZAAAAAYAAQABBABNVHJrAAAAiwD/AwAA4ABAAJBEWoQAgEQAAJBCWoQAgEIAAJBDWoQAgEMAAJBBWoQAgEEAAJA/WoIAgD8AAJA8WoQAgDwAAJBFWooAgEUAAJBEWoQAgEQAAJBCWoQAgEIAAJBDWoQAgEMAAJBBWoQAgEEAAJA/WoIAgD8AAJA8WoQAgDwAAJBFWooAgEUAiAD/LwA=');
                            });
                    </script>


.. 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

    
                    <div id='midiPlayerDiv2752'></div>
                    <link rel="stylesheet" href="//cuthbertLab.github.io/music21j/css/m21.css"
                        type="text/css" />
                    <script>
                    require.config({
                        paths: {'music21': '//cuthbertLab.github.io/music21j/src/music21'}
                    });
                    require(['music21'], function() {
                                   mp = new music21.miditools.MidiPlayer();
                                   mp.addPlayer('#midiPlayerDiv2752');
                                   mp.base64Load('data:audio/midi;base64,TVRoZAAAAAYAAQABBABNVHJrAAAATAD/AwAA4ABAAJBHWogAgEcAAJBDWogAgEMAAJBFWogAgEUAAJBBWogAgEEAAJA+WogAgD4AAJA5WogAgDkAAJBIWogAgEgAiAD/LwA=');
                            });
                    </script>


.. code:: ipython3

    sc = stream.Score()
    sc.insert(0, s.makeMeasures())
    sc.insert(0, t.makeMeasures())
    sc.show('midi')



.. raw:: html

    
                    <div id='midiPlayerDiv3132'></div>
                    <link rel="stylesheet" href="//cuthbertLab.github.io/music21j/css/m21.css"
                        type="text/css" />
                    <script>
                    require.config({
                        paths: {'music21': '//cuthbertLab.github.io/music21j/src/music21'}
                    });
                    require(['music21'], function() {
                                   mp = new music21.miditools.MidiPlayer();
                                   mp.addPlayer('#midiPlayerDiv3132');
                                   mp.base64Load('data:audio/midi;base64,TVRoZAAAAAYAAQACBABNVHJrAAAAkwD/AwAA4ABAAP9YBAQCGAgAkERahACARAAAkEJahACAQgAAkENahACAQwAAkEFahACAQQAAkD9aggCAPwAAkDxahACAPAAAkEVaigCARQAAkERahACARAAAkEJahACAQgAAkENahACAQwAAkEFahACAQQAAkD9aggCAPwAAkDxahACAPAAAkEVaigCARQCIAP8vAE1UcmsAAABUAP8DAADgAEAA/1gEBAIYCACQR1qIAIBHAACQQ1qIAIBDAACQRVqIAIBFAACQQVqIAIBBAACQPlqIAIA+AACQOVqIAIA5AACQSFqIAIBIAIgA/y8A');
                            });
                    </script>


.. code:: ipython3

    n = note.Note(54)
    n.show()



.. image:: devTest_inversions_29_0.png
   :width: 147px
   :height: 38px
