# LoadSampleHere

Loads an AIFC sample from file into RAM allocated and freed by a custom function.

### Synopsis

`Item LoadSampleHere( char *Name, void*(*CustomAllocMem)(),void (*CustomFreeMem)() )`

### Description

This function, like `LoadSample()`, loads and creates a sample item in RAM from a sample stored in the specified file. The major difference is that `LoadSampleHere()` allows a task to use its own memory allocation and deallocation calls to provide RAM for the sample.

To use this task, you must provide a custom allocation function and a custom deallocation function and then specify them in the call. When `LoadSampleHere()` executes, it passes these arguments to the allocation function:

`( int32 NumBytes, uint32 MemType )`

The allocation call should return a DataPtr to the allocated memory if successful or NULL if unsuccessful.

When the sample is later unloaded using `UnloadSample()`, the deallocation function receives these arguments:

`( void *DataPtr, int32 NumBytes)`

The deallocation function must use these arguments to free the sample's memory.

### Arguments

Name
  Name of an AIFF or AIFC file to be loaded.

`CustomAllocMem()`
  A custom memory-allocation function.

`CustomFreeMem()`
  A custom memory-freeing function.

### Return Value

The function returns the item number of the sample if successful 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

`AttachSample``(), DetachSample(), SetAudioItemInfo(), UnloadSample(), DebugSample(), CreateSample(), ScanSample(), GetAudioItemInfo(), LoadSample()`