From 6fd10cdacb5cbe47a4fc339c20a733d4a9a384a1 Mon Sep 17 00:00:00 2001 From: Takamichi Horikawa Date: Sat, 26 Nov 2016 20:57:57 +0900 Subject: initial --- libopna/opnadrum.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 libopna/opnadrum.h (limited to 'libopna/opnadrum.h') diff --git a/libopna/opnadrum.h b/libopna/opnadrum.h new file mode 100644 index 0000000..24bcd48 --- /dev/null +++ b/libopna/opnadrum.h @@ -0,0 +1,57 @@ +#ifndef LIBOPNA_OPNADRUM_H_INCLUDED +#define LIBOPNA_OPNADRUM_H_INCLUDED + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define OPNA_ROM_BD_START 0x0000 +#define OPNA_ROM_SD_START 0x01c0 +#define OPNA_ROM_TOP_START 0x0440 +#define OPNA_ROM_HH_START 0x1b80 +#define OPNA_ROM_TOM_START 0x1d00 +#define OPNA_ROM_RIM_START 0x1f80 +#define OPNA_ROM_SIZE 0x2000 + +#define OPNA_ROM_BD_SIZE ((OPNA_ROM_SD_START-OPNA_ROM_BD_START)*2*3) +#define OPNA_ROM_SD_SIZE ((OPNA_ROM_TOP_START-OPNA_ROM_SD_START)*2*3) +#define OPNA_ROM_TOP_SIZE ((OPNA_ROM_HH_START-OPNA_ROM_TOP_START)*2*3) +#define OPNA_ROM_HH_SIZE ((OPNA_ROM_TOM_START-OPNA_ROM_HH_START)*2*3) +#define OPNA_ROM_TOM_SIZE ((OPNA_ROM_RIM_START-OPNA_ROM_TOM_START)*2*6) +#define OPNA_ROM_RIM_SIZE ((OPNA_ROM_SIZE-OPNA_ROM_RIM_START)*2*6) + +struct opna_drum { + struct { + int16_t *data; + bool playing; + unsigned index; + unsigned len; + unsigned level; + bool left; + bool right; + } drums[6]; + unsigned total_level; + int16_t rom_bd[OPNA_ROM_BD_SIZE]; + int16_t rom_sd[OPNA_ROM_SD_SIZE]; + int16_t rom_top[OPNA_ROM_TOP_SIZE]; + int16_t rom_hh[OPNA_ROM_HH_SIZE]; + int16_t rom_tom[OPNA_ROM_TOM_SIZE]; + int16_t rom_rim[OPNA_ROM_RIM_SIZE]; +}; + +void opna_drum_reset(struct opna_drum *drum); +// set rom data, size: 0x2000 (8192) bytes +void opna_drum_set_rom(struct opna_drum *drum, void *rom); + +void opna_drum_mix(struct opna_drum *drum, int16_t *buf, int samples); + +void opna_drum_writereg(struct opna_drum *drum, unsigned reg, unsigned val); + +#ifdef __cplusplus +} +#endif + +#endif // LIBOPNA_OPNADRUM_H_INCLUDED -- cgit v1.2.3