def test_from_Bar(self): self.assertEqual(LilyPond.from_Bar(self.commonbar), "{ \\time 4/4 \\key c \\major c'4 e'4 g'4 b'4 }") self.assertEqual(LilyPond.from_Bar(self.ebar), "{ \\time 4/4 \\key e \\major c'4 e'4 g'4 b'4 }") self.assertEqual(LilyPond.from_Bar(self.fbar), "{ \\time 6/8 \\key f \\major c'8 e'8 g'8 b'8 }")
def test_to_pdf(self): self.assert_( LilyPond.to_pdf( "{ %s }" % LilyPond.from_NoteContainer(NoteContainer("C"), value.dots(8)), "pdftest first test" ) ) self.assert_(LilyPond.to_pdf(LilyPond.from_Bar(self.tbar), "pdftest2")) self.assert_(LilyPond.to_pdf(LilyPond.from_Bar(self.mbar), "pdftest3"))
def test_to_png(self): self.assert_( LilyPond.to_png( '{ %s }' % LilyPond.from_NoteContainer(NoteContainer('C'), value.dots(8)), 'pn1')) self.assert_(LilyPond.to_png(LilyPond.from_Bar(self.tbar), 'pn2')) self.assert_(LilyPond.to_png(LilyPond.from_Bar(self.mbar), 'pn3'))
def test_to_pdf(self): self.assert_( LilyPond.to_pdf( '{ %s }' % LilyPond.from_NoteContainer(NoteContainer('C'), value.dots(8)), 'pdftest first test')) self.assert_(LilyPond.to_pdf(LilyPond.from_Bar(self.tbar), 'pdftest2')) self.assert_(LilyPond.to_pdf(LilyPond.from_Bar(self.mbar), 'pdftest3'))
def test_to_png(self): self.assertTrue( LilyPond.to_png( "{ %s }" % LilyPond.from_NoteContainer(NoteContainer("C"), value.dots(8)), "pn1", )) self.assertTrue(LilyPond.to_png(LilyPond.from_Bar(self.tbar), "pn2")) self.assertTrue(LilyPond.to_png(LilyPond.from_Bar(self.mbar), "pn3"))
def test_to_pdf(self): self.assertTrue( LilyPond.to_pdf( "{ %s }" % LilyPond.from_NoteContainer(NoteContainer("C"), value.dots(8)), "pdftest first test", ) ) self.assertTrue(LilyPond.to_pdf(LilyPond.from_Bar(self.tbar), "pdftest2")) self.assertTrue(LilyPond.to_pdf(LilyPond.from_Bar(self.mbar), "pdftest3"))
def test_from_Bar(self): self.assertEqual(LilyPond.from_Bar(self.commonbar), "{ \\time 4/4 \\key c \\major c'4 e'4 g'4 b'4 }") self.assertEqual(LilyPond.from_Bar(self.ebar), "{ \\time 4/4 \\key e \\major c'4 e'4 g'4 b'4 }") self.assertEqual(LilyPond.from_Bar(self.fbar), "{ \\time 6/8 \\key f \\major c'8 e'8 g'8 b'8 }") self.assertEqual(LilyPond.from_Bar(self.a_minor_bar), "{ \\time 4/4 \\key a \\minor }") self.assertEqual(LilyPond.from_Bar(self.b_flat_minor_bar), "{ \\time 4/4 \\key bes \\minor }") self.assertEqual(LilyPond.from_Bar(self.f_sharp_minor_bar), "{ \\time 4/4 \\key fis \\minor }")
def setup_plotting(): global fig global ax1 global ax2 global ax3 global line1 global line2 global sheet fig = plt.figure(figsize=(12, 8)) ax1 = fig.add_subplot(2, 2, 1) # Volume ax2 = fig.add_subplot(2, 2, 2) # Fourier ax3 = fig.add_subplot(2, 1, 2) # Notes ax3.set_axis_off() line1, = ax1.plot(np.random.randn(CHUNK_SIZE)) line2, = ax2.plot(np.random.randn(CHUNK_SIZE)) b = Bar() bar = LilyPond.from_Bar(b) LilyPond.to_png(bar, "track") img = mpimg.imread("track.png") cropped_image = img[0:300, :, :] sheet = ax3.imshow(cropped_image, cmap='gray', interpolation='antialiased')
for mode_func in MODE_CHORD_FUNCTIONS ] print(', '.join(chords)) elif args.action == '12_bar_blues': for four_bars in twelve_bar_blues(args.key): print('\t'.join(four_bars)) elif args.action == 'blues_scale': print("{} blues scale: {}".format(args.key, ', '.join(blues_scale(args.key)))) elif args.action == '12_bar_blues_printout': from mingus.containers.note import QuarterNoteFactory as Q from mingus.core.chords import WholNoteChordFactory as WNC blues_scale = Blues(args.key) bar = Bar() bar.extend( Q( list( blues_scale.generate(4 * 12, undulating=True, starting_octave=4)))) bar.set_chord_notes([ WNC(chord) for chord in twelve_bar_blues_chord_progression(args.key) ]) result = from_Bar(bar) print(result) to_png(result, args.filename)
def test_to_png(self): self.assert_(LilyPond.to_png('{ %s }' % LilyPond.from_NoteContainer(NoteContainer('C'), value.dots(8)), 'pn1')) self.assert_(LilyPond.to_png(LilyPond.from_Bar(self.tbar), 'pn2')) self.assert_(LilyPond.to_png(LilyPond.from_Bar(self.mbar), 'pn3'))
def test_to_pdf(self): self.assert_(LilyPond.to_pdf('{ %s }' % LilyPond.from_NoteContainer(NoteContainer('C'), value.dots(8)), 'pdftest first test')) self.assert_(LilyPond.to_pdf(LilyPond.from_Bar(self.tbar), 'pdftest2')) self.assert_(LilyPond.to_pdf(LilyPond.from_Bar(self.mbar), 'pdftest3'))
def test_to_png(self): self.assert_(LilyPond.to_png("{ %s }" % LilyPond.from_NoteContainer(NoteContainer("C"), value.dots(8)), "pn1")) self.assert_(LilyPond.to_png(LilyPond.from_Bar(self.tbar), "pn2")) self.assert_(LilyPond.to_png(LilyPond.from_Bar(self.mbar), "pn3"))
for chord in args.chords: chord_notes = chords.from_shorthand(chord) new_note = reduce_accidentals(tritone(chord_notes[0])) new_chord = new_note + '7' ii_chord_type_short, chord = reharmonize_v_to_ii_v(new_chord) print("{} {}".format(ii_chord_type_short, new_chord)) elif args.action == 'chord_modes': chords = [chords.determine_seventh(mode_func(args.key), shorthand=True)[0] for mode_func in MODE_CHORD_FUNCTIONS] print(', '.join(chords)) elif args.action == '12_bar_blues': for four_bars in twelve_bar_blues(args.key): print('\t'.join(four_bars)) elif args.action == 'blues_scale': print("{} blues scale: {}".format(args.key, ', '.join(blues_scale(args.key)))) elif args.action == '12_bar_blues_printout': from mingus.containers.note import QuarterNoteFactory as Q from mingus.core.chords import WholNoteChordFactory as WNC blues_scale = Blues(args.key) bar = Bar() bar.extend(Q(list(blues_scale.generate(4*12, undulating=True, starting_octave=4)))) bar.set_chord_notes([WNC(chord) for chord in twelve_bar_blues_chord_progression(args.key)]) result = from_Bar(bar) print(result) to_png(result, args.filename)