Hello everyone,
This is my first post and I want to say how impressed I am about this software. I've been using alternative shells for years, mainly because the ability to handle all kinds of key shortcuts, but Autohotkey goes far far beyond (and I've only seen 2% of what is possible).
The truth is I found Autohotkey looking for a program that could detect MIDI IN input and translate that to keypresses. This is not yet possible with this great software and I was writing Chris about this (instead of posting here, sorry!).
I don't know if any of the other users have some MIDI hardware. I have bought recently a Behringer BCR2000 controller. It connects through USB, costs 200 eur. It has 32 endless rotary knobs and 28 push buttons. I use it to make music, but I was wondering how awesome it would be to control a program like Photoshop or Flash to select RGB colors with real knobs, or to assign to each button a function like Levels, Curves, Create Layer... it would be like the hardware version of Photoshop.
So that this would be possible, someone should add MIDI input to Autohotkey. I believe it should be quite easy and not add many bytes to the executable file. I looked very quickly how to program MIDI in C with google and found:
http://www.borg.com/~jglatt/tech/lowmidi.htm
http://ccarh.stanford.edu/courses/253/lab/midiprog/
(I'm a programmer myself and I've done MIDI apps long time ago, but now I only do interactive web services).
Is there anyone else who thinks this could be a really interesting addition? I guess you all know how powerful Autohotkey is, so imagine adding suddendly 61 new keys and lots of sliders and knobs :)
Here some thoughts I wrote to Chris in that email last week:
Add a new entry to the View menu:
View > List MIDI IN ports
That would dump a list of available MIDI IN ports like:
0=Edirol PCR-50
1=Behringer BCR2000
2=Yamaha SY-85
Then, in our script, we can specify not only keyboard keys but also MIDI events. Those can be of two types (there are a few more, but probably not interesting in this case):
First type:
Key Down.
3 bytes: channel (0-16), key number (0-127), velocity (0-127)
Second type:
Control Changes (CC).
3 bytes: channel (0-16), CC number (0-127), value (0-127)
And the script could look like:
#z::Run,
www.autohotkey.com
&0key70::Run,
www.somepage.com
&1cc100::Run,
www.someotherpage.com
So when we play key 70 on the Edirol, opens somepage.com, and when we move the slider that transmits control change 100 in the BCR2000, opens someotherpage.com.
For this to work, Autokeys should start listening to the MIDI devices specified by &0, &1, etc. I'm not sure if MIDI support is included in your C compiler, but it's probable.
The behaviour I described is the most simple and only detects the event, but does not use the parameter. It can be improved if Autokey can detect the CC value and use it, because when I turn a knob, it transmits 'how much it is turned'. That could control the transparency of an object, or the volume, or... Also key velocity can be read (how hard the keyboard was hit, so it could detect your mood :)
The programming part shouldn't be so difficult. Basically it consists on opening the required MIDI in ports, listening to them, when events occur discards non useful events and take actions for the interesting ones. One thing to consider is the amount of events, which can be high. If you turn a knob from 0 to 127, maybe it transmits 127 x 3 bytes. No one could hit a key on the computer keyboard 127 x 3 times in half second, but with control changes this is possible. One solution is to filter and allow the same control change at a maximum rate, lets say one every 1/10 s., discarding the rest.
I don't know about file size increase. Depends on the required MIDI library or maybe direct access is possible...
By the way... there is a way to test it on your own computer without owning MIDI devices. You would need two programs. First, a virtual synthesisers with virtual keyboard, knobs and sliders which you can play with the mouse. Second, MidiYoke driver, which allows
"you to connect the MIDI output from one program to the MIDI input of a different program."
This way you could click keys and move sliders in the virtual synth, which would send MIDI events to a port that you are listening to in Autokeys. (a little twisted, but cheap).
I think a simple beta version can be done in a few hours...
Anyone? :)