A library transpiles Music Macro Language into ABC music notation.
https://cat2151.github.io/mml2abc/dist/
- A simple text-to-text JavaScript library
- Generates ABC music notation for abcjs from MML
- abcjs is a library that draws sheet music in the browser and plays it using a SoundFont GM software synthesizer.
- What is mml2abc used for?
- For playing sounds in a browser
- To write MML and play it with abcjs
- For writing MML and playing sounds in Obsidian
- For playing sounds in a browser
- When playing in a browser:
- Sound can be played by writing a small
index.htmlfile.
- Sound can be played by writing a small
- When playing in Obsidian:
- When playing from the command line on Windows:
- Not investigated.
- This is out of scope. Priority is given to "writing MML and playing sounds in Obsidian."
- Since abcjs can play sounds in Obsidian (i.e., Chromium), there's likely a way, but it hasn't been investigated.
- Are there any command-line software synthesizers that can output audio from ABC music notation (not limited to abcjs)? Not investigated.
- This is out of scope. Priority is given to "writing MML and playing sounds in Obsidian."
- Not investigated.
- How to use mml2abc in a webpage?
- A sample has been prepared. Please refer to easymmlabc.
- How to play MML sounds in Obsidian?
- Import
mml2abcand pass arguments to its functions. - For specific examples, please refer to easymmlabc.
- Proof of Concept
- Proof of concept is prioritized over high functionality, high performance, high reliability, extensibility, stability, and version compatibility.
- Playing Sound
- Maintaining the ability to play at least basic sounds is prioritized as much as possible.
- The ability to provide an
MML stringto a function and obtain anabcjs-playable string.- Maintaining simplicity by not adding more complex features is prioritized.
- Realizing "writing MML and playing sounds in Obsidian."
- Prioritize a simple MML format that inherits a subset of existing standards.
- It will be a subset of SiON (chords will be a subset of Z-MUSIC).
- The dialect name is
mmlabc.
- Creating
mml2abc.pegjs- is the responsibility of this repository.
- mml2abc.pegjs is the core file of this project and serves as the SSOT (Single Source of Truth).
- All grammar for MML to ABC music notation conversion is described in this file.
- Creating a mechanism to easily use
mml2abc- is handled by easymmlabc.
- Creating a mechanism to use
mml2abcin Obsidian
- Developing the MML parser using TDD with peggyjs + Jest is easy. I hope this can be of some reference, and I'll try to write more about it in the future.
- Jest is used for TDD.
- Using the VSCode Jest extension
- It's easy to have tests run automatically (red/green) just by writing tests and peggyjs.
- Using the VSCode Jest extension
- chokidar is used to connect peggyjs and Jest.
- Updating peggyjs automatically generates ES modules (for browsers) and CommonJS (for TDD & servers), and Jest's automatic tests run, making it easy.
- For printf debugging in peggyjs, control Jest's
silentandverboseoptions (allowsconsole.logoutput to be seen in the VSCode Jest terminal).- printf debugging is occasionally necessary, so having it enabled makes things easier.
- webpack-dev-server is used for live reload (hot reload) of browser pages.
- Problems sometimes emerge when actually playing in the browser (e.g., unexpected behavior of abcjs), so having live reload enabled makes things easier.
- After cloning, set up the environment first.
- This includes installing Node.js related tools, running
npm install, and installing VSCode and its Jest extension.
- This includes installing Node.js related tools, running
- To start daily development, just run the following:
code . npm run watch