libctru
v2.4.1
|
Functions for interacting with DSP audio channels. More...
Go to the source code of this file.
Functions | |
Basic channel operation | |
void | ndspChnReset (int id) |
Resets a channel. More... | |
void | ndspChnInitParams (int id) |
Initializes the parameters of a channel. More... | |
bool | ndspChnIsPlaying (int id) |
Checks whether a channel is currently playing. More... | |
u32 | ndspChnGetSamplePos (int id) |
Gets the current sample position of a channel. More... | |
u16 | ndspChnGetWaveBufSeq (int id) |
Gets the sequence ID of the wave buffer that is currently playing in a channel. More... | |
bool | ndspChnIsPaused (int id) |
Checks whether a channel is currently paused. More... | |
void | ndspChnSetPaused (int id, bool paused) |
Sets the pause status of a channel. More... | |
Configuration | |
void | ndspChnSetFormat (int id, u16 format) |
Sets the format of a channel. More... | |
u16 | ndspChnGetFormat (int id) |
Gets the format of a channel. More... | |
void | ndspChnSetInterp (int id, ndspInterpType type) |
Sets the interpolation type of a channel. More... | |
ndspInterpType | ndspChnGetInterp (int id) |
Gets the interpolation type of a channel. More... | |
void | ndspChnSetRate (int id, float rate) |
Sets the sample rate of a channel. More... | |
float | ndspChnGetRate (int id) |
Gets the sample rate of a channel. More... | |
void | ndspChnSetMix (int id, float mix[12]) |
Sets the mix parameters (volumes) of a channel. More... | |
void | ndspChnGetMix (int id, float mix[12]) |
Gets the mix parameters (volumes) of a channel. More... | |
void | ndspChnSetAdpcmCoefs (int id, u16 coefs[16]) |
Sets the DSPADPCM coefficients of a channel. More... | |
Wave buffers | |
void | ndspChnWaveBufClear (int id) |
Clears the wave buffer queue of a channel and stops playback. More... | |
void | ndspChnWaveBufAdd (int id, ndspWaveBuf *buf) |
Adds a wave buffer to the wave buffer queue of a channel. More... | |
IIR filters | |
void | ndspChnIirMonoSetEnable (int id, bool enable) |
Configures whether the IIR monopole filter of a channel is enabled. More... | |
bool | ndspChnIirMonoSetParamsCustomFilter (int id, float a0, float a1, float b0) |
Manually sets up the parameters on monopole filter. More... | |
bool | ndspChnIirMonoSetParamsLowPassFilter (int id, float f0) |
Sets the monopole to be a low pass filter. More... | |
bool | ndspChnIirMonoSetParamsHighPassFilter (int id, float f0) |
Sets the monopole to be a high pass filter. More... | |
void | ndspChnIirBiquadSetEnable (int id, bool enable) |
Configures whether the IIR biquad filter of a channel is enabled. More... | |
bool | ndspChnIirBiquadSetParamsCustomFilter (int id, float a0, float a1, float a2, float b0, float b1, float b2) |
Manually sets up the parameters of the biquad filter. More... | |
bool | ndspChnIirBiquadSetParamsLowPassFilter (int id, float f0, float Q) |
Sets the biquad to be a low pass filter. More... | |
bool | ndspChnIirBiquadSetParamsHighPassFilter (int id, float f0, float Q) |
Sets the biquad to be a high pass filter. More... | |
bool | ndspChnIirBiquadSetParamsBandPassFilter (int id, float f0, float Q) |
Sets the biquad to be a band pass filter. More... | |
bool | ndspChnIirBiquadSetParamsNotchFilter (int id, float f0, float Q) |
Sets the biquad to be a notch filter. More... | |
bool | ndspChnIirBiquadSetParamsPeakingEqualizer (int id, float f0, float Q, float gain) |
Sets the biquad to be a peaking equalizer. More... | |
Data types | |
#define | NDSP_CHANNELS(n) ((u32)(n) & 3) |
Specifies the number of channels used in a sample. | |
#define | NDSP_ENCODING(n) (((u32)(n) & 3) << 2) |
Specifies the encoding used in a sample. | |
enum | { NDSP_ENCODING_PCM8 = 0 , NDSP_ENCODING_PCM16 , NDSP_ENCODING_ADPCM } |
enum | { NDSP_FORMAT_MONO_PCM8 = NDSP_CHANNELS(1) | NDSP_ENCODING(NDSP_ENCODING_PCM8) , NDSP_FORMAT_MONO_PCM16 = NDSP_CHANNELS(1) | NDSP_ENCODING(NDSP_ENCODING_PCM16) , NDSP_FORMAT_MONO_ADPCM = NDSP_CHANNELS(1) | NDSP_ENCODING(NDSP_ENCODING_ADPCM) , NDSP_FORMAT_STEREO_PCM8 = NDSP_CHANNELS(2) | NDSP_ENCODING(NDSP_ENCODING_PCM8) , NDSP_FORMAT_STEREO_PCM16 = NDSP_CHANNELS(2) | NDSP_ENCODING(NDSP_ENCODING_PCM16) , NDSP_FORMAT_PCM8 = NDSP_FORMAT_MONO_PCM8 , NDSP_FORMAT_PCM16 = NDSP_FORMAT_MONO_PCM16 , NDSP_FORMAT_ADPCM = NDSP_FORMAT_MONO_ADPCM , NDSP_FRONT_BYPASS = BIT(4) , NDSP_3D_SURROUND_PREPROCESSED = BIT(6) } |
Channel format flags for use with ndspChnSetFormat. More... | |
enum | ndspInterpType { NDSP_INTERP_POLYPHASE = 0 , NDSP_INTERP_LINEAR = 1 , NDSP_INTERP_NONE = 2 } |
Interpolation types. More... | |
Functions for interacting with DSP audio channels.
anonymous enum |
anonymous enum |
Channel format flags for use with ndspChnSetFormat.
enum ndspInterpType |
u16 ndspChnGetFormat | ( | int | id | ) |
Gets the format of a channel.
id | ID of the channel (0..23). |
ndspInterpType ndspChnGetInterp | ( | int | id | ) |
Gets the interpolation type of a channel.
id | ID of the channel (0..23). |
void ndspChnGetMix | ( | int | id, |
float | mix[12] | ||
) |
Gets the mix parameters (volumes) of a channel.
id | ID of the channel (0..23) |
mix | Mix parameters to write out to. See ndspChnSetMix. |
float ndspChnGetRate | ( | int | id | ) |
Gets the sample rate of a channel.
id | ID of the channel (0..23). |
u32 ndspChnGetSamplePos | ( | int | id | ) |
Gets the current sample position of a channel.
id | ID of the channel (0..23). |
u16 ndspChnGetWaveBufSeq | ( | int | id | ) |
Gets the sequence ID of the wave buffer that is currently playing in a channel.
id | ID of the channel (0..23). |
void ndspChnIirBiquadSetEnable | ( | int | id, |
bool | enable | ||
) |
Configures whether the IIR biquad filter of a channel is enabled.
id | ID of the channel (0..23). |
enable | Whether to enable the IIR biquad filter. |
bool ndspChnIirBiquadSetParamsBandPassFilter | ( | int | id, |
float | f0, | ||
float | Q | ||
) |
Sets the biquad to be a band pass filter.
id | ID of the channel (0..23). |
f0 | Mid-frequency. |
Q | "Quality factor", typically should be sqrt(2)/2 (i.e. 0.7071). |
bool ndspChnIirBiquadSetParamsCustomFilter | ( | int | id, |
float | a0, | ||
float | a1, | ||
float | a2, | ||
float | b0, | ||
float | b1, | ||
float | b2 | ||
) |
Manually sets up the parameters of the biquad filter.
id | ID of the channel (0..23). |
bool ndspChnIirBiquadSetParamsHighPassFilter | ( | int | id, |
float | f0, | ||
float | Q | ||
) |
Sets the biquad to be a high pass filter.
id | ID of the channel (0..23). |
f0 | High pass cut-off frequency. |
Q | "Quality factor", typically should be sqrt(2)/2 (i.e. 0.7071). |
bool ndspChnIirBiquadSetParamsLowPassFilter | ( | int | id, |
float | f0, | ||
float | Q | ||
) |
Sets the biquad to be a low pass filter.
id | ID of the channel (0..23). |
f0 | Low pass cut-off frequency. |
Q | "Quality factor", typically should be sqrt(2)/2 (i.e. 0.7071). |
bool ndspChnIirBiquadSetParamsNotchFilter | ( | int | id, |
float | f0, | ||
float | Q | ||
) |
Sets the biquad to be a notch filter.
id | ID of the channel (0..23). |
f0 | Notch frequency. |
Q | "Quality factor", typically should be sqrt(2)/2 (i.e. 0.7071). |
bool ndspChnIirBiquadSetParamsPeakingEqualizer | ( | int | id, |
float | f0, | ||
float | Q, | ||
float | gain | ||
) |
Sets the biquad to be a peaking equalizer.
id | ID of the channel (0..23). |
f0 | Central frequency. |
Q | "Quality factor", typically should be sqrt(2)/2 (i.e. 0.7071). |
gain | Amount of gain (raw value = 10 ^ dB/40) |
void ndspChnIirMonoSetEnable | ( | int | id, |
bool | enable | ||
) |
Configures whether the IIR monopole filter of a channel is enabled.
id | ID of the channel (0..23). |
enable | Whether to enable the IIR monopole filter. |
bool ndspChnIirMonoSetParamsCustomFilter | ( | int | id, |
float | a0, | ||
float | a1, | ||
float | b0 | ||
) |
Manually sets up the parameters on monopole filter.
id | ID of the channel (0..23). |
enable | Whether to enable the IIR monopole filter. |
bool ndspChnIirMonoSetParamsHighPassFilter | ( | int | id, |
float | f0 | ||
) |
Sets the monopole to be a high pass filter.
(Note: This is a lower-quality filter than the biquad one.)
id | ID of the channel (0..23). |
f0 | High pass cut-off frequency. |
bool ndspChnIirMonoSetParamsLowPassFilter | ( | int | id, |
float | f0 | ||
) |
Sets the monopole to be a low pass filter.
(Note: This is a lower-quality filter than the biquad one.)
id | ID of the channel (0..23). |
f0 | Low pass cut-off frequency. |
void ndspChnInitParams | ( | int | id | ) |
Initializes the parameters of a channel.
id | ID of the channel (0..23). |
bool ndspChnIsPaused | ( | int | id | ) |
Checks whether a channel is currently paused.
id | ID of the channel (0..23). |
bool ndspChnIsPlaying | ( | int | id | ) |
Checks whether a channel is currently playing.
id | ID of the channel (0..23). |
void ndspChnReset | ( | int | id | ) |
Resets a channel.
id | ID of the channel (0..23). |
void ndspChnSetAdpcmCoefs | ( | int | id, |
u16 | coefs[16] | ||
) |
Sets the DSPADPCM coefficients of a channel.
id | ID of the channel (0..23). |
coefs | DSPADPCM coefficients to use. |
void ndspChnSetFormat | ( | int | id, |
u16 | format | ||
) |
Sets the format of a channel.
id | ID of the channel (0..23). |
format | Format to use. |
void ndspChnSetInterp | ( | int | id, |
ndspInterpType | type | ||
) |
Sets the interpolation type of a channel.
id | ID of the channel (0..23). |
type | Interpolation type to use. |
void ndspChnSetMix | ( | int | id, |
float | mix[12] | ||
) |
Sets the mix parameters (volumes) of a channel.
id | ID of the channel (0..23). |
mix | Mix parameters to use. Working hypothesis:
|
void ndspChnSetPaused | ( | int | id, |
bool | paused | ||
) |
Sets the pause status of a channel.
id | ID of the channel (0..23). |
paused | Whether the channel is to be paused (true) or unpaused (false). |
void ndspChnSetRate | ( | int | id, |
float | rate | ||
) |
Sets the sample rate of a channel.
id | ID of the channel (0..23). |
rate | Sample rate to use. |
void ndspChnWaveBufAdd | ( | int | id, |
ndspWaveBuf * | buf | ||
) |
Adds a wave buffer to the wave buffer queue of a channel.
id | ID of the channel (0..23). |
buf | Wave buffer to add. |
void ndspChnWaveBufClear | ( | int | id | ) |
Clears the wave buffer queue of a channel and stops playback.
id | ID of the channel (0..23). |