Once the library has been initialized all of the library functions can be used, but at this point no data has been prepared yet. Here we make the preparations in order to make each data set usable in sequence.
First we DMA transfer the data from ROM that needs to be placed in RAM. The function used to secure a memory area in RAM from the audio heap is nuAuStlHeapAlloc.
Reserve memory from the audio heap
Function name: | nuAuStlHeapAlloc |
Syntax: | void *nuAuStlHeapAlloc(s32 length) |
Arguments: | length The size of memory secured from the heap |
Return value: | Pointer to the reserved heap memory |
Next we use nuPiReadRom to transfer the data to the reserved area.
Load data from ROM
Function name: | nuPiReadRom | ||||||
Syntax: | void nuPiReadRom(u32 rom_addr, void* buf_ptr, u32 size) | ||||||
Arguments: |
|
||||||
Return value: | None |
(*)Be sure that the size is an even number of bytes.
There are also two functions that can be used to find out the present state of the heap
Return the previously used sizes with audio heap
Function name: | nuAuStlGetHeapUsed |
Syntax: | s32 nuAuStlGetHeapUsed(void) |
Arguments: | None |
Return value: | Size of audio heap being used |
Return sizes with audio heap still available
Function name: | nuAuStlGetHeapFree |
Syntax: | s32 nuAuStlGetHeapFree(void) |
Arguments: | None |
Return value: | Size of audio heap remaining |
Next, we perform the necessary initialization of the Sound Effect Bank and Sample Bank from among the data to be used for audio playback. The first items initialized automatically become the default banks. For songs, all you have to do is place the data in RAM, and no initialization is necessary.
Initialize Sound Effect Bank
Function name: | MusFxBankInitialize | |
Syntax: | void MusFxBankInitialize(void *fxbank) | |
Arguments: | fxbank | Address of sound effect bank in RAM |
Return value: | None |
Initialize a sample bank
Function name: | MusPtrBankInitialize | ||||
Syntax: | void MusPtrBankInitialize(void *pbank, void *wbank) | ||||
Arguments: |
| ||||
Return value: | None |