From 30c59a00956142aafda87c0bdc71c46d1a2218ff Mon Sep 17 00:00:00 2001 From: Takamichi Horikawa Date: Mon, 27 Mar 2017 23:33:40 +0900 Subject: add oscilloscope view --- libopna/opna.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'libopna/opna.c') diff --git a/libopna/opna.c b/libopna/opna.c index 10155d0..1b0aa6c 100644 --- a/libopna/opna.c +++ b/libopna/opna.c @@ -1,4 +1,6 @@ #include "opna.h" +#include "oscillo/oscillo.h" +#include void opna_reset(struct opna *opna) { opna_fm_reset(&opna->fm); @@ -23,8 +25,20 @@ unsigned opna_readreg(const struct opna *opna, unsigned reg) { } void opna_mix(struct opna *opna, int16_t *buf, unsigned samples) { - opna_fm_mix(&opna->fm, buf, samples); - opna_ssg_mix_55466(&opna->ssg, &opna->resampler, buf, samples); + opna_mix_oscillo(opna, buf, samples, 0); +} + +void opna_mix_oscillo(struct opna *opna, int16_t *buf, unsigned samples, struct oscillodata *oscillo) { + if (oscillo) { + for (int i = 0; i < LIBOPNA_OSCILLO_TRACK_COUNT; i++) { + memmove(&oscillo[i].buf[0], + &oscillo[i].buf[samples], + (OSCILLO_SAMPLE_COUNT - samples)*sizeof(oscillo[i].buf[0])); + } + } + unsigned offset = OSCILLO_SAMPLE_COUNT - samples; + opna_fm_mix(&opna->fm, buf, samples, &oscillo[0], offset); + opna_ssg_mix_55466(&opna->ssg, &opna->resampler, buf, samples, &oscillo[6], offset); opna_drum_mix(&opna->drum, buf, samples); opna_adpcm_mix(&opna->adpcm, buf, samples); } -- cgit v1.2.3