107 lines
5.4 KiB
Markdown
107 lines
5.4 KiB
Markdown
# MusicBoxConverter
|
|
|
|
> Converts MIDI files into music box scores that are ready to print.
|
|
|
|
This is a command-line program that converts MIDI files to scores that can be printed for 30 note music boxes (such as [this one for example](https://smile.amazon.co.uk/dp/B0774TSP3T/)). While it does not currently support other music boxes (I don't have any others on hand), it could be extended to support them fairly trivially given the track width and the names of the notes it can play.
|
|
|
|
If you are unsure of how to create a MIDI file for this program to consume, I recommend [Musescore](https://musescore.org/), which is a free and open source music notation program that has a MIDI export function.
|
|
|
|
|
|
## System Requirements
|
|
|
|
- Linux:
|
|
- [Mono](https://www.mono-project.com/download/stable/) (`dotnet` might work but is untested)
|
|
- Windows:
|
|
- Visual Studio (the free version is fine - it's just the developer command prompt you need)
|
|
- All operating systems:
|
|
- [Git](https://git-scm.com/downloads) (`sudo apt install git` on apt-based systems)
|
|
- For printing:
|
|
- [Inkscape](https://inkscape.org/)
|
|
- [ImageMagick](https://imagemagick.org/) (`sudo apt install imagemagick` on apt-based systems)
|
|
- [pdfposter](https://pdfposter.readthedocs.io/en/stable/Installation.html) (`sudo apt install pdfposter` on apt-based systems)
|
|
|
|
|
|
## Getting Started
|
|
This program is written in C♯. To get started, first clone this repository and compile it:
|
|
|
|
```bash
|
|
git clone https://git.starbeamrainbowlabs.com/sbrl/MusicBoxConverter.git
|
|
cd MusicBoxConverter
|
|
msbuild
|
|
```
|
|
|
|
This should work regardless of whether you're on Linux or Windows.
|
|
|
|
If you're on Windows, you'll either need to use a _Visual Studio Developer Command Prompt_ or open the solution file in _Visual Studio_ itself and hit the build button.
|
|
|
|
Once the build is complete, the binary (and associated libraries) can be found in `MusicBoxConverter/bin/Debug` (or `MusicBoxConverter/bin/Release` if you did a release build).
|
|
|
|
If you're having trouble building it, please [get in touch](https://starbeamrainbowlabs.com/) and I'll send you a build (when [this bug is fixed](https://github.com/go-gitea/gitea/issues/16526), I'll be able to create a release and upload the binaries there)
|
|
|
|
|
|
## Usage
|
|
1. Export the MuseScore file to a MIDI file
|
|
2. Run the MIDI file through this program.
|
|
3. Open the resulting SVG in Inkscape
|
|
4. Print the SVG to PDF (or `inkscape --export-pdf output.pdf input.svg`)
|
|
5. Open the resulting PDF in LibreOffice Draw
|
|
6. Print to your actual printer - tiling over multiple pages if required.
|
|
|
|
This somewhat convoluted process prevents anyone from automatically rescaling it along the way, and thus misaligning the green lines in the SVG file generated by the program.
|
|
|
|
If the above doesn't work, it's probably LibreOffice Draw scaling it even though you've told it not to. In that case, try this:
|
|
|
|
```bash
|
|
# Convert MIDI -> SVG
|
|
./MusicBoxConverter.exe --input song.midi --output score.svg
|
|
# Convert SVG → PNG
|
|
inkscape -o score.png score.svg
|
|
# Convert the PNG to PDF, rotating by 90 degrees (for portrait printing)
|
|
convert score.png -rotate 90 score.pdf
|
|
# Split the PDF up into multiple pages for the printer
|
|
# -s1 Don't scale the output
|
|
# -m Sets the output paper size. Defaults to A4 (21x29.7cm) if unspecified, but may need to reduce by a cm or 2 on each side (as below) if things get cut off.
|
|
pdfposter -s1 -m 20x27.7cm score.pdf print.pdf
|
|
```
|
|
|
|
....if that cuts things off at the edges, try doing it like this:
|
|
|
|
```bash
|
|
convert score.svg score.pdf
|
|
pdfposter -s1 score.pdf print.pdf
|
|
```
|
|
|
|
|
|
## Real-world usage
|
|
- (none yet - [get in touch](https://starbeamrainbowlabs.com/) if you've used this program somewhere cool!)
|
|
|
|
|
|
## Useful Links
|
|
A collection of links that were useful in making this program.
|
|
|
|
- [ffmpeg - showspectrumpic manual](https://ffmpeg.org/ffmpeg-filters.html#showspectrumpic) -- useful for analysing the frequencies produces by a music box
|
|
- [Frequency to Musical Note Converter](https://newt.phys.unsw.edu.au/music/note/)
|
|
|
|
|
|
## Contributing
|
|
Contributions are very welcome - both bug reports and code contributions! Bug reports can be made to my email address (available on my website <https://starbeamrainbowlabs.com/>). Code contributions can be sent as a patch via email. Do this to generate a patch file you can attach to an email:
|
|
|
|
```bash
|
|
git format-patch --stdout origin > patch_file.patch
|
|
```
|
|
|
|
This generates a patch file for all unpushed commits. To specify a specific commit range, do this:
|
|
|
|
```bash
|
|
git format-patch --stdout FIRST_COMMIT..LAST_COMMIT > patch_file.patch
|
|
```
|
|
|
|
Please mention in at least 1 commit message that you release your all your work under the MPL-2.0 (see below), as otherwise I will be unable to accept it (work you produce is as far as I know automatically copyright, so unless you release it under a licence no matter how awesome it is I'm not allowed to use it).
|
|
|
|
If there's significant interest in this, I can move it to [my GitHub account](https://github.com/sbrl) to make collaboration easier.
|
|
|
|
If you're feeling that way inclined I have a [Liberapay profile](https://liberapay.com/sbrl) if you'd like to donate to say an extra thank you :-)
|
|
|
|
|
|
## License
|
|
This project is released under the Mozilla Public License 2.0. The full license text is included in the `LICENSE` file in this repository. Tldr legal have a [great summary](https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2)) of the license if you're interested.
|