# How Do I Determine When a Sample or Envelope

Samples and envelopes become associated with an instrument by creating an attachment item. You can use the same sample on multiple instruments, or you can use multiple samples on one instrument. What you really need to know is when a specific attachment has finished. There are two ways to do this:

- The first is to call `MonitorAttachment()` to request a signal when the sample or envelope has finished. This method can be used with `WaitSignal()` which lets a task sleep until the attachment is finished.

- The second way is to set the AF_ATTF_FATLADYSINGS flag in the attachment. When the attachment finishes, it stops the associated instrument. You can then poll the instrument by calling `GetAudioItemInfo()` with AF_TAG_STATUS.

Be careful when you are polling for an instrument to finish. Never loop continuously while polling. This is called busy waiting. Busy waiting takes up CPU cycles and can cause a drop in performance or a deadlock.

### For More Information

See Preparing Instruments, for complete programming details.

See Audio Folio Calls, in the 3DO Music and Audio Programmer's Reference for information on these calls.

See the example files ta_attach.c and sample_envelope.c for examples of `MonitorAttachment()` usage.