From ef806d5bd80a9cbd6094c8e816a9b6d71a4084ab Mon Sep 17 00:00:00 2001 From: TurtleP Date: Wed, 14 Sep 2022 13:35:11 -0400 Subject: [PATCH] add various ndspChnGet* methods (#506) --- libctru/include/3ds/ndsp/channel.h | 29 +++++++++++++++++++++++++++++ libctru/source/ndsp/ndsp-channel.c | 20 ++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/libctru/include/3ds/ndsp/channel.h b/libctru/include/3ds/ndsp/channel.h index d3c81b4..e5b0f13 100644 --- a/libctru/include/3ds/ndsp/channel.h +++ b/libctru/include/3ds/ndsp/channel.h @@ -107,6 +107,14 @@ void ndspChnSetPaused(int id, bool paused); */ void ndspChnSetFormat(int id, u16 format); +/** + * + * @brief Gets the format of a channel. + * @param id ID of the channel (0..23). + * @return The format of the channel. + */ +u16 ndspChnGetFormat(int id); + /** * @brief Sets the interpolation type of a channel. * @param id ID of the channel (0..23). @@ -114,6 +122,13 @@ void ndspChnSetFormat(int id, u16 format); */ void ndspChnSetInterp(int id, ndspInterpType type); +/** + * @brief Gets the interpolation type of a channel. + * @param id ID of the channel (0..23). + * @return The interpolation type of the channel. + */ +ndspInterpType ndspChnGetInterp(int id); + /** * @brief Sets the sample rate of a channel. * @param id ID of the channel (0..23). @@ -121,6 +136,13 @@ void ndspChnSetInterp(int id, ndspInterpType type); */ void ndspChnSetRate(int id, float rate); +/** + * @brief Gets the sample rate of a channel. + * @param id ID of the channel (0..23). + * @return The sample rate of the channel. + */ +float ndspChnGetRate(int id); + /** * @brief Sets the mix parameters (volumes) of a channel. * @param id ID of the channel (0..23). @@ -134,6 +156,13 @@ void ndspChnSetRate(int id, float rate); */ void ndspChnSetMix(int id, float mix[12]); +/** + * @brief Gets the mix parameters (volumes) of a channel. + * @param id ID of the channel (0..23) + * @param mix Mix parameters to write out to. See \ref ndspChnSetMix. + */ +void ndspChnGetMix(int id, float* mix[12]); + /** * @brief Sets the DSPADPCM coefficients of a channel. * @param id ID of the channel (0..23). diff --git a/libctru/source/ndsp/ndsp-channel.c b/libctru/source/ndsp/ndsp-channel.c index 3253dee..1a8456b 100644 --- a/libctru/source/ndsp/ndsp-channel.c +++ b/libctru/source/ndsp/ndsp-channel.c @@ -123,6 +123,12 @@ void ndspChnSetInterp(int id, ndspInterpType type) LightLock_Unlock(&chn->lock); } +ndspInterpType ndspChnGetInterp(int id) +{ + ndspChnSt* chn = &ndspChn[id]; + return chn->interpType; +} + void ndspChnSetRate(int id, float rate) { ndspChnSt* chn = &ndspChn[id]; @@ -132,6 +138,12 @@ void ndspChnSetRate(int id, float rate) LightLock_Unlock(&chn->lock); } +float ndspChnGetRate(int id) +{ + ndspChnSt* chn = &ndspChn[id]; + return chn->rate; +} + void ndspChnSetMix(int id, float mix[12]) { ndspChnSt* chn = &ndspChn[id]; @@ -141,6 +153,14 @@ void ndspChnSetMix(int id, float mix[12]) LightLock_Unlock(&chn->lock); } +void ndspChnGetMix(int id, float out_mix[12]) +{ + ndspChnSt* chn = &ndspChn[id]; + LightLock_Lock(&chn->lock); + memcpy(out_mix, chn->mix, sizeof(ndspChn[id].mix)); + LightLock_Unlock(&chn->lock); +} + void ndspChnSetAdpcmCoefs(int id, u16 coefs[16]) { ndspChnSt* chn = &ndspChn[id];