Hello Lena,
In each state definition, you can set the state of the state machine's output channels. The outputs are set on entering the state, so you can use the state timestamp for alignment. For instance, given the following state:
sma = AddState(sma, 'Name', 'Pulse', ...
'Timer', 0.001,...
'StateChangeConditions', {'Tup', '>exit'},...
'OutputActions', {'BNC1', 1});
The TTL pulse onset timestamp on trial 2 would be:
SessionData.RawEvents.Trial{2}.States.Pulse(1)
The HiFi module sends an event back to the state machine when the sound actually plays, for a record of sound onset latency. The HiFi module's TTL output can be patched back to the state machine or to your acquisition system for additional measures of sound onset and offset time.
I hope this helps,
Josh