10 #define CSND_NUM_CHANNELS 32
13 #define CSND_TIMER(n) (0x3FEC3FC / ((u32)(n)))
26 if (vol < 0.0f) vol = 0.0f;
27 else if (vol > 1.0f) vol = 1.0f;
30 if (rpan < 0.0f) rpan = 0.0f;
31 else if (rpan > 1.0f) rpan = 1.0f;
33 lvol = vol*(1-rpan) * 0x8000;
34 rvol = vol*rpan * 0x8000;
35 return lvol | (rvol << 16);
57 #define SOUND_CHANNEL(n) ((u32)(n) & 0x1F)
60 #define SOUND_FORMAT(n) ((u32)(n) << 12)
63 #define SOUND_LOOPMODE(n) ((u32)(n) << 10)
Result CSND_InvalidateDataCache(const void *adr, u32 size)
Invalidates the data cache of a memory region.
static u32 CSND_VOL(float vol, float pan)
Converts a vol-pan pair into a left/right volume pair used by the hardware.
Definition: csnd.h:21
void CSND_SetLooping(u32 channel, u32 value)
Sets whether to loop a channel.
CSND_CapInfo * csndGetCapInfo(u32 capUnit)
Gets a capture unit's information.
Result CSND_FlushDataCache(const void *adr, u32 size)
Flushes the data cache of a memory region.
#define SOUND_FORMAT(n)
Creates a sound format value from an encoding.
Definition: csnd.h:60
void CSND_SetTimer(u32 channel, u32 timer)
Sets a channel's timer.
Result CSND_UpdateInfo(bool waitDone)
Updates CSND information.
Result csndInit(void)
Initializes CSND.
Result csndPlaySound(int chn, u32 flags, u32 sampleRate, float vol, float pan, void *data0, void *data1, u32 size)
Plays a sound.
#define SOUND_LOOPMODE(n)
Creates a sound loop mode value from a loop mode.
Definition: csnd.h:63
Result csndGetState(u32 channel, CSND_ChnInfo *out)
Gets a channel's state.
void CSND_SetEncoding(u32 channel, u32 value)
Sets a channel's encoding.
void CSND_SetChnRegs(u32 flags, u32 physaddr0, u32 physaddr1, u32 totalbytesize, u32 chnVolumes, u32 capVolumes)
Sets CSND's channel registers.
Result CSND_Reset(void)
Resets CSND.
void CSND_SetPlayState(u32 channel, u32 value)
Sets a channel's play state.
CSND_ChnInfo * csndGetChnInfo(u32 channel)
Gets a channel's information.
void CSND_CapEnable(u32 capUnit, bool enable)
Sets whether a capture unit is enabled.
void CSND_SetChnRegsPSG(u32 flags, u32 chnVolumes, u32 capVolumes, CSND_DutyCycle duty)
Sets CSND's PSG channel registers.
void CSND_CapSetBit2(u32 capUnit, bool set)
Sets a capture unit's second bit.
void CSND_SetAdpcmState(u32 channel, int block, int sample, int index)
Sets a channel's ADPCM state.
@ CSND_LOOPMODE_NORMAL
Normal loop.
Definition: csnd.h:51
@ CSND_LOOPMODE_NORELOAD
Don't reload.
Definition: csnd.h:53
@ CSND_LOOPMODE_MANUAL
Manual loop.
Definition: csnd.h:50
@ CSND_LOOPMODE_ONESHOT
Do not loop.
Definition: csnd.h:52
void CSND_SetAdpcmReload(u32 channel, bool reload)
Sets a whether channel's ADPCM data should be reloaded when the second block is played.
void CSND_SetChnRegsNoise(u32 flags, u32 chnVolumes, u32 capVolumes)
Sets CSND's noise channel registers.
void CSND_CapSetRepeat(u32 capUnit, bool repeat)
Sets whether a capture unit should repeat.
@ CAPTURE_FORMAT_8BIT
PCM8.
Definition: csnd.h:84
@ CAPTURE_FORMAT_16BIT
PCM16.
Definition: csnd.h:83
@ CAPTURE_REPEAT
Repeat capture.
Definition: csnd.h:81
@ CAPTURE_ONE_SHOT
Capture once.
Definition: csnd.h:82
@ CAPTURE_ENABLE
Enable capture.
Definition: csnd.h:85
Result CSND_SetDspFlags(bool waitDone)
Sets up DSP flags.
void CSND_SetBit7(u32 channel, bool set)
Sets bit 7 of a channel.
void CSND_SetCapRegs(u32 capUnit, u32 flags, u32 addr, u32 size)
Sets a capture unit's capture registers.
void CSND_CapSetBuffer(u32 capUnit, u32 addr, u32 size)
Sets a capture unit's buffer.
void CSND_SetDuty(u32 channel, CSND_DutyCycle duty)
Sets a channel's duty.
Result csndExecCmds(bool waitDone)
Executes pending CSND commands.
u32 * csndAddCmd(int cmdid)
Adds a command to the list, returning a buffer to write arguments to.
void csndGetDspFlags(u32 *outSemFlags, u32 *outIrqFlags)
Gets CSND's DSP flags.
void CSND_SetInterp(u32 channel, bool interp)
Sets whether a channel should use interpolation.
void CSND_SetPlayStateR(u32 channel, u32 value)
Sets a channel's play state, resetting registers on stop.
Result CSND_ReleaseCapUnit(u32 capUnit)
Releases a capture unit.
CSND_DutyCycle
Duty cycles for a PSG channel.
Definition: csnd.h:90
@ DutyCycle_87
87.5% duty cycle
Definition: csnd.h:98
@ DutyCycle_25
25.0% duty cycle
Definition: csnd.h:93
@ DutyCycle_37
37.5% duty cycle
Definition: csnd.h:94
@ DutyCycle_62
62.5% duty cycle
Definition: csnd.h:96
@ DutyCycle_50
50.0% duty cycle
Definition: csnd.h:95
@ DutyCycle_75
75.0% duty cycle
Definition: csnd.h:97
@ DutyCycle_12
12.5% duty cycle
Definition: csnd.h:92
@ DutyCycle_0
0.0% duty cycle
Definition: csnd.h:91
Result csndIsPlaying(u32 channel, u8 *status)
Gets whether a channel is playing.
void CSND_CapSetTimer(u32 capUnit, u32 timer)
Sets a capture unit's timer.
void CSND_SetVol(u32 channel, u32 chnVolumes, u32 capVolumes)
Sets a channel's volume.
void CSND_CapSetFormat(u32 capUnit, bool eightbit)
Sets a capture unit's format.
vu32 * csndSharedMem
CSND shared memory.
u32 csndSharedMemSize
CSND shared memory size.
Result CSND_StoreDataCache(const void *adr, u32 size)
Stores the data cache of a memory region.
Result CSND_AcquireCapUnit(u32 *capUnit)
Acquires a capture unit.
u32 csndChannels
Bitmask of channels that are allowed for usage.
void CSND_SetBlock(u32 channel, int block, u32 physaddr, u32 size)
Sets the data of a channel's block.
@ SOUND_FORMAT_ADPCM
ADPCM.
Definition: csnd.h:73
@ SOUND_REPEAT
Repeat the sound.
Definition: csnd.h:69
@ SOUND_FORMAT_8BIT
PCM8.
Definition: csnd.h:71
@ SOUND_FORMAT_16BIT
PCM16.
Definition: csnd.h:72
@ SOUND_FORMAT_PSG
PSG.
Definition: csnd.h:74
@ SOUND_LINEAR_INTERP
Linear interpolation.
Definition: csnd.h:68
@ SOUND_ENABLE
Enable sound.
Definition: csnd.h:75
@ SOUND_ONE_SHOT
Play the sound once.
Definition: csnd.h:70
void csndExit(void)
Exits CSND.
@ CSND_ENCODING_PSG
PSG (Similar to DS?)
Definition: csnd.h:44
@ CSND_ENCODING_ADPCM
IMA-ADPCM.
Definition: csnd.h:43
@ CSND_ENCODING_PCM8
PCM8.
Definition: csnd.h:41
@ CSND_ENCODING_PCM16
PCM16.
Definition: csnd.h:42
void csndWriteCmd(int cmdid, u8 *cmdparams)
Adds a command to the list, copying its arguments from a buffer.
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:47
uint8_t u8
would be nice if newlib had this already
Definition: types.h:21
int16_t s16
16-bit signed integer
Definition: types.h:27
volatile u32 vu32
32-bit volatile unsigned integer.
Definition: types.h:33
s32 Result
Function result.
Definition: types.h:42
uint16_t u16
16-bit unsigned integer
Definition: types.h:22
uint32_t u32
32-bit unsigned integer
Definition: types.h:23
Capture info.
Definition: csnd.h:119
u8 active
Capture active.
Definition: csnd.h:123
u16 _pad2
Padding.
Definition: csnd.h:125
u8 _pad1
Padding.
Definition: csnd.h:124
u32 unknownZero
Unknown.
Definition: csnd.h:126
Channel info.
Definition: csnd.h:103
u8 _pad3
Padding.
Definition: csnd.h:112
s16 adpcmSample
Current ADPCM sample.
Definition: csnd.h:110
u8 _pad1
Padding.
Definition: csnd.h:108
u16 _pad2
Padding.
Definition: csnd.h:109
u32 unknownZero
Unknown.
Definition: csnd.h:113
u8 adpcmIndex
Current ADPCM index.
Definition: csnd.h:111
u8 active
Channel active.
Definition: csnd.h:107