在网页上写下音乐符号

msi*_*nfo 24 html javascript css jquery

我希望能够在网页中编写音乐符号和和弦.

有没有可用于此的库(如Mathjax for math)?如果没有,那么还有其他方法来实现这一目标吗?

Kee*_*ema 26

看看这个Javascript api用html5 canvas创建乐谱.

http://www.vexflow.com/docs/tutorial.html

例:

 <canvas width=700 height=100"></canvas>
Run Code Online (Sandbox Code Playgroud)

更新(2014年3月18日)

然后:

var canvas = $("div.three div.a canvas")[0];
  var renderer = new Vex.Flow.Renderer(canvas,
    Vex.Flow.Renderer.Backends.CANVAS);

  var ctx = renderer.getContext();
  var stave = new Vex.Flow.Stave(10, 0, 500);

  // Add a treble clef
  stave.addClef("treble");
  stave.setContext(ctx).draw();

  var notes = [
    // Dotted eighth E##
    new Vex.Flow.StaveNote({ keys: ["e##/5"], duration: "8d" }).
      addAccidental(0, new Vex.Flow.Accidental("##")).addDotToAll(),

    // Sixteenth Eb
    new Vex.Flow.StaveNote({ keys: ["eb/5"], duration: "16" }).
      addAccidental(0, new Vex.Flow.Accidental("b")),

    // Half D
    new Vex.Flow.StaveNote({ keys: ["d/5"], duration: "h" }),

    // Quarter Cm#5
    new Vex.Flow.StaveNote({ keys: ["c/5", "eb/5", "g#/5"], duration: "q" }).
      addAccidental(1, new Vex.Flow.Accidental("b")).
      addAccidental(2, new Vex.Flow.Accidental("#"))
  ];

  // Helper function to justify and draw a 4/4 voice
  Vex.Flow.Formatter.FormatAndDraw(ctx, stave, notes);
Run Code Online (Sandbox Code Playgroud)

这将产生:

这个

希望能帮助到你!

  • 我认为这是一个非常棒的api.您可以根据需要将画布设置为大或小.并且笔记不难添加.这也是一个很大的优点,它有一个很好的/干净的教程. (3认同)

thS*_*oft 16

以下是一些支持格式的库:

  • 我是 AlphaTab 的开发者。在最新版本(GitHub 上的源代码)中,我们还支持我们使用的内部数据模型的 JSON 变体。这使得在数据库中存储文件比 GuitarPro 二进制文件更容易。MusicXML 已在我的路线图上。 (2认同)

pat*_*luc 6

我想你可以尝试使用音乐字体,比如这两个:http://www.fontspace.com/david-rakowski/lassushttp://www.fontspace.com/robert-allgeyer/musiqwik(可能有其他人,我做了一个快速搜索......)

它并不完美,但它可以做到这一点.您必须在您的网站上集成该字体并使其使用正确的css规则...