diff options
author | Takamichi Horikawa <takamichiho@gmail.com> | 2017-03-27 23:33:40 +0900 |
---|---|---|
committer | Takamichi Horikawa <takamichiho@gmail.com> | 2017-03-27 23:33:40 +0900 |
commit | 30c59a00956142aafda87c0bdc71c46d1a2218ff (patch) | |
tree | 0bf1c81767dc8edb86ade2a4e224392e2ac5280b /libopna/opna.c | |
parent | 0073f2b8befc6163f2970cb7a01e75fffc95994e (diff) |
add oscilloscope view
Diffstat (limited to 'libopna/opna.c')
-rw-r--r-- | libopna/opna.c | 18 |
1 files changed, 16 insertions, 2 deletions
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 <string.h> 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); } |