V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
sadhen
V2EX  ›  分享创造

zz: Write music in TeXmacs using Lilypond

  •  
  •   sadhen ·
    darcy-shen · 2020-04-12 22:38:38 +08:00 · 1278 次点击
    这是一个创建于 1499 天前的主题,其中的信息可能已经有所发展或是发生改变。

    GNU TeXmacs 论坛的一位小伙伴,描述了一些在 TeXmacs 中生成五线谱的方法。

    其实就是在目前 TeXmacs 的 Graph 插件的基础上,新定制一个 Lilypond 插件。Graph 插件是我从 18 年 10 月就开始实现的插件,由于基本只在周末写代码,进度上比较慢,到现在( 2020 年四月),其实还没有完全写完。Graph 插件支持那些从文本的描述语言生成的图片的工具,比如

    等等。整体是用 Python 实现的,所有相关的代码都维护在了 tmpy 这个目录下面。虽然引入了额外的 Python 依赖,但是确实要比用 Scheme 来维护这些插件会轻松很多。其实 Python 的代码无非就是调用一个命令行工具,生成一张图片,然后通过一种协议,将这张图片输入到 TeXmacs 里面。用 Python 实现的目的确实是为了降低维护成本,希望有更多的开发者加入。从 Lilypond 的这个适配来说,我的效果达到了,蛮开心的。

    2016 年的时候,当时在看 TeXmacs 的 Graphviz 插件,但是没办法 Make it work,当时是调研了 Graphviz 算法的方案,寻思着去用 Scheme 实现类似 Graphviz 的布局算法。发了微博说:

    打算把 网页链接 这篇论文中的算法用 scheme 实现出来,做成 TeXmacs 绘图的插件,这样以后作图就不用 graphviz 了 ​​​​

    后来有了更多的工作经验之后,就没有那么 Naive 了,人生有限,并没有那么多时间写那么多代码。。。

    能复用的工作尽可能复用,能大家一起做事情,不要一个人闷头苦干!!!

    前面废话太多,转载如下:


    The code of the Graph plugin is quite easy to read. I took a look at the code and it turns out the logic for generating pictures using pdflatex is quite straightforward. The program to generate music sheets is called lilypond. It is also uses Scheme.

    Please follow the following:

    1. Create a file lilypond.py from pdflatex.py in the folder plugins/tmpy/graph/, change every line of code that has PDFLatex into lilypond; delete the arguments in the cmd0 variable.
    2. add lilypond() where PDFLatex() appears in the file plugins/tmpy/session/tm_graph.py

    One should look at other backends such as xypic in order to customize the size of the output.

    Now look at the output:


    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3021 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 04:28 · PVG 12:28 · LAX 21:28 · JFK 00:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.