A web component which allows you to embed werckmeister snippets on your website.
- include the javascript file
<script src="https://unpkg.com/@werckmeister/components@1.1.6-41/werckmeister-components.js"></script>- embed your snippet
<werckmeister-snippet>
<![CDATA[
device: MyDevice midi _usePort=0;
instrumentDef:lead _onDevice=MyDevice _ch=0 _pc=0;
-- a melody track
[
instrument: lead;
{
c d e f | g a b c
}
]
]]>
</werckmeister-snippet> https://jsfiddle.net/z8qv5b7j/
can be either default or single. single means that the input is treated as one singe voice line such as c d e f g.
In defaultmode the input has to be a valid werckmeister source.
https://jsfiddle.net/bh4ugc5q/
Set the tempo of an snippet.
Inline css rules to set up the apperance of the snippet. https://jsfiddle.net/zxhgyv2p/
Set an url of an css file, to override the default css of the snippet. https://jsfiddle.net/m01bzg3f/
Set the repo url. See Soundfont Server.
Uses a workspace url as source. E.g.: "https://sambag.uber.space/api-wm/conductor16thHighHat"
Add the Werckmeister Components script to your HTML:
<script src="https://unpkg.com/@werckmeister/components/werckmeister-components.js"></script>Define a workspace <werckmeister-editor>. Each editor can contain a werckmeister document.
Example:
<werckmeister-workspace id="workspace"></werckmeister-workspace>
<werckmeister-editor
id="ed1"
wm-filename="main.sheet"
wm-style="height: 700px;"
>
using "chords/default.chords";
tempo: 140;
device: MyDevice webPlayer _useFont="FluidR3-GM";
instrumentDef:lead _onDevice=MyDevice _ch=0 _pc=0;
instrumentDef:rhythm _onDevice=MyDevice _ch=1 _pc=0;
instrumentDef:bass _onDevice=MyDevice _ch=2 _pc=0;
-- melody track
[
instrument: lead;
{
\p
r4 e f# g | c'1~ | c'4 d e f# | b2 b2~ |
}
]
</werckmeister-editor>
<a href id="download">Download MIDI</a>Link your editor to the workspace using JavaScript:
const workspace = document.getElementById('workspace');
workspace.registerEditor(document.getElementById('ed1'));You can also hook into events:
workspace.onError = (ex) => console.log("Error:", ex);
workspace.onCompiled = (doc) => console.log("Compiled successfully:", doc);To trigger MIDI file download:
const downloadEl = document.querySelector("#download");
downloadEl.onclick = (ev) => {
ev.preventDefault();
workspace.download("myFile.mid");
}Load a custom CSS file to override the default styling of the editor.
Set the repo url. See Soundfont Server.
sets an error callback
sets the style content to the underlying editor component
Load a custom CSS file to override the default styling of the editor.
Defines a filename for the editor file. This file is accessable for the compiler.