Der spezielle Drum Algorithmus in der MB64 arbeitet aehnlich wie von Steff beschrieben (er befindet sich in drums.inc):
; This include file provides following functions:
; o DRUMS_Init: initializes the drums driver
; o DRUMS_Timer: called by USER_Timer or USER_SR_Service_Finish periodically to update the DRUM_S
TATE
; o DRUMS_AIN_NotifyChange: called from USER_AIN_NotifyChange on AIN events
; o DRUMS_Tick: called by USER_Tick to handle the drum trigger events
;
; number of analog inputs which are assigned to drum triggers
#define DRUMS_NUMBER_AIN 8
;
; threshold value for rising signal - when will an “On” event be regognized?
#define DRUMS_THRESHOLD_RISING 64
;
; threshold value for falling signal - when will an “Off” event be regognized?
#define DRUMS_THRESHOLD_FALLING 16
;
; measuring time - defines, how long an analog value should be measured before
; the maximum value will be sent out) - absolute time depends on the period time
; of DRUMS_Timer. If DRUMS_Timer is called from USER_SR_Service_Finish,
; the time is: 1 mS * DRUMS_MEASURING_TIME
#define DRUMS_MEASURING_TIME 10
;
; using the MB64_POT handler to send an event (allows menu configuration
; of the MIDI events) or just send trigger the notes directly?
#define DRUMS_USE_MB64_POT_HANDLER 0
;
;
; Some comments to the concept: this driver consists of a finite state
; machine which measures the maximum peak value of an analog drum trigger
; signal and sends an “On” event after a certain delay defined by MEASURING_TIME.
; An “Off” event will be sent once the analog value falls below the THRESHOLD
; value.
;
; a) STATE == MEASURING_TIME+3
; set by DRUMS_AIN_NotifyChange once the drum output passes the
; THRESHOLD_RISING value or once the new measuring result is greater
; than the last recorded MAX_VALUE
; Exception: don’t record MAX_VALUE if STATE == 0x01
; (On event has already been sent)
;
; b) STATE >= 0x03
; DRUMS_Timer decrements the STATE periodically until it is <= 0x02
;
; c) STATE == 0x02
; DRUMS_Tick sends an “On” event with the maximum value which has
; been recorded by DRUMS_AIN_NotifyChange during STATE was >= 0x03
; Thereafter it sets the STATE to 0x01
;
; d) STATE == 0x01
; DRUMS_AIN_NotifyChange waits until the drum trigger falls below
; the THRESHOLD_FALLING value and sends the “Off” event
; Thereafter it sets the STATE to 0x00
;
; e) STATE == 0x00
; Idle state - DRUMS_AIN_NotifyChange waits until the drum trigger
; passes the THRESHOLD_RISING value again.
; If so, the MAX_VALUE will be updated and the STATE will be
; set to MEASURING_TIME+3 — continue at a)
;
; Exception:
; if the analog signal falls below the THRESHOLD_FALLING value
; during STATE > 1, force state to 0x02, so that an On and Off
; event will be sent
;
Allerdings betraegt die Sample Rate lediglich 200 uS, da der AIN Handler von MIOS so ausgelegt ist, dass er die restlichen Tasks moeglichst wenig stoert. Mit einer zusaetzlichen Hardware (einem sog. Integrator) laesst sich das jedoch relaxen, jedoch auf Kosten der Latenz (immerhin noch < 3 mS)
Admir hat sich auf das Thema spezialisiert und hat eine hochoptimierte Firmware programmiert.
Thorsten.