# Template

A description of an audio instrument.

### Description

A Template is the description of a DSP audio instrument (including the DSP code, resource requirements, parameter settings, etc.) from which Instrument items are created. A Template can either be a standard system instrument template (e.g. envelope.dsp, sampler.dsp, etc) or a custom template created by ARIA.

### Folio

audio

### Item Type

AUDIO_TEMPLATE_NODE

### Create

`CreateInsTemplate()`

`CreateItem()`

`DefineInsTemplate()`

`LoadInsTemplate()`

### Delete

`DeleteItem()`

`UnloadInsTemplate()`

### Use

`AdoptInstrument()`

### Tags

AF_TAG_ALLOC_FUNCTION
  (void *(*)(uint32 memsize, uint32 memflags)) Create. Sets custom memory allocation function to be called during template creation for objects that can be created in user memory. Currently this only applies to samples embedded in ARIA instruments. Defaults to `AllocMem()`. If you supply a custom allocation function you must also provide a custom free function with AF_TAG_FREE_FUNCTION.

AF_TAG_DEVICE
  (Item) Create. Audio device Item for instrument template. 0 indicates the default audio device, the DSP, which is the only valid audio device item at the present time.

AF_TAG_FREE_FUNCTION
  (void (*)(void *memptr, uint32 memsize)) Create. Sets custom memory free function to be called during template deletion. Defaults to `FreeMem()`. If you supply a custom free function you must also provide a custom allocation function with AF_TAG_ALLOC_FUNCTION.

AF_TAG_IMAGE_ADDRESS
  (const char *) Create. Specifies a memory location containing a template file image. Must use in conjunction with AF_TAG_IMAGE_LENGTH. Mutually exclusive AF_TAG_NAME.

AF_TAG_IMAGE_LENGTH
  (uint32) Create. Specifies number of bytes in template file image pointed to by AF_TAG_IMAGE_ADDRESS.

AF_TAG_LEAVE_IN_PLACE
  (bool) Create. When TRUE and used in conjunction with AF_TAG_IMAGE_ADDRESS, causes any user memory objects read from the template file that would otherwise be copied into freshly allocated memory, to be used in-place (i.e. point to a part of the file image instead of allocating more memory). Currently this is only applies to samples embedded in an ARIA instrument. Mutually exclusive with AF_TAG_ALLOC_FUNCTION. See Sample Item and `CreateSample()` for more details and caveats.

Note that sample data may have to be moved down two bytes to align it properly for Portfolio DMA. This will destroy the sample image so that it cannot be reused.

AF_TAG_NAME
  (const char *) Create. Name of template file to load. Mutually exclusive with AF_TAG_IMAGE_ADDRESS.

### See Also

``Instrument`, Attachment`