qzdoom/src/sound/opnmidi/chips/mame/mame_ym2612fm.h
Vitaly Novichkov 59c8d8ff64 Upgrade libADLMIDI and libOPNMIDI
Added full-panning stereo, improvement of channel management, and many other things.

Also, I have implemented an ability to use custom WOPL (for libADLMIDI) and WOPN (for libOPNMIDI) banks from the same path as "soundfonts", but also, in the same environment, the "fm_banks" folder was added for WOPL/WOPN storing purposes.
To toggle usage of embedded or custom bank, I have added togglable booleans. When bank fails to be loaded, the default embedded bank is getting to be used as fallback.

ADLMIDI 1.4.0   2018-10-01
 * Implemented a full support for Portamento! (Thanks to [Jean Pierre Cimalando](https://github.com/jpcima) for a work!)
 * Added support for SysEx event handling! (Thanks to [Jean Pierre Cimalando](https://github.com/jpcima) for a work!)
 * Added support for GS way of custom drum channels (through SysEx events)
 * Ignore some NRPN events and lsb bank number when using GS standard (after catching of GS Reset SysEx call)
 * Added support for CC66-Sostenuto controller (Pedal hold of currently-pressed notes only while CC64 holds also all next notes)
 * Added support for CC67-SoftPedal controller (SoftPedal lowers the volume of notes played)
 * Fixed correctness of CMF files playing
 * Fixed unnecessary overuse of chip channels by blank notes
 * Added API to disable specific MIDI tracks or play one of MIDI tracks solo
 * Added support for more complex loop (loopStart=XX, loopEnd=0). Where XX - count of loops, or 0 - infinite. Nested loops are supported without of any limits.
 * Added working implementation of TMB's velocity offset
 * Added support for full-panning stereo option (Thanks to [Christopher Snowhill](https://github.com/kode54) for a work!)
 * Fixed inability to play high notes due physical tone frequency out of range on the OPL3 chip

OPNMIDI 1.4.0   2018-10-01
 * Implemented a full support for Portamento! (Thanks to [Jean Pierre Cimalando](https://github.com/jpcima) for a work!)
 * Added support for SysEx event handling! (Thanks to [Jean Pierre Cimalando](https://github.com/jpcima) for a work!)
 * Added support for GS way of custom drum channels (through SysEx events)
 * Ignore some NRPN events and lsb bank number when using GS standard (after catching of GS Reset SysEx call)
 * Added support for CC66-Sostenuto controller (Pedal hold of currently-pressed notes only while CC64 holds also all next notes)
 * Added support for CC67-SoftPedal controller (SoftPedal lowers the volume of notes played)
 * Resolved a trouble which sometimes makes a junk noise sound and unnecessary overuse of chip channels
 * Volume models support taken from libADLMIDI has been adapted to OPN2's chip speficis
 * Fixed inability to play high notes due physical tone frequency out of range on the OPN2 chip
 * Added support for full-panning stereo option

ADL&OPN Hotfix: re-calculated default banks
The fix on side of measurer of OPL3-BE and OPN2-BE where some instruments getting zero releasing time.
2018-10-04 08:58:47 -04:00

165 lines
4.8 KiB
C

/*
File: fm.h -- header file for software emulation for FM sound generator
*/
#ifndef FM_HHHHH
#define FM_HHHHH
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "mamedef.h"
/* --- select emulation chips --- */
/*
#define BUILD_YM2203 (HAS_YM2203) // build YM2203(OPN) emulator
#define BUILD_YM2608 (HAS_YM2608) // build YM2608(OPNA) emulator
#define BUILD_YM2610 (HAS_YM2610) // build YM2610(OPNB) emulator
#define BUILD_YM2610B (HAS_YM2610B) // build YM2610B(OPNB?)emulator
#define BUILD_YM2612 (HAS_YM2612) // build YM2612(OPN2) emulator
#define BUILD_YM3438 (HAS_YM3438) // build YM3438(OPN) emulator
*/
#define BUILD_YM2203 0
#define BUILD_YM2608 0
#define BUILD_YM2610 0
#define BUILD_YM2610B 0
#define BUILD_YM2612 1
#define BUILD_YM3438 0
#define FM_BUSY_FLAG_SUPPORT 0
/* select bit size of output : 8 or 16 */
#define FM_SAMPLE_BITS 16
/* select timer system internal or external */
#define FM_INTERNAL_TIMER 1
/* --- speedup optimize --- */
/* busy flag enulation , The definition of FM_GET_TIME_NOW() is necessary. */
/* #define FM_BUSY_FLAG_SUPPORT 1 */
/* --- external SSG(YM2149/AY-3-8910)emulator interface port */
/* used by YM2203,YM2608,and YM2610 */
typedef struct _ssg_callbacks ssg_callbacks;
struct _ssg_callbacks
{
void (*set_clock)(void *param, int clock);
void (*write)(void *param, int address, int data);
int (*read)(void *param);
void (*reset)(void *param);
};
/* --- external callback funstions for realtime update --- */
#if FM_BUSY_FLAG_SUPPORT
#define TIME_TYPE attotime
#define UNDEFINED_TIME attotime_zero
#define FM_GET_TIME_NOW(machine) timer_get_time(machine)
#define ADD_TIMES(t1, t2) attotime_add((t1), (t2))
#define COMPARE_TIMES(t1, t2) attotime_compare((t1), (t2))
#define MULTIPLY_TIME_BY_INT(t,i) attotime_mul(t, i)
#endif
/* compiler dependence */
#if 0
#ifndef OSD_CPU_H
#define OSD_CPU_H
typedef unsigned char UINT8; /* unsigned 8bit */
typedef unsigned short UINT16; /* unsigned 16bit */
typedef unsigned int UINT32; /* unsigned 32bit */
typedef signed char INT8; /* signed 8bit */
typedef signed short INT16; /* signed 16bit */
typedef signed int INT32; /* signed 32bit */
#endif /* OSD_CPU_H */
#endif
typedef stream_sample_t FMSAMPLE;
/*
#if (FM_SAMPLE_BITS==16)
typedef INT16 FMSAMPLE;
#endif
#if (FM_SAMPLE_BITS==8)
typedef unsigned char FMSAMPLE;
#endif
*/
typedef void (*FM_TIMERHANDLER)(void *param,int c,int cnt,int clock);
typedef void (*FM_IRQHANDLER)(void *param,int irq);
/* FM_TIMERHANDLER : Stop or Start timer */
/* int n = chip number */
/* int c = Channel 0=TimerA,1=TimerB */
/* int count = timer count (0=stop) */
/* doube stepTime = step time of one count (sec.)*/
/* FM_IRQHHANDLER : IRQ level changing sense */
/* int n = chip number */
/* int irq = IRQ level 0=OFF,1=ON */
#if (BUILD_YM2612||BUILD_YM3438)
/**
* @brief Initialize chip and return the instance
* @param param Unused, keep NULL
* @param baseclock YM2612 clock
* @param rate Output sample rate
* @param TimerHandler Keep NULL
* @param IRQHandler Keep NULL
* @return Chip instance or NULL on any error
*/
void * ym2612_init(void *param, int baseclock, int rate,
FM_TIMERHANDLER TimerHandler,FM_IRQHANDLER IRQHandler);
/**
* @brief Free chip instance
* @param chip Chip instance
*/
void ym2612_shutdown(void *chip);
/**
* @brief Reset state of the chip
* @param chip Chip instance
*/
void ym2612_reset_chip(void *chip);
/**
* @brief Generate stereo output of specified length
* @param chip Chip instance
* @param buffer Output sound buffer
* @param frames Output buffer size in frames (one frame - two array entries of the buffer)
* @param mix 0 - override buffer data, 1 - mix output data with a content of the buffer
*/
void ym2612_generate(void *chip, FMSAMPLE *buffer, int frames, int mix);
#define ym2612_update_one(chip, buffer, length) ym2612_generate(chip, buffer, length, 0)
/**
* @brief Single-Sample generation prepare
* @param chip Chip instance
*/
void ym2612_pre_generate(void *chip);
/**
* @brief Generate single stereo PCM frame. Will be used native sample rate of 53267 Hz
* @param chip Chip instance
* @param buffer One stereo PCM frame
*/
void ym2612_generate_one_native(void *chip, FMSAMPLE buffer[2]);
/* void ym2612_post_generate(void *chip, int length); */
int ym2612_write(void *chip, int a, unsigned char v);
void ym2612_write_pan(void *chip, int c, unsigned char v);
unsigned char ym2612_read(void *chip, int a);
int ym2612_timer_over(void *chip, int c );
void ym2612_postload(void *chip);
void ym2612_set_mutemask(void *chip, UINT32 MuteMask);
void ym2612_setoptions(UINT8 Flags);
#endif /* (BUILD_YM2612||BUILD_YM3438) */
#ifdef __cplusplus
}
#endif
#endif /* FM_HHHHH */