Wintergatan / Midi-to-laser-cutter

https://wintergatan.github.io/Midi-to-laser-cutter/
MIT License
126 stars 16 forks source link

“Can you hear the drums Fernado?” #11

Open Yuleblinker opened 7 years ago

Yuleblinker commented 7 years ago

Forgive the title but “Data Mapping Models” might not have got your attention and “Forget About Music for a While” might have been a bit controversial given the likely readers. I think that’s what we should do though. Because I’d like us to be able to play some drums, control a whacky contraption or simply play music box mechanisms. With a little thought at this stage in the project it will be possible to easily allow all these things whilst still fulfilling our primary goal. It’s just about making sure the data mapping model is flexible in design from the start and, temporarily, forgetting about music.

MIDI is the data model the user is going to give us. In very simple terms this data has the following structure or ‘map’:

simple_model

A user may import the following MIDI:

d_minor

Nothing unusual there. But it does bring up the first ‘mapping’ challenge… my standard 20 note music box mechanism can’t play a B flat but your modified one may be able to. We need to accommodate both scenarios. What I want to suggest here is that by coding the ‘mapping’ procedure to be as flexible as possible we can easily solve this issue AND the one I’m about to present.

What if ten-year-old Björn has created a little machine for a school project that has little levers to play some little drums and he wants to control it with a paper strip with holes in it. He’s figured out how to create a MIDI drum track in music class and wants to impress his friend Fernando with his machine. His track looks like this:

agnethas_drum_machine

Agnetha sees a video Björn has posted on YouTube and decides it would be cool to wire up her Arduino to some light sensors that get fired when holes in a paper strip pass over them. These events will control a laser light show to brighten up the long winter nights. She wants to use her MIDI keyboard to program the timings to match some tunes. She wants to associate notes with lights and creates this track:

agnethas_laser_show

If you’ve read this far you might be thinking “this is getting silly – it’s nothing to do with laser cutting from MIDI files. Who’s going to invent and build a machine that does such preposterous things? Have you lost your marbles?” Well just remember the reason you’re reading this at all. It’s probably something to do with preposterous machines and marbles!

Can we create a tool to allow Björn and Agnetha to fulfil their creative dreams, let Fernado finally hear some drums AND allow those who simply want to play music box mechanisms to cut some holes in paper? I think we can. It’s just about making sure we allow for flexible data mapping to ‘non-standard’ outputs – that’s the second mapping challenge. The good news is I don’t think the challenge is too difficult. We should just forget about music and scales for a while.

Here’s what I suggest…

Input The user imports a MIDI file. That file can be ‘music’ in any key, or simply indicate that certain named events should happen at certain times, like in a drum track.

Display (Editing and Playing) The user interface displays this (and ideally allows for basic editing, playback or creation)

‘Standard’ Maps The user ‘chooses’ an output mapping. This can be from a list of suggested standard templates like:

Their choice then creates a ‘strip’ on screen to match the output mapping. This could be a new strip or an overlay on top of their original strip.

The interface visually shows the user if there are any potential issues with their choice. For example, in simple music tracks, notes out of range or that are in a pitch that the output mapping doesn’t contain. The interface should allow the user to do things like move notes up/down octaves, delete notes or even transpose the whole track. At this point it’s really about the user trying to ‘massage’ their input to fit their chosen output. All this should be done as visually and non-technically as possible.

And now to the whole point of this long post…

‘User-configured’ Maps The user can choose to create their own output mapping. The interface allows them to choose how many rows they want. The user then indicates which MIDI program and which channel each row indicates. (Ideally they will also be able to provide their own name for each row e.g. 72 Tickle Unicorn with mechanical finger to make it giggle. An example could be:

non_standard_output_map

The Program, Channel and Description are all editable with drop-downs, pop-up editing boxes or simple text input.

The application then attempts to map the input data to the output just as it does for ‘standard’ music. The same controls are provided for showing the user if their input contains anything that currently doesn’t fit in the output structure. And the same controls used for simple music tracks also allow the user to move, delete or add events and control their timing.

So, forget about music for a while. Let’s just think about taking MIDI program, channel and event data, and showing the user how this fits with their own selection of programs and channels. If we do, we will have an application that would support some very unusual and creative uses for strips of paper with nicely cut holes.

We will also have an application for those without access to Unicorns who just want to take a MIDI file and cut it with a laser cutter.


Postscript: Björn grew up and sadly found out there are no Unicorns. He built his machine though. He was able to quickly cut his paper strips using this really useful application he found online. The drums played, Fernando heard them, collaborated with Björn on a catchy tune and some lyrics with no swear words at all, and they are hoping to win Melodifestivalen next year.

Agnetha built her machine and is now in custody awaiting trial for the disruption of flights in the air space over Malmö Airport. Investigators found many meters of perfectly punched paper strips in her apartment. The authorities are currently looking into a certain web application to see if it poses a threat to national security.

LorenzoLeonardini commented 7 years ago

I agree with you. However I think that the main goal we want to achieve now is only allowing the user to use a Music Box with modified notes (like Martin's one).