Midi-to-laser-cutter
Midi-to-laser-cutter copied to clipboard
TODO: Avoid re-inventing the wheel
There are already a good number of resources/projects that could be useful as a starting point. Making use of existing code bases would save a good deal of time. For reading and parsing MIDI files there are many existing and mature code libraries that could be used as a basis for this project. For example here are a few:
Python py-midi 1.2.2 https://pypi.python.org/pypi/py-midi/1.2.2 Mido - MIDI Objects for Python https://mido.readthedocs.io/en/latest/ python-midi https://github.com/vishnubob/python-midi music21 http://web.mit.edu/music21/ Javascirpt MIDI.js https://galactic.ink/midi-js/
And something that almost is exactly what we are after: Falcon MIDI to music box punch card converter https://github.com/Tenchi2xh/Falcon This allows output to 15, 20 and 30 not music box strips. It currently outputs pixel-based formats but support for vector or DXF formats could easily be added
In terms of what could be created there is already a web based application that allows the import of MIDI files, transposing, selecting music box device and output. It can be found here: Musicboxmaniacs https://musicboxmaniacs.com/create/
A web-based solution would definately allow the greatest access to the application and would also negate cross-platform issues.
I'm a C# passionate, and I link also this: https://github.com/stephentoub/MidiSharp (but the web-based solution would be the best idea.)
EDIT: Talking about web, I develop in PHP, and I found this: https://github.com/tmont/midiparser
It seems very cool and useful.
Looking for something to export in vectorial graphic from PHP, maybe we can check this: https://github.com/PhenX/php-svg-lib
Then I'll stop making a MIDI parser myself. I was having fun, but it's not needed.
The PHP resources look good but relying on PHP to do the parsing and processing would put the load on the server. And whilst we're probably not talking about a hugh amount of traffic it may still affect performance. If a web-based option is to be considered I'd suggest passing on all of the processing to the end user and have it done whitin their browser i.e. using Javascript
A Javascript approach would also open it up to many more people to use/amend/hack any code as there is no reliance on having access to a server. A Javascript approach would also mean the user could play the MIDI track directly within the browser to validate/check it and possibly even create/edit it without needing other software - along the lines of the Musicboxmaniacs tool: https://musicboxmaniacs.com/create/
An in-browser solution is easier to host, it can even be hosted on this repository using GitHub pages.
So JavaScript it is? I think it's a good idea.
I already made something for it: https://github.com/ianespana/Wintergatan-Laser-MIDI
It's in C#, but if we were to make a website I think we could integrate it there
@ianespana , Excellent!! (I also like C# ❤️ ) The project will probably be JS-based but your program is cool! We have a good start point, a good ispiration! Ok, different libraries, different languages... but a good ispiration!
@JonesyLeo To be honest we don't need a library for this. It's really easy to interpret MIDI, specially since we only have to worry about note on commands, their pitch, and the absolute time they are played on. Delta time is useless, as well as all the other attributes
@ianespana Cool, a cleaner work!
So... why not just use https://musicboxmaniacs.com/create/? It seems to already do everything. Converting the PDF into another format if necessary is trivial and I bet the creators of that site would be happy to add another format for laser cutters.
I emailed the site's creators and asked if they would add a laser cutter-friendly format
Then, what's really the point on having this project? Just saying. I'd rather actually do it for ourselves.
Hi everybody. I'm the creator of http://musicboxmaniacs.com and a big fan of Wintergatan. Supporting laser cutting friendly formats has been in my todo list for a long time, but this effort makes me consider this to be the top priority (big thanks to @emosenkis for writing to me). I'm open for collaboration and will be happy to use a third-party library (my backend is running on python) or integrate my website with a REST API for that.
Hey @rzinurov , you can join the discussion on gitter: https://gitter.im/Wintergatan/Midi-to-laser-cutter
Hey @rzinurov After reviewing some code I think it's interesting to integrate the project with your website. How I see it is that you can press a share button that opens up this project with the music notes filled in.
Are you still interested in collaborating?
Hi @whitebird. It's been a long time and I ended up developing my own DXF export. And even though your idea sounds interesting, I don't think I will have time for this in the next couple of months.

Hey @rzinurov,
Your exporting options look very clean, i'm really impressed by the PDF that's generated. There's no hurry to it. It may be possible that we provide a generic API that you can call to generate the export.
The reason why I thought again about the collaboration is that your editor is very refined and robust already.
One thing of importance to me is that as much as possible is generated client-side on our side. The extra challenge in that is so that it remains portable to other platforms and usable around the world, either offline or online.
Hey @whitebird. Thanks, I'm glad that you like my export implementation. Unfortunately, a pretty big amount of the editor logic is done on the backend side, so it's not really possible to use it offline. If you need a similar editor, I think it will be easier to build it from scratch, rather then reusing my code. It was built 4 years ago in angular and frankly I had no idea what I was doing 😬
and frankly I had no idea what I was doing 😬
Oh, so it's not just me, hahaha
Do you have an interface that solely exports the note data? As in Note 1 is an A at 1 sec, or something like that? Or MIDI?
Do you have an interface that solely exports the note data? As in Note 1 is an A at 1 sec, or something like that? Or MIDI?
No, not really. I use custom JSON format to send melody data between client and server. It is based on bar number indexing, the notes are quantized to the grid, which sometimes causes problems with rhythm when importing MIDI files. MIDI, MP3 and other files are generated from this internal format.
Interesting, maybe I can adopt your custom JSON format so you won't have to do much work.
I don't think you should, really. The format is not great and in fact at some point I considered to deprecate it and switch to a better one, but I did not get to it.
Currently I'm using the format generated by MidiConvert: https://github.com/Tonejs/MidiConvert