''' 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() if __name__ == "__main__": from music21 import base base.mainTest(Test, TestExternal) #from music21 import corpus #from music21.demos.bhadley import HarmonyRealizer #test = HarmonyRealizer.TestExternal() #test.leadsheetEx1() #sc = converter.parse('https://github.com/cuthbertLab/music21/raw/master/music21/corpus/leadSheet/fosterBrownHair.mxl') # Jeannie Light Brown Hair testfile1 = ''' % Dylan - Blowin' in the Wind VP: I IV | V I | In: I | Vr: $VP I IV | I | $VP I IV | V | $VP I IV | I | IV V | I IV | IV V | [2/4] I | [4/4] IV V | I IV | IV V | I | S: [D] $In $Vr $Vr $Vr '''
s1 = stream.Stream() s2 = stream.Stream() s2.append(note.Note('D-2')) s2.append(note.Note('F#5')) self.assertEqual(getAccidentalCountSum([s1, s2]), {'flat': 1, 'sharp': 1}) def testGetAccidentalCountSumAdvanced(self): s1 = corpus.parse('bach/bwv7.7') s2 = corpus.parse('bach/bwv66.6') totalNotes = len(s1.flat.notes) + len(s2.flat.notes) tally = getAccidentalCountSum([s1, s2], True) self.assertEqual(tally, {'sharp': 195, 'natural': 324}) self.assertEqual(totalNotes, tally['sharp'] + tally['natural']) class TestSlow(unittest.TestCase): def runTest(self): pass def testAccidentalCountBachChorales(self): # the total number of accidentals in the Bach Chorales chorales = list( corpus.chorales.Iterator() ) self.assertEqual(getAccidentalCountSum(chorales, True), {'double-sharp': 4, 'flat': 7886, 'natural': 79869, 'sharp': 14940}) if __name__ == "__main__": from music21 import base base.mainTest(Test) # replace 'Test' with 'TestSlow' to test it on all 371 Bach Chorales.
def testRealizeLeadsheet(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() if __name__ == "__main__": from music21 import base base.mainTest(Test, TestExternal) #from music21 import corpus #from music21.demos.bhadley import HarmonyRealizer #test = HarmonyRealizer.TestExternal() #test.leadsheetEx1() #sc = converter.parse('https://github.com/cuthbertLab/music21/raw/master/music21/corpus/leadSheet/fosterBrownHair.mxl') # Jeannie Light Brown Hair testfile1 = ''' % Dylan - Blowin' in the Wind VP: I IV | V I | In: I | Vr: $VP I IV | I | $VP I IV | V | $VP I IV | I | IV V | I IV | IV V | [2/4] I | [4/4] IV V | I IV | IV V | I |
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() if __name__ == "__main__": from music21 import base base.mainTest(Test) #from music21 import corpus #from music21.demos.bhadley import HarmonyRealizer #test = HarmonyRealizer.TestExternal() #test.leadsheetEx1() #sc = converter.parse('C:/wikifonia/wikifonia-4750.mxl') #hey Jude -- gone #sc = corpus.parse('demos/BlowinInTheWind.mxl') #test.realizeLeadsheet(sc) testfile1 = ''' % Dylan - Blowin' in the Wind VP: I IV | V I | In: I |
def testGetAccidentalCountSumAdvanced(self): s1 = corpus.parse('bach/bwv7.7') s2 = corpus.parse('bach/bwv66.6') totalNotes = len(s1.flat.notes) + len(s2.flat.notes) tally = getAccidentalCountSum([s1, s2], True) self.assertEqual(tally, {'sharp': 195, 'natural': 324}) self.assertEqual(totalNotes, tally['sharp'] + tally['natural']) class TestSlow(unittest.TestCase): def runTest(self): pass def testAccidentalCountBachChorales(self): # the total number of accidentals in the Bach Chorales chorales = list(corpus.chorales.Iterator()) self.assertEqual(getAccidentalCountSum(chorales, True), { 'double-sharp': 4, 'flat': 7886, 'natural': 79869, 'sharp': 14940 }) if __name__ == "__main__": from music21 import base base.mainTest( Test ) # replace 'Test' with 'TestSlow' to test it on all 371 Bach Chorales.