# Callbacks

## Defines
#define | CALL __cdecl
## Typedefs
typedef void(CALL * | TECELLA_ERR_CB )(TECELLA_HNDL h, TECELLA_ERRNUM e, const wchar_t *msg)
typedef void(CALL * | TECELLA_ACQUIRE_CB )(TECELLA_HNDL h, int channel, unsigned int samples_available)
typedef void(CALL * | TECELLA_STIMULUS_CB )(TECELLA_HNDL h, int stimulus_index, unsigned long long timestamp)

## Detailed Description

TecellaAmp provides several callback mechanisms for error reporting and acquisition notifications.

## Define Documentation

#define CALL __cdecl

## Typedef Documentation

typedef void(CALL * TECELLA_ACQUIRE_CB)(TECELLA_HNDL h, int channel, unsigned int samples_available)

A callback to recieve notifications of when newly acquired samples are available. Please note that this callback runs in a dedicated acquisition callback thread and it is the user's responsibility to synchronize/lock any communication and memory access from this callback. We recommend using the blocking tecella_acquire_read_i() functions without callbacks if possible.

Parameters:

  | h | The handle of the amplifier the notification applies to.
  | channel | The channel that new samples are available for.
  | samples_available | The number of new samples available since the last time the callback was called for this channel.

See also:
  tecella_acquire_set_callback()

typedef void(CALL * TECELLA_ERR_CB)(TECELLA_HNDL h, TECELLA_ERRNUM e, const wchar_t *msg)

A callback to receive all errors emitted by the API. Very useful for debugging and catching all errors if you accidentally forget to check a return code.

Parameters:

  | h | The handle of the amplifier associated with the error.
  | e | The error code.
  | msg | The error message associated with the error code.

See also:
  tecella_error_set_callback()

typedef void(CALL * TECELLA_STIMULUS_CB)(TECELLA_HNDL h, int stimulus_index, unsigned long long timestamp)

A callback to recieve notifications of when a stimulus has started. Please note that this callback runs in a dedicated acquisition callback thread and it is the user's responsibility to synchronize/lock any communication and memory access from this callback. We recommend using the blocking tecella_acquire_read_i() functions without callbacks if possible.

Parameters:

  | h | The handle of the amplifier the notification applies to.
  | stimulus_index | The stimulus that started playing.
  | timestamp | The sample at which the stimulus started playing, where 0 is the timestamp of the first sample received after calling tecella_acquire_start().

See also:
  tecella_stimulus_set_callback()