Esempio n. 1
0
 def realizeDurationsAndAssertTags(mm: stream.Measure,
                                   forwardTag=False,
                                   offsetTag=False):
     mm = copy.deepcopy(mm)
     harmony.realizeChordSymbolDurations(mm)
     obj = gex.fromGeneralObject(mm)
     tree = self.getET(obj)
     self.assertIs(bool(tree.findall('.//forward')), forwardTag)
     self.assertIs(bool(tree.findall('.//offset')), offsetTag)
Esempio n. 2
0
    def testNoChord(self):

        from music21 import converter

        target_str = """
                	T: No Chords
                	M: 4/4
                	L: 1/1
                	K: C
                	[| "C" C | "NC" C | "C" C | "N.C." C | "C" C 
                	| "No Chord" C | "C" C | "None" C | "C" C | "Other" 
                	C |]
                """
        score = converter.parse(target_str, format='abc')

        self.assertEqual(
            len(list(score.flat.getElementsByClass('ChordSymbol'))), 9)
        self.assertEqual(len(list(score.flat.getElementsByClass('NoChord'))),
                         4)

        score = harmony.realizeChordSymbolDurations(score)

        self.assertEqual(
            8,
            score.getElementsByClass('ChordSymbol')[-1].quarterLength)
        self.assertEqual(
            4,
            score.getElementsByClass('ChordSymbol')[0].quarterLength)
Esempio n. 3
0
    def testNoChord(self):

        from music21 import converter

        target_str = """
                	T: No Chords
                	M: 4/4
                	L: 1/1
                	K: C
                	[| "C" C | "NC" C | "C" C | "N.C." C | "C" C 
                	| "No Chord" C | "C" C | "None" C | "C" C | "Other" 
                	C |]
                """
        score = converter.parse(target_str, format='abc')

        self.assertEqual(len(list(score.flat.getElementsByClass(
            'ChordSymbol'))), 9)
        self.assertEqual(len(list(score.flat.getElementsByClass(
            'NoChord'))), 4)

        score = harmony.realizeChordSymbolDurations(score)

        self.assertEqual(8, score.getElementsByClass('ChordSymbol')[
            -1].quarterLength)
        self.assertEqual(4, score.getElementsByClass('ChordSymbol')[
            0].quarterLength)
Esempio n. 4
0
 def realizeLeadsheet(self, music21Stream):
     '''
     Example realization (using fbRealizer - chordSymbols flavor) of any leadsheet 
     converted to a music21Stream
     
     '''
     testFile = harmony.realizeChordSymbolDurations(music21Stream)
     smoothBassCS = generateSmoothBassLine(testFile.flat.getElementsByClass(harmony.ChordSymbol))
     output = generateContrapuntalBassLine(smoothBassCS, generatePopSongRules())
     mergeLeadSheetAndBassLine(music21Stream, output).show()
Esempio n. 5
0
 def leadsheetEx1(self):
     '''
     Example realization of a lead sheet, "Jeanie With The Light Brown Hair" from music21 corpus
     
     '''
     testFile1 = corpus.parse('leadSheet/fosterBrownHair.xml')
     testFile1.insert(metadata.Metadata()) 
     testFile1.metadata.title = 'Jeanie With The Light Brown Hair'
     testFile = harmony.realizeChordSymbolDurations(testFile1)
     smoothBassCS = generateSmoothBassLine(testFile.flat.getElementsByClass(harmony.ChordSymbol))
 
     output = generateContrapuntalBassLine(smoothBassCS, generatePopSongRules())
     mergeLeadSheetAndBassLine(testFile1, output).show()
Esempio n. 6
0
 def realizeclercqTemperleyEx(self, testfile):  
     '''
     Example realization  (using fbRealizer - romanNumerals flavor) of any clercqTemperley file.
     testfile must conform to the requirements of a class clercgTemperley file (must be a string)
     '''
     s = clercqTemperley.CTSong(testfile)
 
     testFile1 = s.toScore()
     testFile = harmony.realizeChordSymbolDurations(testFile1)
     smoothBassRN = generateSmoothBassLine(testFile.flat.getElementsByClass(roman.RomanNumeral))
 
     output = generateContrapuntalBassLine(smoothBassRN, generateBaroqueRules())
     output.insert(metadata.Metadata()) 
     output.metadata.title = s.title
     output.show()
Esempio n. 7
0
    def testNoChord(self):

        from music21 import converter

        target_str = '''
            T: No Chords
            M: 4/4
            L: 1/1
            K: C
            [| "C" C | "NC" C | "C" C | "N.C." C | "C" C
            | "No Chord" C | "C" C | "None" C | "C" C | "Other"
            C |]
            '''
        score = converter.parse(target_str, format='abc')

        self.assertEqual(len(score[harmony.ChordSymbol]), 9)
        self.assertEqual(len(score[harmony.NoChord]), 4)

        score = harmony.realizeChordSymbolDurations(score)

        self.assertEqual(8, score.getElementsByClass(harmony.ChordSymbol)
                            .last().quarterLength)
        self.assertEqual(4, score.getElementsByClass(harmony.ChordSymbol)
                            .first().quarterLength)