A rust port of vgm2mid by Paul Jensen and Valley Bell
#[allow(unused_imports)]
use crate::midi_shim::{
	MIDIShim, MIDI_PAN, MIDI_PAN_CENTER, MIDI_PAN_LEFT, MIDI_PAN_RIGHT, MIDI_PATCH_GUNSHOT,
	MIDI_PATCH_LEAD_1_SQUARE, MIDI_PITCHWHEEL_CENTER, MIDI_PITCHWHEEL_MAX, MIDI_PITCHWHEEL_MIN,
	MIDI_RPN_LSB, MIDI_RPN_MSB, MIDI_VOLUME, RPN_PITCH_BEND_RANGE_L, RPN_PITCH_BEND_RANGE_M,
};

use midly::num::{u14, u7, u4};

pub(crate) const CHN_DAC: u4 = u4::new(9);

#[allow(dead_code)]
pub(crate) const MIDI_NOTE_STEPS: u16 = 12;
//const PITCHWHEEL_SENSITIVITY = 64 //+/- n Semitones
//const PITCHWHEEL_STEPS_REAL = 8192 / PITCHWHEEL_SENSITIVITY
//const PITCHWHEEL_STEPS_DEFAULT = 4096 //16384 / 4
pub(crate) const PITCHWHEEL_SENSITIVITY_DEFAULT: u7 = u7::new(0x02); //+/- n Semitones
pub(crate) const PITCHWHEEL_STEPS_DEFAULT: u14 = u14::new(4096); //16384 / 4

//const MIDI_NOTE_CURVE = 2 ^ (1 / MIDI_NOTE_STEPS)
//const PITCHWHEEL_CURVE = MIDI_NOTE_CURVE ^ (1 / PITCHWHEEL_STEPS)

// Timing
//FIXME: Ensure that floating point numbers are the correct representation.
#[allow(dead_code)]
pub(crate) const OSC1: f64 = 53693100.0;
#[allow(dead_code)]
pub(crate) const FM_YM2413_SN76489: f64 = OSC1 / 15.0;
#[allow(dead_code)]
pub(crate) const FSAM_YM2413_SN76489: f64 = FM_YM2413_SN76489 / 72.0;
#[allow(dead_code)]
pub(crate) const FM_YM2612: f64 = OSC1 / 14.0;
#[allow(dead_code)]
pub(crate) const FSAM_YM2612: f64 = FM_YM2612 / 72.0;

pub(crate) const OPL_TYPE_YM3526: u8 = 0x1;
pub(crate) const OPL_TYPE_YM3812: u8 = 0x2;
pub(crate) const OPL_TYPE_YMF262: u8 = 0x3;
pub(crate) const OPL_TYPE_Y8950: u8 = 0x8;
pub(crate) const OPN_TYPE_YM2203: u8 = 0x1;
pub(crate) const OPN_TYPE_YM2608: u8 = 0x2;
pub(crate) const OPN_TYPE_YM2610: u8 = 0x3;
pub(crate) const OPN_TYPE_YM2612: u8 = 0x4;