# SND_SetupCapture

## Syntax

      #include <nitro/snd.h>

      void SND_SetupCapture(
              SNDCapture capture,
              SNDCaptureFormat format,
              void* buffer_p,
              u32 length,
              BOOL loopFlag,
              SNDCaptureIn in,
              SNDCaptureOut out );

## Arguments

`capture` | The capture identifier.
`format` | The format of the capture data
`buffer_p` | Starting address of the capture buffer. Must have 4-byte alignment.
`length` | The length of the capture buffer. Expressed in units of words. Takes a value of 0 to 0xffff.
`loopFlag` | The loop flag.
`in` | The capture input.
`out` | The capture output.

## Return Values

None.

## Description

This function conducts the setup for captures.

The capture frequency is set by the timer of the corresponding channel. The corresponding channel is locked by the `SND_LockChannel` function, and then its timer is set by `SND_SetChannelTimer` or a similar function. Start capturing with the `SND_StartTimer` function.

Select from among the following values for the capture identifier `capture`:

Table. SNDCapture

Label | Description
--- | ---
SND_CAPTURE_0 | Capture 0. This captures the output from the L mixer or channel 0. The timer is shared with channel 1.
SND_CAPTURE_1 | Capture 1. This captures the output from the R mixer or channel 2. The timer is shared with channel 3.

Select from among the following values for the capture data format `format`:

Table. SNDCaptureFormat

Label | Description
--- | ---
SND_CAPTURE_FORMAT_PCM8 | 8-bit PCM
SND_CAPTURE_FORMAT_PCM16 | 16-bit PCM

The capture buffer's starting address `buffer_p` must have 4-byte alignment.
The capture buffer length `length` is specified in units of words.

If the loop flag `loopFlag` is set to TRUE, the capture will continue again from the start of the buffer when the end of the buffer is reached during the capture. If `loopFlag` is set to FALSE, the capture will halt automatically when the capture reaches the end of the capture buffer.

Select from among the following values for the capture input `in`:

Table. SNDCaptureIn

Label | Description
--- | ---
SND_CAPTURE_IN_MIXER | Captures output from the L mixer or the R mixer.
SND_CAPTURE_IN_CHANNEL | Captures the output from the channel adder.

Select from among the following values for the capture output `out`:

Table. SNDCaptureOut

Label | Description
--- | ---
SND_CAPTURE_OUT_NORMAL | Send channel 1 or channel 3 to normal output.
SND_CAPTURE_OUT_CHANNEL_MIX | Sends channel 1 output or channel 3 output to the respective channel adder. (It is also sent for normal output.)

### Note

There is a problem with the logic for capturing the channel adder output. The capture cannot be done correctly. For details, see the "NITRO Programming Manual."

This function is an ARM7 reserved function. After this function is called, its processing will occur only after the command is issued with the `SND_FlushCommand` function.

If program execution must be synchronized with process completion, first use the `SND_GetCurrentCommandTag` function to obtain the command tag immediately after calling this function. Then, after the command is issued, use the command tag and call either the `SND_IsFinishedCommandTag` or `SND_WaitForCommandProc` function to confirm that processing has finished or to wait for it to complete.

## See Also

`SND_LockChannel, SND_SetChannelTimer, SND_StartTimer, SND_FlushCommand, SND_GetCurrentCommandTag, SND_IsFinishedCommandTag, SND_WaitForCommandProc`

## Revision History

2005/06/13 Made changes following revisions to the NITRO Programming Manual.
2005/02/07 Added notes concerning ARM7 command processing.
2005/01/06 Deleted TEG descriptions.
2004/07/20 Initial version.

CONFIDENTIAL