コード例 #1
0
 def test_from_Composition(self):
     self.assertEqual(LilyPond.from_Composition(self.composition1),
                      '\\header { title = "Untitled" composer = "" opus = "" } { { c\'4 e\'4 g\'4 b\'4 } }'
                      )
     self.assertEqual(LilyPond.from_Composition(self.composition2),
                      '\\header { title = "Untitled" composer = "" opus = "" } { { c\'4 e\'4 g\'4 b\'4 } } { { c\'4 e\'4 g\'4 b\'4 } { \\key e \\major c\'4 e\'4 g\'4 b\'4 } }'
                      )
コード例 #2
0
 def test_from_Composition(self):
     self.assertEqual(LilyPond.from_Composition(self.composition1),
                      '\\header { title = "Untitled" composer = "" opus = "" } { { c\'4 e\'4 g\'4 b\'4 } }'
                      )
     self.assertEqual(LilyPond.from_Composition(self.composition2),
                      '\\header { title = "Untitled" composer = "" opus = "" } { { c\'4 e\'4 g\'4 b\'4 } } { { c\'4 e\'4 g\'4 b\'4 } { \\key e \\major c\'4 e\'4 g\'4 b\'4 } }'
                      )
コード例 #3
0
ファイル: walkingbass.py プロジェクト: rickylqhan/walkingbass
 def to_png(self):
     c = Composition()
     c.set_author(self.author)
     c.set_title(self.title)
     c.add_track(self.track)
     ly_string = LilyPond.from_Composition(c)
     #print ly_string
     LilyPond.to_png(ly_string, self.title)
コード例 #4
0
ファイル: __init__.py プロジェクト: beraldoleal/givemeasheet
def index():
    if request.method == 'POST':
        keys = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]
        meters = [(2,2), (2,4), (3,4), (4,4)]
        bars = int(request.form['bars'])
	key = keys[int(request.form['key'])]
        meter = meters[int(request.form['meter'])]
        scale = int(request.form['scale'])

        composition = Composition()
        composition.set_author("by givemeasheet.com", "*****@*****.**")
        composition.set_title("%d bars exercise in %s" % (bars, key))
        
        track = Track(Guitar())
       
        dificulty = 3
        if scale == 0:
            scale = scales.diatonic(key)
            scale_name = "Natural Major"
        elif scale == 1:
            scale = scales.natural_minor(key)
            scale_name = "Natural Minor"
        elif scale == 2:
            scale = scales.harmonic_minor(key)
            scale_name = "Minor Harmonic"
        elif scale == 3:
            scale = scales.melodic_minor(key)
            scale_name = "Minor Melodic"
        
        composition.subtitle = scale_name

        for bar in range(0,bars):
            bar = Bar(key, meter)
        
            while not bar.is_full():
                # Random note
                index = randrange(dificulty)
                note = Note(scale[index])
                possibles = get_possibles(bar)
                bar.place_notes(note, possibles[randrange(len(possibles))])
        
            track.add_bar(bar)
        
        composition.add_track(track)
        
        l = LilyPond.from_Composition(composition)
        u = uuid.uuid1()
        file_name = "/var/www/givemeasheet/givemeasheet/static/sheets/%s" % u.hex
        LilyPond.save_string_and_execute_LilyPond(l, file_name, "-fpng")
        sheet="/static/sheets/%s.png" % os.path.basename(file_name)
        midi="/static/sheets/%s.midi" % os.path.basename(file_name)
        MidiFileOut.write_Composition("%s.midi" % file_name, composition)

        return render_template('index.html', sheet=sheet, midi=midi)
    else:
        return render_template('index.html')
コード例 #5
0
    def saveLily(self):
        docMingus = self._createMingus()
        filename = tkutil.ask_savefile(title='Save Lilypond',
                                       types=['.ly|LilyPond'])
        if not filename: return

        s = LilyPond.from_Composition(docMingus)
        f = open(filename, 'w')
        f.write(s)
        f.close()
コード例 #6
0
firstbar = Bar(meter=(3,4))
track.add_bar(firstbar)
print track.add_notes(['C-5'], 4.0)
print track.add_notes(['E-5'], 2.0)

print track.add_notes(['C-4','D-4'], 8.0)
print track.add_notes(['C-4','D-4','F-4'], 8.0)
print track.add_notes([], 8.0) #treated as rest?
print track.add_notes(['C-4','D-4'], 8.0)
print track.add_notes(['C-4','D-4'], 8.0)
print track.add_notes(['C-4','D-4'], 8.0)
print track.add_notes(['C-4','D-4'], 24.0)
print track.add_notes(['C-4','D-4'], 24.0)
print track.add_notes(['C-4','D-4'], 24.0)
print track.add_notes(['C-4','D-4'], 8.0)

s = MusicXML.from_Composition(comp)
f=open('out.xml','w')
f.write(s)
f.close()

s=LilyPond.from_Composition(comp)
f=open('out.ly','w')
f.write(s)
f.close()

#4.0 qtr
#2.0 half
#1.0 whole

コード例 #7
0
def testWriteToLilypond(docMingus):
    s = LilyPond.from_Composition(docMingus)
    f = open('out.ly', 'w')
    f.write(s)
    f.close()
コード例 #8
0
ファイル: test_LilyPond.py プロジェクト: anzev/mingus
	def test_from_Composition(self):
		self.assertEqual(LilyPond.from_Composition(self.composition1),\
			"\\header { title = \"Untitled\" composer = \"\" opus = \"\" } { { c'4 e'4 g'4 b'4 } }")
		self.assertEqual(LilyPond.from_Composition(self.composition2),\
			"\\header { title = \"Untitled\" composer = \"\" opus = \"\" } { { c'4 e'4 g'4 b'4 } } { { c'4 e'4 g'4 b'4 } { \\key e \\major c'4 e'4 g'4 b'4 } }")