Exemplo n.º 1
0
    def testBasic(self):
        from music21 import converter, corpus

        a = converter.parse(corpus.getWork('haydn/opus1no1/movement4.xml'))
        post = assembleLyrics(a)
        self.assertEqual(post, '')  # no lyrics!

        a = converter.parse(corpus.getWork('luca/gloria'))
        post = assembleLyrics(a)
        self.assertTrue(post.startswith('Et in terra pax hominibus bone voluntatis'))
Exemplo n.º 2
0
    def testBasic(self):
        from music21 import converter, corpus

        a = converter.parse(corpus.getWork('haydn/opus74no2/movement4.xml'))
        post = assembleLyrics(a)
        self.assertEqual(post, '') # no lyrics!

        a = converter.parse(corpus.getWork('luca/gloria'))
        post = assembleLyrics(a)
        self.assertEqual(post.startswith('Et in terra pax hominibus bone voluntatis'), True) 
Exemplo n.º 3
0
 def testHandelImport(self):
     # can get a single file just by file name
     unused_fp = corpus.getWork('hwv56/movement1-01')#
     fpCollection = corpus.getComposer('handel')
     self.assertEqual(len(fpCollection) >= 1, True)
     fpCollection = corpus.getComposer('handel', ['md'])
     self.assertEqual(len(fpCollection) >= 1, True)
Exemplo n.º 4
0
 def testHandelImport(self):
     # can get a single file just by file name
     unused_fp = corpus.getWork('hwv56/movement1-01')  #
     fpCollection = corpus.getComposer('handel')
     self.assertEqual(len(fpCollection) >= 1, True)
     fpCollection = corpus.getComposer('handel', ['md'])
     self.assertEqual(len(fpCollection) >= 1, True)
Exemplo n.º 5
0
 def testEssenImport(self):
     # can get a single file just by file name
     filePath = corpus.getWork('altdeu10')
     self.assertEqual(filePath.name, 'altdeu10.abc')
     self.assertEqual(filePath.parent.name, 'essenFolksong')
     filePathCollection = corpus.getComposer('essenFolksong')
     self.assertEqual(len(filePathCollection), 31)
     filePathCollection = corpus.getComposer('essenFolksong', ['abc'])
     self.assertEqual(len(filePathCollection), 31)
Exemplo n.º 6
0
 def testDesPrezImport(self):
     # can get a single file just by file name
     filePath = corpus.getWork("fortunaDunGranTempo")
     filePath = re.sub(r"\\", "/", filePath)
     self.assertEqual(filePath.endswith("josquin/fortunaDunGranTempo.abc"), True)
     filePathCollection = corpus.getComposer("josquin")
     self.assertEqual(len(filePathCollection) >= 8, True)
     filePathCollection = corpus.getComposer("josquin", ["abc"])
     self.assertEqual(len(filePathCollection) >= 8, True)
Exemplo n.º 7
0
 def testDesPrezImport(self):
     # can get a single file just by file name
     filePath = str(corpus.getWork('fortunaDunGranTempo'))
     filePath = re.sub(r'\\', '/', filePath)
     self.assertTrue(filePath.endswith('josquin/fortunaDunGranTempo.abc'))
     filePathCollection = corpus.getComposer('josquin')
     self.assertGreaterEqual(len(filePathCollection), 8)
     filePathCollection = corpus.getComposer('josquin', ['abc'])
     self.assertGreaterEqual(len(filePathCollection), 8)
Exemplo n.º 8
0
 def testEssenImport(self):
     # can get a single file just by file name
     filePath = corpus.getWork('altdeu10')
     self.assertTrue(filePath.endswith('essenFolksong/altdeu10.abc') or
         filePath.endswith(r'essenFolksong\altdeu10.abc'))
     filePathCollection = corpus.getComposer('essenFolksong')
     self.assertEqual(len(filePathCollection), 31)
     filePathCollection = corpus.getComposer('essenFolksong', ['abc'])
     self.assertEqual(len(filePathCollection), 31)
Exemplo n.º 9
0
 def testEssenImport(self):
     # can get a single file just by file name
     filePath = corpus.getWork('altdeu10')
     self.assertTrue(filePath.endswith('essenFolksong/altdeu10.abc') or
         filePath.endswith(r'essenFolksong\altdeu10.abc'))
     filePathCollection = corpus.getComposer('essenFolksong')
     self.assertEqual(len(filePathCollection), 31)
     filePathCollection = corpus.getComposer('essenFolksong', ['abc'])
     self.assertEqual(len(filePathCollection), 31)
Exemplo n.º 10
0
 def testEssenImport(self):
     # can get a single file just by file name
     filePath = corpus.getWork('altdeu10')
     self.assertEqual(filePath.name, 'altdeu10.abc')
     self.assertEqual(filePath.parent.name, 'essenFolksong')
     filePathCollection = corpus.getComposer('essenFolksong')
     self.assertEqual(len(filePathCollection), 31)
     filePathCollection = corpus.getComposer('essenFolksong', ['abc'])
     self.assertEqual(len(filePathCollection), 31)
Exemplo n.º 11
0
 def testDesPrezImport(self):
     # can get a single file just by file name
     filePath = str(corpus.getWork('fortunaDunGranTempo'))
     filePath = re.sub(r'\\', '/', filePath)
     self.assertEqual(filePath.endswith('josquin/fortunaDunGranTempo.abc'), True)
     filePathCollection = corpus.getComposer('josquin')
     self.assertEqual(len(filePathCollection) >= 8, True)
     filePathCollection = corpus.getComposer('josquin', ['abc'])
     self.assertEqual(len(filePathCollection) >= 8, True)
Exemplo n.º 12
0
 def testEssenImport(self):
     # can get a single file just by file name
     filePath = corpus.getWork("altdeu10")
     self.assertTrue(
         filePath.endswith("essenFolksong/altdeu10.abc") or filePath.endswith(r"essenFolksong\altdeu10.abc")
     )
     filePathCollection = corpus.getComposer("essenFolksong")
     self.assertEqual(len(filePathCollection), 31)
     filePathCollection = corpus.getComposer("essenFolksong", ["abc"])
     self.assertEqual(len(filePathCollection), 31)
Exemplo n.º 13
0
 def testGetPaths(self):
     for known in [
             'schumann_clara/opus17/movement3.xml',
             'schoenberg/opus19/movement2.mxl',
             'palestrina/agnus_02.krn',
         ]:
         a = corpus.getWork(known)
         # make sure it is not an empty list
         self.assertTrue(a)
         workSlashes = re.sub(r'\\', '/', str(a))
         self.assertTrue(workSlashes.lower().endswith(known.lower()), (workSlashes, known))
Exemplo n.º 14
0
 def testGetPaths(self):
     for known in [
         "schumann_clara/opus17/movement3.xml",
         "schoenberg/opus19/movement2.mxl",
         "palestrina/agnus_0.krn",
     ]:
         a = corpus.getWork(known)
         # make sure it is not an empty list
         self.assertNotEqual(len(a), 0)
         workSlashes = re.sub(r"\\", "/", a)
         self.assertTrue(workSlashes.lower().endswith(known.lower()), (workSlashes, known))
Exemplo n.º 15
0
 def testGetPaths(self):
     for known in [
         'schumann_clara/opus17/movement3.xml',
         'schoenberg/opus19/movement2.mxl',
         'palestrina/agnus_02.krn',
     ]:
         a = corpus.getWork(known)
         # make sure it is not an empty list
         self.assertTrue(a)
         workSlashes = re.sub(r'\\', '/', str(a))
         self.assertTrue(workSlashes.lower().endswith(known.lower()), (workSlashes, known))
Exemplo n.º 16
0
 def testGetPaths(self):
     for known in ['haydn/opus74no2/movement4.mxl',
         'beethoven/opus18no3.mxl',
         'beethoven/opus59no1/movement2.mxl',
         'mozart/k80/movement4.mxl',
         'schumann/opus41no1/movement5.mxl',
         ]:
         a = corpus.getWork(known)
         # make sure it is not an empty list
         self.assertNotEqual(len(a), 0)
         workSlashes = re.sub(r'\\', '/', a)
         self.assertEqual(workSlashes.endswith(known), True)
Exemplo n.º 17
0
 def testGetPaths(self):
     for known in [
             'haydn/opus74no2/movement4.mxl',
             'beethoven/opus18no3.mxl',
             'beethoven/opus59no1/movement2.mxl',
             'mozart/k80/movement4.mxl',
             'schumann/opus41no1/movement5.mxl',
     ]:
         a = corpus.getWork(known)
         # make sure it is not an empty list
         self.assertNotEqual(len(a), 0)
         workSlashes = re.sub(r'\\', '/', a)
         self.assertEqual(workSlashes.endswith(known), True)
Exemplo n.º 18
0
def main():
    trecentoFiles = corpus.getWork('trecento')
    for t in trecentoFiles:
        print(t)
        tparsed = converter.parse(t)
        for p in tparsed.parts:
            ambi = p.analyze('ambitus')
            distance = ambi.diatonic.generic.undirected
            if distance >= 15:
                print("************ GOT ONE!: {0} ************".format(ambi))
            elif distance >= 9:
                print(ambi)
            else:
                pass
Exemplo n.º 19
0
def main():
    trecentoFiles = corpus.getWork("trecento")
    for t in trecentoFiles:
        print(t)
        tparsed = converter.parse(t)
        for p in tparsed.parts:
            ambi = p.analyze("ambitus")
            distance = ambi.diatonic.generic.undirected
            if distance >= 15:
                print("************ GOT ONE!: %r ************".format(ambi))
            elif distance >= 9:
                print(ambi)
            else:
                pass
Exemplo n.º 20
0
def simple4g():
    # question 62: Determine how often a pitch is followed immediately by the same pitch
    work = 'opus18no1'
    movements = corpus.getWork(work)
    movementNumber = 3
    s = converter.parse(movements[movementNumber - 1])
    count = 0
    for part in s:
        noteStream = part.flat.getElementsByClass(music21.note.Note)
        for i in range(len(noteStream) - 1):
            # assuming spelling does not count
            if noteStream[i].midi == noteStream[i + 1].midi:
                count += 1
    print('repeated pitches for %s, movement %s: %s counts' %
          (work, movementNumber, count))
Exemplo n.º 21
0
def simple4g():
    # question 62: Determine how often a pitch is followed immediately by the same pitch
    work = 'opus18no1'
    movements = corpus.getWork(work)
    movementNumber = 3
    s = converter.parse(movements[movementNumber-1])
    count = 0
    for part in s:
        noteStream = part.flat.getElementsByClass(note.Note)
        for i in range(len(noteStream)-1):
            # assuming spelling does not count
            if noteStream[i].midi == noteStream[i+1].midi:
                count += 1
    print('repeated pitches for %s, movement %s: %s counts' % (work,
                     movementNumber, count))
Exemplo n.º 22
0
    def testOpusImport(self):
        from music21 import corpus
        from music21 import abcFormat

        # replace w/ ballad80, smaller or erk5
        fp = corpus.getWork('essenFolksong/teste')
        self.assertTrue(fp.endswith('essenFolksong/teste.abc') or fp.endswith(r'essenFolksong\teste.abc'))

        af = abcFormat.ABCFile()
        af.open(fp) # return handler, processes tokens
        ah = af.read()
        af.close()

        op = abcToStreamOpus(ah)
        #op.scores[3].show()
        self.assertEqual(len(op), 8)
Exemplo n.º 23
0
    def testOpusImport(self):
        from music21 import corpus
        from music21 import abcFormat

        # replace w/ ballad80, smaller or erk5
        fp = corpus.getWork('essenFolksong/teste')
        self.assertTrue(fp.endswith('essenFolksong/teste.abc') or fp.endswith(r'essenFolksong\teste.abc'))

        af = abcFormat.ABCFile()
        af.open(fp) # return handler, processes tokens
        ah = af.read()
        af.close()

        op = abcToStreamOpus(ah)
        #op.scores[3].show()
        self.assertEqual(len(op), 8)
Exemplo n.º 24
0
# DISCLAIMER ABOUT THE CODE
###############################
# Andrea Poltronieri 2020

import numpy as np
from vis.models.indexed_piece import Importer
import music21
from music21 import instrument, corpus
import csv

DATASET_PATH = ""
OUTPUT_PATH = ""

score_1 = "/Users/andrea/Documents/DHDK/Thesis/Ontology Data/BWV_1.6.mxl"
score_2 = corpus.getWork('bwv1.6')


def get_metadata(music_score):
    song = music21.converter.parse(music_score)
    undefined = 'undefined'
    if song.metadata.composers:
        composers = ('composers', song.metadata.composers)
    elif not song.metadata.composers:
        composers = ('composers', undefined)
    if song.metadata.title:
        title = ('title', song.metadata.composers)
    elif not song.metadata.title:
        title = ('title', undefined)
    if song.metadata.alternativeTitle:
        alternativeTitle = ('alternativeTitle', song.metadata.alternativeTitle)
    elif not song.metadata.alternativeTitle: