# DefineSampleHere

Defines a sample from a data stream.

### Synopsis

`Item DefineSampleHere( uint8 *AIFFImage, int32 NumBytes,void *(*CustomAllocMem)(), void (*CustomFreeMem)() )`

### Description

This call uses a custom allocation function to allocate memory for a sample buffer. It then finds an image of an AIFF file contained within a data stream and creates a sample using that image, placing the sample in the allocated memory. The function specifies a custom memory-deallocation function to be called when the sample is unloaded.

See the description of `LoadSampleHere()` for the parameters passed to the custom memory calls.

When you finish with the created sample, you should call `UnloadSample()` to deallocate its resources. After you have called `DefineSampleHere()`, the image that you have read is no longer needed and can be freed.

### Arguments

AIFFImage
  Pointer to the AIFF image in RAM.

NumBytes
  Value specifying the number of bytes in the sample.

CustomAllocMem
  Pointer to a custom memory-allocation function.

CustomFreeMem
  Pointer to a custom memory-freeing function.

### Return Value

This returns the item number of the sample or an error code (a negative value) if an error occurs.

### Implementation

Folio call implemented in Audio folio V20.

### Associated Files

audio.h

### See Also

``DefineInsTemplate`()`