aboutsummaryrefslogtreecommitdiff
path: root/fmdriver/ppz8.c
diff options
context:
space:
mode:
authorTakamichi Horikawa <takamichiho@gmail.com>2017-04-03 22:19:14 +0900
committerTakamichi Horikawa <takamichiho@gmail.com>2017-04-03 22:19:49 +0900
commitfd698bc65313888c689877128d4b489c64f2e85f (patch)
tree0ad39ba217b1b43ffa1156f7ab81fcb6b186b9aa /fmdriver/ppz8.c
parent4e4ba88b67cc9e891a69d65bbde460e1ba51a39e (diff)
pmd: fix PPZ8 loop
Diffstat (limited to 'fmdriver/ppz8.c')
-rw-r--r--fmdriver/ppz8.c13
1 files changed, 10 insertions, 3 deletions
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 <stdio.h>
#include <string.h>
+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) {