There's native support for that in the Hauptwerk v4 CODM. Have a look at the
SustainingSoundEffect_RankID
SustainingSoundEffect_MIDINoteNumber
... attributes on the Stop, Coupler and Tremulant tables (page 51 in the v4.0.0. guide) and the 'Action noises, blower noise and sound effects' section (pages 18-19).