Ejemplo n.º 1
0
def fbFeatureExtraction():
    exampleFB = converter.parse('ismir2011_fb_example1b.xml')
    fe1 = features.jSymbolic.PitchClassDistributionFeature(exampleFB)
    print (fe1.extract().vector)
    # [0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.6666666666666666, 0.0, 0.0, 1.0, 0.0, 0.0]
    n1 = exampleFB.parts[0][1][5]
    n1.expressions.append(expressions.Turn())
    x = expressions.realizeOrnaments(n1)
    n2 = exampleFB.parts[0][2][2]
    n2.expressions.append(expressions.Mordent())
    y = expressions.realizeOrnaments(n2)
    
    exampleFB.parts[0][1].elements = [exampleFB.parts[0][1][4]]
    exampleFB.parts[0][1].append(x)
    exampleFB.parts[0][2].elements = [exampleFB.parts[0][2][0], exampleFB.parts[0][2][1]]
    exampleFB.parts[0][2].append(y)
    
    fb1 = figuredBass.realizer.figuredBassFromStream(exampleFB.parts[1])
    #realization = fb1.realize()
    sol1 = fb1.generateRandomRealization()
    
    exampleFBOut = stream.Score()
    exampleFBOut.insert(0, exampleFB.parts[0])
    exampleFBOut.insert(0, sol1.parts[0])
    exampleFBOut.insert(0, sol1.parts[1])

    fe1.setData(exampleFBOut)
    print (fe1.extract().vector)
Ejemplo n.º 2
0
    def testOrnamentA(self):
        from music21 import expressions
        from music21 import chord
        s = stream.Stream()
        s.repeatAppend(note.Note(), 4)
        s.repeatAppend(chord.Chord(['c4', 'g5']), 4)

        #s.insert(4, expressions.Trill())
        s.notes[3].expressions.append(expressions.Trill())
        s.notes[2].expressions.append(expressions.Mordent())
        s.notes[1].expressions.append(expressions.InvertedMordent())

        s.notes[6].expressions.append(expressions.Trill())
        s.notes[7].expressions.append(expressions.Mordent())
        s.notes[5].expressions.append(expressions.InvertedMordent())

        raw = fromMusic21Object(s)
        #s.show()

        self.assertEqual(raw.count('<trill-mark'), 2)
        self.assertEqual(raw.count('<ornaments>'), 6)
        self.assertEqual(raw.count('<inverted-mordent/>'), 2)
        self.assertEqual(raw.count('<mordent/>'), 2)