hundredrabbits / Orca

Esoteric Programming Language
https://100r.co/site/orca.html
MIT License
4.58k stars 229 forks source link

Add setting for scale/mode for MIDI note table #281

Open eethann opened 2 years ago

eethann commented 2 years ago

I'm finding myself needing to devote a good deal of real estate to defining and retrieving scale degree systems in my grids. I've been using T but that approach isn't ideal as it loses the octave information when transposing across a G/A boundary.

I think this could be addressed quite straightforwardly with a setting for MIDI scale degrees. The default would be chromatic: AaBbCcDdEFfGg or 0123456789ab with a root setting of A (I think I like the latter). One could define standard 7 note scales using a form like 024579b or such, and could also change the root note (say to 0 for easier computation).

I can try to mock this up in a PR, curious others' thoughts.

neauoire commented 2 years ago

Hi Eethann,

You should use Q instead of T for this :)

eethann commented 2 years ago

Interesting. The key feature of T is that it has the implicit modulo of the index, which allows for a pseudo-transposition that wraps around from the end of the scale degrees back to the start. Is there a similarly easy way to do that with Q?

My aim has been to transpose a given note by a given scale degree.

This generally looks something like the grid below, with lots of similar QGT combinations referring to the same scale in comments. The approach makes it easy to switch the mode for the entire grid, but takes up space and time calculating the offsets. Making a "mode" for midi that used scale degrees instead of chromatic notes could simplify this a lot, and open up some nice possibilities (easy modulation across the entire grid, etc.). Apologies if I'm too dense in not seeing the equivalent approach using Q.

.......0a7Q........
847GabcdEfg........
...a.....aaa.......
.....12C4..........
....wC304T0546.....
.....0Y0A0.........
......D207TabcdEfg.
.......:02af1......
...................
...................
..........#abcdEfg#
..........#used.by#
..........#many.Qs#
neauoire commented 2 years ago

I'm not super familiar with what scales are, so this is a bit beyond me at the moment, but I can show you how to do modulo on-demand:

1X..
6I4.

The reason I suggested Q was that you can have Octave-Note ports, which might help carrying over B. But it might be too much legwork here.

In my local copy of orca(uxn), I have a hexadecimal operator which I use for controlling lights on stage when I do shows, but you could make yourself an operator that works in a similar way, so you could have ~3a(A3#). Alternatively, you could do an operator that uses 2 x base36 ports and generate a midi value between 0-72 that could be more easily operated on.

If none of this works, you could make yourself a little midi pre-processor script that offsets the midi notes.

eethann commented 2 years ago

Thanks for all of that. Re the modulo, thanks for clarifying that. I'd been working at it and know it's in some of the docs, sorry to have missed it here.

If it's helpful context, the trick with scales is that the offset isn't consistent. E.g. if the notes in a scale are the minor scale ABCDEFG, +2 gets you from A to B, but it only takes +1 to get from B to C. If you want to transpose a note 2 scale degrees consistently, you need to change the amount you add depending on what note you're transposing and to where. If the MIDI implementation has some sense of scales inbuilt, it simplifies this. You just add the number of scale degrees you want to transpose by, and don't need to worry about the variations in # of chromatic steps.

Thanks for the idea of the midi preprocessor, I've been thinking about something along those lines for a few things. I might still give a go at an implementation in my branch, just to test out the concept.

sense-amr commented 2 years ago

hoi niccco!