Dear orbik,
again thank you for sharing your MidiIn DLL and its useful ahk wrapper library.
Looking into your C++ source, I noticed that
your callback
Code:
void CALLBACK midiInProc(HMIDIIN handle, UINT wMsg, DWORD dwInstance, DWORD midi_message, DWORD midi_timestamp)
has access to timing information
"midi_timestamp".
It would be very helpful for the community, if you could extend the DLL
by a duration array
Code:
UINT ruleNoteDur[128][16];
in which a (NoteOffTime-NoteOnTime) duration for each of those 128 * 16 possible events is updated at NoteOffTime, whereas on NoteOnTime it is reset to 0 for each notified individual entry.
The listener-actor functions
Code:
noteXXX(notenumber, vel, ....
bound by
Code:
listenNote(noteNumber, noteXXX, channel=0)
urgently need a duration parameter
Code:
noteXXX(notenumber, vel, dur, ....
For you it may be a small step, but for the community it is a big leap ...

-- Fridemar
PS.:Then we can script things like that:
* Holding down a key produces a repeating motiv/melody (with programmed midi_out or some other *.mid *.wav ,*.mp3 pattern).
* Releasing the key stops the music, leaving a well-defined duration, which lies in the cycle of its adherent command-intervals
* Combined with memo-lyrics, each sung syllable easily anchors a special sub-command in the memory of the user ... such that Worksongs now get a totally new meaning within the context of Midi-powered Autohotkey
)
Ref:
[quote="orbik"](Moved from the relevant topic in Wishlist
http://www.autohotkey.com/forum/topic2831.html.. now in the correct sub forum)
I made a small library for integrating midi input to ahk scripts. It consists of a dll that uses a callback function to store the most recent value for each key velocity, cc, pitch wheel and channel aftertouch for every channel.
....
To get midi input as windows messages you command the dll to send specific data only, and to specific message numbers. You can also directly ask any of the stored most recent values
I also wrote an ahk layer on top of the dll supposed to make it easier to use. It also creates a tray icon menu to select/change midi in device.
The dll file:
http://ihme.org/~orbik/midi4ahk/midi_in.dllDll source (as a vc++ project):
http://ihme.org/~orbik/midi4ahk/dll_source/Dll function reference:
http://ihme.org/~orbik/midi4ahk/midi_in.readme.txt...
....
Code:
listenNote(noteNumber, funcName, channel=0)
{
global msgNum
GoSub, sub_increase_msgnum
DllCall("midi_in.dll\listenNote", Int,noteNumber, Int,channel, Int,msgNum)
OnMessage(msgNum, funcName)
}
....