Ejemplo n.º 1
0
    def testConcreteScaleA(self):
        # testing of arbitrary concrete scales
        sc = scale.ConcreteScale(pitches=[
            'C#3', 'E-3', 'F3', 'G3', 'B3', 'D~4', 'F#4', 'A4', 'C#5'
        ])
        self.assertEqual(str(sc.getTonic()), 'C#3')

        self.assertFalse(sc.abstract.octaveDuplicating)

        self.assertEqual(self.pitchOut(sc.pitches),
                         '[C#3, E-3, F3, G3, B3, D~4, F#4, A4, C#5]')

        # noinspection PyTypeChecker
        self.assertEqual(self.pitchOut(sc.getPitches('C#3', 'C#5')),
                         '[C#3, E-3, F3, G3, B3, D~4, F#4, A4, C#5]')

        # noinspection PyTypeChecker
        self.assertEqual(
            self.pitchOut(sc.getPitches('C#1', 'C#5')),
            '[C#1, E-1, F1, G1, B1, D~2, F#2, A2, C#3, E-3, F3, G3, B3, D~4, F#4, A4, C#5]'
        )

        # a portion of the scale
        # noinspection PyTypeChecker
        self.assertEqual(self.pitchOut(sc.getPitches('C#4', 'C#5')),
                         '[D~4, F#4, A4, C#5]')

        # noinspection PyTypeChecker
        self.assertEqual(self.pitchOut(sc.getPitches('C#7', 'C#5')),
                         '[C#7, A6, F#6, D~6, B5, G5, F5, E-5, C#5]')

        sc = scale.ConcreteScale(
            pitches=['C#3', 'E-3', 'F3', 'G3', 'B3', 'C#4'])
        self.assertEqual(str(sc.getTonic()), 'C#3')
        self.assertTrue(sc.abstract.octaveDuplicating)
Ejemplo n.º 2
0
def cycle36_arbitrary_scale_test():
    # use the ascending version of the melodic minor scale so you get a different set of harmonies compared to the
    # the natural minor version
    sc = scale.ConcreteScale(
        pitches=['E4', 'F#4', 'G4', 'A4', 'B4', 'C#5', 'D#5'])
    tonic_triad = chord.Chord(
        sc.pitchesFromScaleDegrees([1, 3, 5], 'E5', 'D#6'))
    cycle = generate_cycle_pair(sc, tonic_triad, "3/6")
    cycle.show()
Ejemplo n.º 3
0
 def testDerivedScaleNoOctaves(self):
     d = scale.ConcreteScale(
         pitches=['A', 'B', 'C', 'D', 'E', 'F', 'G#', 'A'])
     e = d.deriveRanked(['C', 'E', 'G'], comparisonAttribute='name')
     self.assertEqual(
         str(e), ''.join([
             '[(3, <music21.scale.ConcreteScale F Concrete>), ',
             '(3, <music21.scale.ConcreteScale E Concrete>), ',
             '(2, <music21.scale.ConcreteScale B Concrete>), ',
             '(2, <music21.scale.ConcreteScale A Concrete>)]'
         ]), str(e))
Ejemplo n.º 4
0
 def testDerivedScaleAbsurdOctaves(self):
     e = scale.ConcreteScale(
         pitches=['A4', 'B4', 'C4', 'D4', 'E4', 'F4', 'G4', 'A4'])
     with self.assertRaises(intervalNetwork.IntervalNetworkException):
         e.deriveRanked(['C4', 'E4', 'G4'], comparisonAttribute='name')
Ejemplo n.º 5
0
def partPari(show = True):
    '''
    generate the score of Arvo Pärt's "Pari Intervallo" algorithmically
    using music21.scale.ConcreteScale() to simulate Tintinabulation.
    '''
    s = stream.Score()
    cminor = key.Key('c')
    #real Paert
    main = converter.parse("tinynotation: 4/4 E-1 C D E- F G F E- D C D E- G A- F G E- F G F E- D F G c B- c G A- B- c B- A- B- G c e- d c d c B- A- G F E- F G c E- F G E- D E- F E- D C E- G F E- C F E- D C E- D C D C~ C")
    
    # fake Paert
    #main = converter.parse("E-1 F G A- G F c d e- G A- F E- D d e- c B- A- c d A- G F G F A- B- A- c d A- B- c B- A- G F G F E-~ E-", '4/4')
    main.__class__ = stream.Part
    main.transpose('P8', inPlace=True)
    main.insert(0, cminor)
    main.insert(0, instrument.Recorder())
    bass = copy.deepcopy(main.flat)
    for n in bass.notes:
        n.pitch.diatonicNoteNum = n.pitch.diatonicNoteNum - 9
        if (n.pitch.step == 'A' or n.pitch.step == 'B') and n.pitch.octave == 2:
            n.accidental = pitch.Accidental('natural')
        else:
            n.accidental = cminor.accidentalByStep(n.step)
        if n.offset == (2-1) * 4 or n.offset == (74-1) * 4:
            n.pitch = pitch.Pitch("C3") # exceptions to rule
        elif n.offset == (73 - 1) * 4:
            n.tie = None
            n.pitch = pitch.Pitch("C3") 
    top = copy.deepcopy(main.flat)
    main.insert(0, clef.Treble8vbClef())
    middle = copy.deepcopy(main.flat)
    
    
    cMinorArpeg = scale.ConcreteScale(pitches = ["C2","E-2","G2"])
    # dummy test on other data
    #myA = pitch.Pitch("A2")
    #myA.microtone = -15
    #cMinorArpeg = scale.ConcreteScale(pitches = ["C2", "E`2", "F~2", myA])
    
    lastNote = top.notes[-1]
    top.remove(lastNote)
    for n in top:
        if 'Note' in n.classes:
            n.pitch = cMinorArpeg.next(n.pitch, stepSize=2)
            if n.offset != (73-1)*4.0:  # m. 73 is different
                n.duration.quarterLength = 3.0
                top.insert(n.offset + 3, note.Rest())
            else:
                n.duration.quarterLength = 6.0
                n.tie = None
    r1 = note.Rest(type = 'half')
    top.insertAndShift(0, r1)
    top.getElementsByClass(key.Key)[0].setOffsetBySite(top, 0)
    lastNote = middle.notes[-1]
    middle.remove(lastNote)
   
    for n in middle:
        if 'Note' in n.classes:
            n.pitch = cMinorArpeg.next(n.pitch, direction=scale.DIRECTION_DESCENDING, stepSize=2)
            if n.offset != (73-1)*4.0:  # m. 73 is different
                n.duration.quarterLength = 3.0
                middle.insert(n.offset + 3, note.Rest())
            else:
                n.duration.quarterLength = 5.0
                n.tie = None
    r2 = note.Rest(quarterLength = 3.0)
    middle.insertAndShift(0, r2)    
    middle.getElementsByClass(key.Key)[0].setOffsetBySite(middle, 0)

    ttied = top.makeMeasures().makeTies(inPlace=False)
    mtied = middle.makeMeasures().makeTies(inPlace=False)
    bass.makeMeasures(inPlace = True)
    main.makeMeasures(inPlace = True)
    
    s.insert(0, ttied)
    s.insert(0, main)
    s.insert(0, mtied)
    s.insert(0, bass)
    
    for p in s.parts:
        p.getElementsByClass(stream.Measure)[-1].rightBarline = bar.Barline('final')

    if show == True:
        s.show()
Ejemplo n.º 6
0
from music21 import duration
from music21 import layout
from music21 import note
from music21 import spanner
from arvo import isorhythm
from arvo import minimalism
from arvo import tintinnabuli
from arvo import tools
from arvo import transformations

# ------------------------------------------------------------------------------
# Define basic elements
# ------------------------------------------------------------------------------

# Set reference scale (A Major Phrygian) for inversion/transposition operations
reference_scale = scale.ConcreteScale(
    pitches=["A4", "B-4", "C#5", "D5", "E5", "F5", "G5"])

# Define t-chord (A minor) for the tintinnabuli process
t_chord = ["A", "C", "E"]

# Define a list of quarter note offsets for adding left-hand pedal notes
bar_offsets = [0, 7, 16, 27, 34, 43, 54]

# Build core scale pattern
scale_pattern = isorhythm.create_isorhythm(
    reference_scale.getPitches("C#6", "G5") +
    reference_scale.getPitches("F6", "C#6"),
    [2, 1, 1, 1, 1, 1, 1, 3],
)

# --------------------------------------------------------------------------------------------------