# DeleteInstrument

Frees an instrument and its resources allocated by `CreateInstrument()`.

### Synopsis

`Err DeleteInstrument (Item InstrumentItem)`

### Description

This function frees an instrument allocated by `CreateInstrument()`, which frees the resources allocated for the instrument. If the instrument is running, it is stopped. All of the Attachments, Knobs, and Probes belonging to this Instrument are also deleted by this function. The Envelopes and Samples at the other end of Attachments are not deleted by this function.

If you delete an instrument Template, all Instruments created using that Template are freed, so you don't need to use `DeleteInstrument()` on them.

Do not confuse this function with `UnloadInstrument()`. If you create an Instrument using `LoadInstrument()`, you shouldn't use `DeleteInstrument()` to free the instrument because it will leave the instrument's Template loaded and without access to unload the Template. Use `UnloadInstrument()` instead.

This function is to `CreateInstrument()` as `FreeInstrument()` is to `AllocInstrument()`.

### Arguments

InstrumentItem
  The item number of the instrument to free.

### Return Value

The function returns a non-negative value if successful or an error code (a negative value) if an error occurs.

### Implementation

Folio call implemented in Audio folio V24.

### Associated Files

audio.h

### See Also

``CreateInstrument`(), FreeInstrument(), UnloadInstrument(), UnloadInsTemplate ()`