Audio Interface (AI) API

Introduction
Audio Hardware Configuration
AI DMA

Introduction

The Wii's Audio Interface (AI) manages the transfer of audio data from the DSP (specifically, main memory) to an external digital-analog converter (DAC).

The AI Library API (AI API) provides the following related AI services.

This manual is intended for those who design low-level software for the Nintendo Revolution audio subsystem. Readers must have knowledge about the Revolution hardware architecture, especially the features that pertain to the audio subsystem.

Refer to the AI API Menu for detailed descriptions of the library functions.

Audio Hardware Configuration

The Wii's audio hardware consists of an audio subsystem, AI, and DAC.

Audio Hardware

Audio Subsystem

The audio subsystem consists of a DSP for audio synthesis, a DSP DMA for controlling data transfer between the DSP and main memory, and an AI DMA/FIFO for controlling data transfer from main memory to the AI.

First, the DSP DMA places the audio data that the DSP synthesizes in main memory. Next, the audio data is passed to the AI via the AI DMA/FIFO. At this time, AI API is used for AI DMA control.

Main Memory

The audio hardware can access both internal and external main memory.

AI

The AI consists of a hardware sampling rate converter (SRC) and a DAC interface.

SRC converts the sampling frequency from 32 kHz (fixed) to 48 kHz (fixed) for the audio data that DSP synthesizes. The AI API turns SRC ON/OFF. If the sampling frequency of the audio data is already 48 kHz, SRC is OFF because the sampling frequency doesn't need to be converted.

DAC

The DAC is an external 16-bit stereo DAC that processes audio data at a sampling frequency of 48 kHz (fixed).

AI DMA

The AI DMA transfers audio data from the main memory to the AI via the AI FIFO.

Basic Operations

The AI DMA controller sets the audio data length and registers the main memory address. The AI DMA transfers the audio data from the main memory address to the AI via the AI FIFO (in fact, it transfers 32 Bytes each (=DMA block size) from the main memory via the AI FIFO). The AIInitDMA function is used to register the main memory address and DMA size.

Audio data registered for the AI DMA controller is transferred from main memory to the AI according to the sampling frequency that the AISetDSPSampleRate function sets.

The AISetDSPSampleRate function also turns the AI SRC on and off. SRC is ON if the sampling frequency for audio data AI input (DSP output) is set to 32 kHz using the AISetDSPSampleRate function. SRC is OFF if the sampling frequency for data is set to 48 kHz.

When audio data (with the length that the AIInitDMA function registers) is transferred to the AI, the AI DMA issues a DMA interrupt (AIDINT) to the host CPU (Broadway). The AI library manages this AI DMA interrupt. The AIRegisterDMACallback function can be used to register a callback function to call every time an AI DMA interrupt occurs.

The following is an example of a triple audio buffer.

Triple Audio Buffer

Data Format

The AI DMA transfers audio data in stereo 16-bit PCM (big endian) format. For each sample, data must be interleaved from the right to left channel.

Modifying Data

Usually the audio library (AX) manages the audio buffer in the main memory that becomes the transmission source of an AI DMA transfer. AI API calls are also handled inside the audio library.

The physical address of the audio buffer that the audio library registers using the AIInitDMA function for the AI DMA controller can be obtained using the AIGetDMAStartAddr function. Be sure to convert the physical address that the AIGetDMAStartAddr function retrieves into a logical address using the OSPhysicalToCached function. Similarly, you can obtain the DMA length that was registered using the AIInitDMA function for the AI DMA controller with the AIGetDMALength function.

You can obtain the callback function for AI DMA interrupts registered by the audio library as the return value of the AIRegisterDMACallback function.

Using these functions, you can manipulate audio data that the DSP outputs outside of the audio library.

However, an accurate understanding of how the audio library operates is required to correctly manipulate audio data that the DSP outputs. The sample program THPSimple in the movie library (THP) uses the CPU to mix the movie audio data with the audio data that the audio library (AX) outputs. (File is under the path build/demos/thpdemo/src/THPSimple/THPSimple.c.) Use this example program as a reference for similar processes.

To avoid cache consistency issues, be sure to use the DCInvalidateRange function to invalidate the cache when referencing the audio data that the DSP outputs from the CPU. If changes are to be made by the CPU to audio data output by the DSP, be sure to flush the cache using the DCFlushRange function after the changes are made.

Note: The AX Library calls the AIRegisterDMACallback function from inside the initialization function (for example, inside AXInit). Because of this, any AI DMA interrupt callback set using the AIRegisterDMACallback function before the AX library initialization function was called will be overwritten by the AX callback. If you are using an original AI DMA interrupt callback, be sure to set it using AIRegisterDMACallback only after calling the AX library initialization function.

DSP DMA

The DSP DMA manages the audio library (AX). The DSP DMA cannot be controlled outside of the audio library.

Revision History

2008/12/26 Added a note about the AI DMA interrupt callback.
2006/03/01 Initial version.


CONFIDENTIAL