From 6fd10cdacb5cbe47a4fc339c20a733d4a9a384a1 Mon Sep 17 00:00:00 2001 From: Takamichi Horikawa Date: Sat, 26 Nov 2016 20:57:57 +0900 Subject: initial --- libopna/opnassg.h | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 libopna/opnassg.h (limited to 'libopna/opnassg.h') diff --git a/libopna/opnassg.h b/libopna/opnassg.h new file mode 100644 index 0000000..5928c49 --- /dev/null +++ b/libopna/opnassg.h @@ -0,0 +1,60 @@ +#ifndef LIBOPNA_OPNASSG_H_INCLUDED +#define LIBOPNA_OPNASSG_H_INCLUDED + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct opna_ssg_ch { + uint16_t tone_counter; + bool out; +}; + +struct opna_ssg { + uint8_t regs[0x10]; + struct opna_ssg_ch ch[3]; + uint8_t noise_counter; + uint32_t lfsr; + uint16_t env_counter; + uint8_t env_level; + bool env_att; + bool env_alt; + bool env_hld; + bool env_holding; +}; + +struct opna_ssg_resampler { + int16_t buf[(1<<7)]; + unsigned index; +}; + +void opna_ssg_reset(struct opna_ssg *ssg); +void opna_ssg_resampler_reset(struct opna_ssg_resampler *resampler); +// generate raw data +// Monoral +// Output level: [-32766, 32766] +// Samplerate: clock / 8 +// (on opna: masterclock / 32 +// 7987200 / 32 = 249600) +void opna_ssg_generate_raw(struct opna_ssg *ssg, int16_t *buf, int samples); + +// mix samplerate converted data for mixing with OPNA output +// call to buffer written with OPNA output +// samplerate: 7987200/144 Hz +// (55466.66..) Hz +void opna_ssg_mix_55466( + struct opna_ssg *ssg, struct opna_ssg_resampler *resampler, + int16_t *buf, int samples); +void opna_ssg_writereg(struct opna_ssg *ssg, unsigned reg, unsigned val); + +// channel level (0 - 31) +int opna_ssg_channel_level(const struct opna_ssg *ssg, int ch); + +#ifdef __cplusplus +} +#endif + +#endif // LIBOPNA_OPNASSG_H_INCLUDED -- cgit v1.2.3