# Streaming Stimulus

## Functions
DLLEXPORT TECELLA_ERRNUM CALL | tecella_stimulus_stream_initialize (TECELLA_HNDL h, short *data, int size)
DLLEXPORT TECELLA_ERRNUM CALL | tecella_stimulus_stream_write (TECELLA_HNDL h, short *data, int size)
DLLEXPORT TECELLA_ERRNUM CALL | tecella_stimulus_stream_end (TECELLA_HNDL h)

## Detailed Description

Some amplifiers support streaming stimulus where the stimulus is output at the same sample rate as the response.

## Function Documentation

DLLEXPORT TECELLA_ERRNUM CALL tecella_stimulus_stream_end | ( | TECELLA_HNDL | h | ) |

Indicates that the last sample for the stimulus stream has been written. This is required to prevent erroneous buffer underflow errors from being reported.

Parameters:

  | h | A handle to an initialized device.

DLLEXPORT TECELLA_ERRNUM CALL tecella_stimulus_stream_initialize | ( | TECELLA_HNDL | h,
|  | short * | data,
|  | int | size |
| ) |  |  |

Initializes the streaming of a new stimulus. Should be called before every call to tecella_acquire_start(). If this function is not called, the last stimulus programmed by tecella_stimulus_set() will be used. The first samples in this stimulus will be synchronized to the start of acquisition. The format of the data is amplifier specific. Interface for retreiving format TBD, as only Pico supports streamings stimulus. To be safe, initialize with at least 1 second worth of data to cover any latency issues. For Pico - First Word contains 8 bits of Digital Out, Second Word contains 12 bits of Stimulus, Third word contains 10 bits of Analog Out 1, Fourth Word contains 10 bits of Analog Out 2 TecellaAmps buffer size is 16MB.

Parameters:

  | h | A handle to an initialized device.
  | data | Interpolated samples of output data. (Digital Outs, Stimulus, Analog Out 1...)
  | size | The number of elements in the short being streamed.

See also:
  tecella_stimulus_stream_write()

  tecella_stimulus_stream_end()

DLLEXPORT TECELLA_ERRNUM CALL tecella_stimulus_stream_write | ( | TECELLA_HNDL | h,
|  | short * | data,
|  | int | size |
| ) |  |  |

Appends data to the stimulus stream. After writing the last sample, be sure to call tecella_stimulus_stream_end(). The format of the data is amplifier specific. Interface for retreiving format TBD, as only Pico supports streamings stimulus. For Pico - First Word contains 8 bits of Digital Out, Second Word contains 12 bits of Stimulus, Third word contains 10 bits of Analog Out 1, Fourth Word contains 10 bits of Analog Out 2 TecellaAmps buffer size is 16MB.

Parameters:

  | h | A handle to an initialized device.
  | data | Interpolated samples of output data. (Digital Outs, Stimulus, Analog Out 1...)
  | size | The number of elements in the short being streamed.