libctru
v2.4.1
|
CSND service. More...
#include <3ds/types.h>
Go to the source code of this file.
Data Structures | |
union | CSND_ChnInfo |
Channel info. More... | |
union | CSND_CapInfo |
Capture info. More... | |
Macros | |
#define | CSND_NUM_CHANNELS 32 |
Maximum number of CSND channels. | |
#define | CSND_TIMER(n) (0x3FEC3FC / ((u32)(n))) |
Creates a CSND timer value from a sample rate. | |
#define | SOUND_CHANNEL(n) ((u32)(n) & 0x1F) |
Creates a sound channel value from a channel number. | |
#define | SOUND_FORMAT(n) ((u32)(n) << 12) |
Creates a sound format value from an encoding. | |
#define | SOUND_LOOPMODE(n) ((u32)(n) << 10) |
Creates a sound loop mode value from a loop mode. | |
Enumerations | |
enum | { CSND_ENCODING_PCM8 = 0 , CSND_ENCODING_PCM16 , CSND_ENCODING_ADPCM , CSND_ENCODING_PSG } |
CSND encodings. More... | |
enum | { CSND_LOOPMODE_MANUAL = 0 , CSND_LOOPMODE_NORMAL , CSND_LOOPMODE_ONESHOT , CSND_LOOPMODE_NORELOAD } |
CSND loop modes. More... | |
enum | { SOUND_LINEAR_INTERP = BIT(6) , SOUND_REPEAT = SOUND_LOOPMODE(CSND_LOOPMODE_NORMAL) , SOUND_ONE_SHOT = SOUND_LOOPMODE(CSND_LOOPMODE_ONESHOT) , SOUND_FORMAT_8BIT = SOUND_FORMAT(CSND_ENCODING_PCM8) , SOUND_FORMAT_16BIT = SOUND_FORMAT(CSND_ENCODING_PCM16) , SOUND_FORMAT_ADPCM = SOUND_FORMAT(CSND_ENCODING_ADPCM) , SOUND_FORMAT_PSG = SOUND_FORMAT(CSND_ENCODING_PSG) , SOUND_ENABLE = BIT(14) } |
Sound flags. More... | |
enum | { CAPTURE_REPEAT = 0 , CAPTURE_ONE_SHOT = BIT(0) , CAPTURE_FORMAT_16BIT = 0 , CAPTURE_FORMAT_8BIT = BIT(1) , CAPTURE_ENABLE = BIT(15) } |
Capture modes. More... | |
enum | CSND_DutyCycle { DutyCycle_0 = 7 , DutyCycle_12 = 0 , DutyCycle_25 = 1 , DutyCycle_37 = 2 , DutyCycle_50 = 3 , DutyCycle_62 = 4 , DutyCycle_75 = 5 , DutyCycle_87 = 6 } |
Duty cycles for a PSG channel. More... | |
Functions | |
static u32 | CSND_VOL (float vol, float pan) |
Converts a vol-pan pair into a left/right volume pair used by the hardware. More... | |
Result | CSND_AcquireCapUnit (u32 *capUnit) |
Acquires a capture unit. More... | |
Result | CSND_ReleaseCapUnit (u32 capUnit) |
Releases a capture unit. More... | |
Result | CSND_FlushDataCache (const void *adr, u32 size) |
Flushes the data cache of a memory region. More... | |
Result | CSND_StoreDataCache (const void *adr, u32 size) |
Stores the data cache of a memory region. More... | |
Result | CSND_InvalidateDataCache (const void *adr, u32 size) |
Invalidates the data cache of a memory region. More... | |
Result | CSND_Reset (void) |
Resets CSND. More... | |
Result | csndInit (void) |
Initializes CSND. | |
void | csndExit (void) |
Exits CSND. | |
u32 * | csndAddCmd (int cmdid) |
Adds a command to the list, returning a buffer to write arguments to. More... | |
void | csndWriteCmd (int cmdid, u8 *cmdparams) |
Adds a command to the list, copying its arguments from a buffer. More... | |
Result | csndExecCmds (bool waitDone) |
Executes pending CSND commands. More... | |
void | CSND_SetPlayStateR (u32 channel, u32 value) |
Sets a channel's play state, resetting registers on stop. More... | |
void | CSND_SetPlayState (u32 channel, u32 value) |
Sets a channel's play state. More... | |
void | CSND_SetEncoding (u32 channel, u32 value) |
Sets a channel's encoding. More... | |
void | CSND_SetBlock (u32 channel, int block, u32 physaddr, u32 size) |
Sets the data of a channel's block. More... | |
void | CSND_SetLooping (u32 channel, u32 value) |
Sets whether to loop a channel. More... | |
void | CSND_SetBit7 (u32 channel, bool set) |
Sets bit 7 of a channel. More... | |
void | CSND_SetInterp (u32 channel, bool interp) |
Sets whether a channel should use interpolation. More... | |
void | CSND_SetDuty (u32 channel, CSND_DutyCycle duty) |
Sets a channel's duty. More... | |
void | CSND_SetTimer (u32 channel, u32 timer) |
Sets a channel's timer. More... | |
void | CSND_SetVol (u32 channel, u32 chnVolumes, u32 capVolumes) |
Sets a channel's volume. More... | |
void | CSND_SetAdpcmState (u32 channel, int block, int sample, int index) |
Sets a channel's ADPCM state. More... | |
void | CSND_SetAdpcmReload (u32 channel, bool reload) |
Sets a whether channel's ADPCM data should be reloaded when the second block is played. More... | |
void | CSND_SetChnRegs (u32 flags, u32 physaddr0, u32 physaddr1, u32 totalbytesize, u32 chnVolumes, u32 capVolumes) |
Sets CSND's channel registers. More... | |
void | CSND_SetChnRegsPSG (u32 flags, u32 chnVolumes, u32 capVolumes, CSND_DutyCycle duty) |
Sets CSND's PSG channel registers. More... | |
void | CSND_SetChnRegsNoise (u32 flags, u32 chnVolumes, u32 capVolumes) |
Sets CSND's noise channel registers. More... | |
void | CSND_CapEnable (u32 capUnit, bool enable) |
Sets whether a capture unit is enabled. More... | |
void | CSND_CapSetRepeat (u32 capUnit, bool repeat) |
Sets whether a capture unit should repeat. More... | |
void | CSND_CapSetFormat (u32 capUnit, bool eightbit) |
Sets a capture unit's format. More... | |
void | CSND_CapSetBit2 (u32 capUnit, bool set) |
Sets a capture unit's second bit. More... | |
void | CSND_CapSetTimer (u32 capUnit, u32 timer) |
Sets a capture unit's timer. More... | |
void | CSND_CapSetBuffer (u32 capUnit, u32 addr, u32 size) |
Sets a capture unit's buffer. More... | |
void | CSND_SetCapRegs (u32 capUnit, u32 flags, u32 addr, u32 size) |
Sets a capture unit's capture registers. More... | |
Result | CSND_SetDspFlags (bool waitDone) |
Sets up DSP flags. More... | |
Result | CSND_UpdateInfo (bool waitDone) |
Updates CSND information. More... | |
Result | csndPlaySound (int chn, u32 flags, u32 sampleRate, float vol, float pan, void *data0, void *data1, u32 size) |
Plays a sound. More... | |
void | csndGetDspFlags (u32 *outSemFlags, u32 *outIrqFlags) |
Gets CSND's DSP flags. More... | |
CSND_ChnInfo * | csndGetChnInfo (u32 channel) |
Gets a channel's information. More... | |
CSND_CapInfo * | csndGetCapInfo (u32 capUnit) |
Gets a capture unit's information. More... | |
Result | csndGetState (u32 channel, CSND_ChnInfo *out) |
Gets a channel's state. More... | |
Result | csndIsPlaying (u32 channel, u8 *status) |
Gets whether a channel is playing. More... | |
Variables | |
vu32 * | csndSharedMem |
CSND shared memory. | |
u32 | csndSharedMemSize |
CSND shared memory size. | |
u32 | csndChannels |
Bitmask of channels that are allowed for usage. | |
CSND service.
Usage of this service is deprecated in favor of NDSP.
anonymous enum |
anonymous enum |
anonymous enum |
anonymous enum |
enum CSND_DutyCycle |
Acquires a capture unit.
capUnit | Pointer to output the capture unit to. |
void CSND_CapEnable | ( | u32 | capUnit, |
bool | enable | ||
) |
Sets whether a capture unit is enabled.
capUnit | Capture unit to use. |
enable | Whether to enable the capture unit. |
void CSND_CapSetBit2 | ( | u32 | capUnit, |
bool | set | ||
) |
Sets a capture unit's second bit.
capUnit | Capture unit to use. |
set | Value to set. |
Sets a capture unit's buffer.
capUnit | Capture unit to use. |
addr | Buffer address to use. |
size | Size of the buffer. |
void CSND_CapSetFormat | ( | u32 | capUnit, |
bool | eightbit | ||
) |
Sets a capture unit's format.
capUnit | Capture unit to use. |
eightbit | Format to use. |
void CSND_CapSetRepeat | ( | u32 | capUnit, |
bool | repeat | ||
) |
Sets whether a capture unit should repeat.
capUnit | Capture unit to use. |
repeat | Whether the capture unit should repeat. |
Sets a capture unit's timer.
capUnit | Capture unit to use. |
timer | Timer to set. |
Flushes the data cache of a memory region.
adr | Address of the memory region. |
size | Size of the memory region. |
Invalidates the data cache of a memory region.
adr | Address of the memory region. |
size | Size of the memory region. |
Releases a capture unit.
capUnit | Capture unit to release. |
Result CSND_Reset | ( | void | ) |
Resets CSND.
Note: Currently breaks sound, don't use for now!
void CSND_SetAdpcmReload | ( | u32 | channel, |
bool | reload | ||
) |
Sets a whether channel's ADPCM data should be reloaded when the second block is played.
channel | Channel to use. |
reload | Whether to reload ADPCM data. |
void CSND_SetAdpcmState | ( | u32 | channel, |
int | block, | ||
int | sample, | ||
int | index | ||
) |
Sets a channel's ADPCM state.
channel | Channel to use. |
block | Current block. |
sample | Current sample. |
index | Current index. |
void CSND_SetBit7 | ( | u32 | channel, |
bool | set | ||
) |
Sets bit 7 of a channel.
channel | Channel to use. |
set | Value to set. |
Sets the data of a channel's block.
channel | Channel to use. |
block | Block to set. |
physaddr | Physical address to set the block to. |
size | Size of the block. |
Sets a capture unit's capture registers.
capUnit | Capture unit to use. |
flags | Capture unit flags. |
addr | Capture unit buffer address. |
size | Buffer size. |
void CSND_SetChnRegs | ( | u32 | flags, |
u32 | physaddr0, | ||
u32 | physaddr1, | ||
u32 | totalbytesize, | ||
u32 | chnVolumes, | ||
u32 | capVolumes | ||
) |
Sets CSND's channel registers.
flags | Flags to set. |
physaddr0 | Physical address of the first buffer to play. |
physaddr1 | Physical address of the second buffer to play. |
totalbytesize | Total size of the data to play. |
chnVolumes | Channel volume data. |
capVolumes | Capture volume data. |
Sets CSND's noise channel registers.
flags | Flags to set. |
chnVolumes | Channel volume data. |
capVolumes | Capture volume data. |
void CSND_SetChnRegsPSG | ( | u32 | flags, |
u32 | chnVolumes, | ||
u32 | capVolumes, | ||
CSND_DutyCycle | duty | ||
) |
Sets CSND's PSG channel registers.
flags | Flags to set. |
chnVolumes | Channel volume data. |
capVolumes | Capture volume data. |
duty | Duty value to set. |
Result CSND_SetDspFlags | ( | bool | waitDone | ) |
Sets up DSP flags.
waitDone | Whether to wait for completion. |
void CSND_SetDuty | ( | u32 | channel, |
CSND_DutyCycle | duty | ||
) |
Sets a channel's duty.
channel | Channel to use. |
duty | Duty to set. |
Sets a channel's encoding.
channel | Channel to use. |
value | Encoding to set. |
void CSND_SetInterp | ( | u32 | channel, |
bool | interp | ||
) |
Sets whether a channel should use interpolation.
channel | Channel to use. |
interp | Whether to use interpolation. |
Sets whether to loop a channel.
channel | Channel to use. |
value | Whether to loop the channel. |
Sets a channel's play state.
channel | Channel to use. |
value | Play state to set. |
Sets a channel's play state, resetting registers on stop.
channel | Channel to use. |
value | Play state to set. |
Sets a channel's timer.
channel | Channel to use. |
timer | Timer to set. |
Sets a channel's volume.
channel | Channel to use. |
chnVolumes | Channel volume data to set. |
capVolumes | Capture volume data to set. |
Stores the data cache of a memory region.
adr | Address of the memory region. |
size | Size of the memory region. |
Result CSND_UpdateInfo | ( | bool | waitDone | ) |
Updates CSND information.
waitDone | Whether to wait for completion. |
|
inlinestatic |
Converts a vol-pan pair into a left/right volume pair used by the hardware.
vol | Volume to use. |
pan | Pan to use. |
u32* csndAddCmd | ( | int | cmdid | ) |
Adds a command to the list, returning a buffer to write arguments to.
cmdid | ID of the command to add. |
Result csndExecCmds | ( | bool | waitDone | ) |
Executes pending CSND commands.
waitDone | Whether to wait until the commands have finished executing. |
CSND_CapInfo* csndGetCapInfo | ( | u32 | capUnit | ) |
Gets a capture unit's information.
Note: Requires previous CSND_UpdateInfo()
capUnit | Capture unit to get information for. |
CSND_ChnInfo* csndGetChnInfo | ( | u32 | channel | ) |
Gets a channel's information.
Note: Requires previous CSND_UpdateInfo()
channel | Channel to get information for. |
Gets CSND's DSP flags.
Note: Requires previous CSND_UpdateInfo()
outSemFlags | Pointer to write semaphore flags to. |
outIrqFlags | Pointer to write interrupt flags to. |
Result csndGetState | ( | u32 | channel, |
CSND_ChnInfo * | out | ||
) |
Gets a channel's state.
channel | Channel to get the state of. |
out | Pointer to output channel information to. |
Gets whether a channel is playing.
channel | Channel to check. |
status | Pointer to output the channel status to. |
Result csndPlaySound | ( | int | chn, |
u32 | flags, | ||
u32 | sampleRate, | ||
float | vol, | ||
float | pan, | ||
void * | data0, | ||
void * | data1, | ||
u32 | size | ||
) |
Plays a sound.
chn | Channel to play the sound on. |
flags | Flags containing information about the sound. |
sampleRate | Sample rate of the sound. |
vol | The volume, ranges from 0.0 to 1.0 included. |
pan | The pan, ranges from -1.0 to 1.0 included. |
data0 | First block of sound data. |
data1 | Second block of sound data. This is the block that will be looped over. |
size | Size of the sound data. |
In this implementation if the loop mode is used, data1 must be in the range [data0 ; data0 + size]. Sound will be played once from data0 to data0 + size and then loop between data1 and data0+size.
void csndWriteCmd | ( | int | cmdid, |
u8 * | cmdparams | ||
) |
Adds a command to the list, copying its arguments from a buffer.
cmdid | ID of the command to add. |
cmdparams | Buffer containing the command's parameters. |