From fd698bc65313888c689877128d4b489c64f2e85f Mon Sep 17 00:00:00 2001 From: Takamichi Horikawa Date: Mon, 3 Apr 2017 22:19:14 +0900 Subject: pmd: fix PPZ8 loop --- fmdriver/ppz8.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'fmdriver/ppz8.c') diff --git a/fmdriver/ppz8.c b/fmdriver/ppz8.c index 7540ca0..4dea524 100644 --- a/fmdriver/ppz8.c +++ b/fmdriver/ppz8.c @@ -1,8 +1,14 @@ #include "ppz8.h" #include "fmdriver_common.h" -//#include #include +unsigned ppz8_get_mask(const struct ppz8 *ppz8) { + return ppz8->mask; +} +void ppz8_set_mask(struct ppz8 *ppz8, unsigned mask) { + ppz8->mask = mask & 0xffu; +} + void ppz8_init(struct ppz8 *ppz8, uint16_t srate, uint16_t mix_volume) { for (int i = 0; i < 2; i++) { struct ppz8_pcmbuf *buf = &ppz8->buf[i]; @@ -143,6 +149,7 @@ void ppz8_mix(struct ppz8 *ppz8, int16_t *buf, unsigned samples) { struct ppz8_channel *channel = &ppz8->channel[p]; if (!channel->playing) continue; int32_t out = ppz8_channel_calc(ppz8, channel); + if ((1u << p) & (ppz8->mask)) continue; out *= ppz8->mix_volume; out >>= 15; lo += (out * pan_vol[channel->pan][0]) >> 2; @@ -317,8 +324,8 @@ static void ppz8_channel_loop_voice(struct ppz8 *ppz8, uint8_t ch, uint8_t v) { struct ppz8_channel *channel = &ppz8->channel[ch]; struct ppz8_pcmbuf *buf = &ppz8->buf[v>>7]; struct ppz8_pcmvoice *voice = &buf->voice[v & 0x7f]; - channel->loopstartptr = ((uint64_t)(voice->loopstart)>>1)<<16; - channel->loopendptr = ((uint64_t)(voice->loopend)>>1)<<16; + channel->loopstartoff = voice->loopstart; + channel->loopendoff = voice->loopend; } static uint32_t ppz8_voice_length(struct ppz8 *ppz8, uint8_t v) { -- cgit v1.2.3