diff --git a/libctru/include/3ds/ndsp/channel.h b/libctru/include/3ds/ndsp/channel.h index fa92295..443725c 100644 --- a/libctru/include/3ds/ndsp/channel.h +++ b/libctru/include/3ds/ndsp/channel.h @@ -81,6 +81,21 @@ u32 ndspChnGetSamplePos(int id); * @return The sequence ID of the wave buffer. */ u16 ndspChnGetWaveBufSeq(int id); + +/** + * @brief Checks whether a channel is currently paused. + * @param id ID of the channel (0..23). + * @return Whether the channel is currently paused. + */ +bool ndspChnIsPaused(int id); + +/** + * @brief Sets the pause status of a channel. + * @param id ID of the channel (0..23). + * @param paused Whether the channel is to be paused (true) or unpaused (false). + */ +void ndspChnSetPaused(int id, bool paused); + ///@} ///@name Configuration diff --git a/libctru/source/ndsp/ndsp-channel.c b/libctru/source/ndsp/ndsp-channel.c index d7c709f..d9437ee 100644 --- a/libctru/source/ndsp/ndsp-channel.c +++ b/libctru/source/ndsp/ndsp-channel.c @@ -24,7 +24,7 @@ typedef struct ndspWaveBuf* waveBuf; u16 wavBufCount, wavBufIdNext; - bool playing; + bool playing, paused; u8 interpType, iirFilterType; u16 format; @@ -52,6 +52,7 @@ void ndspChnReset(int id) chn->wavBufIdNext = 0; chn->wavBufSeq = 0; chn->playing = false; + chn->paused = false; chn->interpType = 0; chn->iirFilterType = 0; chn->format = NDSP_FORMAT_PCM16; @@ -89,6 +90,20 @@ void ndspChnSetFormat(int id, u16 format) ndspChn[id].format = format; } +bool ndspChnIsPaused(int id) +{ + return ndspChn[id].paused; +} + +void ndspChnSetPaused(int id, bool paused) +{ + ndspChnSt* chn = &ndspChn[id]; + LightLock_Lock(&chn->lock); + chn->paused = paused; + chn->flags |= CFLAG_PLAYSTATUS; + LightLock_Unlock(&chn->lock); +} + void ndspChnSetInterp(int id, ndspInterpType type) { ndspChnSt* chn = &ndspChn[id]; @@ -336,7 +351,7 @@ void ndspiUpdateChn(void) if (flags & CFLAG_PLAYSTATUS) { u16 playStatus = st->playStatus &~ 0xFF; - if (chn->playing) + if (chn->playing && !chn->paused) playStatus |= 1; st->playStatus = playStatus; stflags |= 0x10000;