# WhereAttachment

Returns the current playing location attachment.

### Synopsis

`int32 WhereAttachment (Item Attachment)`

### Description

This function is useful for monitoring the progress of a sample or envelope that's being played. It returns a value indicating where playback is located in the attachment's sample or envelope. For sample attachments, returns the currently playing byte offset of within the sample. For envelope attachments, returns the currently playing segment index.

A sample's offset starts at zero. Note that the offset is not measured in sample frames. You must divide the byte offset by the number of bytes per frame, then discard the remainder to find out which frame is being played.

### Arguments

Attachment
  Item number of the attachment.

### Return Value

Non-negative value indicating position (byte offset of sample or segment index of envelope) on success, negative error code on failure.

### Implementation

SWI implemented in Audio folio V20.

### Caveats

If a sample attachment has finished, the return value may be negative, or greater than the length of the sample. This is because the DMA hardware is pointing to a different sample. To determine whether an attachment has finished, use `MonitorAttachment()`.

### Associated Files

audio.h

### See Also

`MonitorAttachment``()`