Skip to content

Instantly share code, notes, and snippets.

@AxGord
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AxGord/6abf66967f15b76d4ac6 to your computer and use it in GitHub Desktop.
Save AxGord/6abf66967f15b76d4ac6 to your computer and use it in GitHub Desktop.
Use midi controllers for Code Snippets. Soft: Windows, Haxe, Pony, Nodejs, node-midi, Autohotkey. I'm use Automap/Launchpad. File name == midi code.
Send, trace();
Send, {Left}
Send, {Left}
Send, function(){SPACE}
import js.Node;
import pony.fs.Dir;
import pony.midi.MidiDevice;
class MidiCodeSnippets {
static function main() {
var midi = new MidiDevice(0);
for (u in new Dir('.').content()) if (u.isFile && u.file.ext == 'ahk') {
var n = Std.parseInt(u.file.name);
if (n != null) midi.on - n - 0 + u.file.name << run;
}
}
static function run(f:String):Void Node.child_process.exec(f, null, null);
}
import js.Node;
import pony.fs.File;
import pony.midi.MidiCode;
import pony.midi.MidiDevice;
//second way
class MidiCodeSnippets2 {
static function main() new MidiDevice(0).on.add(handler);
static function handler(key:MidiCode, velocity:MidiCode):Void {
if (velocity != 0) return;
var f = new File(key + '.ahk');
if (!f.exists) return;
Node.child_process.exec(f.name, null, null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment