EricJ wrote:1. Should I check for the prior status of the note and only send commands when there is a change?
Yes.
EricJ wrote:2. If I do #1 and no keys are pressed, then no commands are sent. How will the software detect the midi device?
You don't need to worry about that within your hardware. When configuring Hauptwerk, you right-click on the relevant virtual keyboard, select 'Auto-detect MIDI settings', then follow the on-screen instructions to press and release the relevant keys on your keyboard so that Hauptwerk will hear the messages and thus know what settings to use.
EricJ wrote:and HW will remember the midi device?
Yes -- Hauptwerk will listen for the MIDI channel and MIDI port and remember them.
EricJ wrote:Does it ever forget MIDI devices, i.e. when HW is restarte
No -- it won't forget your settings. The only time you might need to auto-detect them again is if you change your MIDI device/hardware. (However, in Hauptwerk v6, you can remap MIDI port settings if you change your MIDI ports.)
EricJ wrote:3. do I need to send a MIDI command periodically, (every x seconds) so that the MIDI device will be detected? I could send the All Notes Off command if no keys are pressed
You don't need to send any messages periodically. However, some MIDI keyboards do send an 'all notes off' message every few seconds if no keys are pressed, just as a precautionary measure in case any preceding 'MIDI note-off' message were to be lost en route, thus avoiding the risk of a note 'sticking on'. That isn't a bad idea.