コード例 #1
0
ファイル: console.py プロジェクト: crickxson/sheetmusic
def sheetmusic(Gnumeric, range_ref, key = "C", upper = 4, lower = 4):
    '''
    Convert the cells to sheet music.
    '''
    left, top, right, bottom = u.parse_range_ref(Gnumeric, range_ref)
    values = u.range_rendered_text(Gnumeric, left, top, right, bottom,
        sheet = 1) #Gnumeric.functions['sheet'](range_ref))
    t = to_track(values, key, upper, lower)
    lp = LilyPond.from_Track(t)
    return LilyPond.to_png(lp, '/tmp/track')
コード例 #2
0
ファイル: song.py プロジェクト: spiderbit/canta-ng
 def generate_picture(self, k):
     ''' Generates picture of the lines k '''
     img_path = os.path.join(self.path, 'media', 'images')
     if not os.path.exists(img_path):
         os.makedirs(img_path)
     import tempfile
     tmp_dir = tempfile.mkdtemp()
     track = self.composition.tracks[k]
     ltrack = LilyPond.from_Track(track)
     tmp_file = os.path.join(tmp_dir, 'tmp_file')
     lily_str = li_header + ltrack
     LilyPond.save_string_and_execute_LilyPond(lily_str, tmp_file, '-fps')
     img_file = os.path.join(img_path, self.song_name + str(k) + '.png')
     gs_cmd = 'gs -dBATCH -dNOPAUSE -g2048x256 -q -r273.5 ' \
             +'-sDEVICE=pngalpha -sOutputFile="%s" "%s"' \
             % (img_file, tmp_file + '.ps')
     from subprocess import Popen
     p = Popen(gs_cmd, shell=True)
     sts = os.waitpid(p.pid, 0)
     os.unlink(tmp_file + '.ps')
     os.rmdir(tmp_dir)
コード例 #3
0
ファイル: song.py プロジェクト: tewe/canta
 def generate_picture(self, k):
     ''' Generates picture of the lines k '''
     img_path = os.path.join(self.path, 'media', 'images')
     if not os.path.exists(img_path):
         os.makedirs(img_path)
     import tempfile
     tmp_dir = tempfile.mkdtemp()
     track = self.composition.tracks[k]
     ltrack = LilyPond.from_Track(track)
     tmp_file = os.path.join(tmp_dir, 'tmp_file')
     lily_str = li_header + ltrack
     LilyPond.save_string_and_execute_LilyPond(lily_str, tmp_file, '-fps')
     img_file = os.path.join(img_path, self.song_name + str(k) + '.png')
     gs_cmd = 'gs -dBATCH -dNOPAUSE -g2048x256 -q -r273.5 ' \
             +'-sDEVICE=pngalpha -sOutputFile="%s" "%s"' \
             % (img_file, tmp_file + '.ps')
     from subprocess import Popen
     p = Popen(gs_cmd, shell=True)
     sts = os.waitpid(p.pid, 0)
     os.unlink(tmp_file + '.ps')
     os.rmdir(tmp_dir)
コード例 #4
0
 def test_from_Track(self):
     self.assertEqual(LilyPond.from_Track(self.track1),
                      "{ { c'4 e'4 g'4 b'4 } }")
     self.assertEqual(LilyPond.from_Track(self.track2),
                      "{ { c'4 e'4 g'4 b'4 } { \\key e \\major c'4 e'4 g'4 b'4 } }"
                      )
コード例 #5
0
 def test_from_Track(self):
     self.assertEqual(LilyPond.from_Track(self.track1),
                      "{ { c'4 e'4 g'4 b'4 } }")
     self.assertEqual(
         LilyPond.from_Track(self.track2),
         "{ { c'4 e'4 g'4 b'4 } { \\key e \\major c'4 e'4 g'4 b'4 } }")