gzdoom/libraries/opnmidi/opnmidi_cvt.hpp

83 lines
3 KiB
C++
Raw Normal View History

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-01 21:07:05 +00:00
/*
* libOPNMIDI is a free MIDI to WAV conversion library with OPN2 (YM2612) emulation
*
* MIDI parser and player (Original code from ADLMIDI): Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
* ADLMIDI Library API: Copyright (c) 2015-2018 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "opnbank.h"
template <class WOPNI>
static void cvt_generic_to_FMIns(opnInstMeta2 &ins, const WOPNI &in)
{
ins.tone = in.percussion_key_number;
ins.flags = in.inst_flags;
/* Junk, delete later */
ins.fine_tune = 0.0;
/* Junk, delete later */
ins.opn[0].fbalg = in.fbalg;
ins.opn[0].lfosens = in.lfosens;
ins.opn[0].finetune = in.note_offset;
ins.midi_velocity_offset = in.midi_velocity_offset;
for(size_t op = 0; op < 4; op++)
{
ins.opn[0].OPS[op].data[0] = in.operators[op].dtfm_30;
ins.opn[0].OPS[op].data[1] = in.operators[op].level_40;
ins.opn[0].OPS[op].data[2] = in.operators[op].rsatk_50;
ins.opn[0].OPS[op].data[3] = in.operators[op].amdecay1_60;
ins.opn[0].OPS[op].data[4] = in.operators[op].decay2_70;
ins.opn[0].OPS[op].data[5] = in.operators[op].susrel_80;
ins.opn[0].OPS[op].data[6] = in.operators[op].ssgeg_90;
}
ins.opn[1] = ins.opn[0];
ins.ms_sound_kon = in.delay_on_ms;
ins.ms_sound_koff = in.delay_off_ms;
}
template <class WOPNI>
static void cvt_FMIns_to_generic(WOPNI &ins, const opnInstMeta2 &in)
{
ins.percussion_key_number = in.tone;
ins.inst_flags = in.flags;
ins.fbalg = in.opn[0].fbalg;
ins.lfosens = in.opn[0].lfosens;
ins.note_offset = in.opn[0].finetune;
ins.midi_velocity_offset = in.midi_velocity_offset;
for(size_t op = 0; op < 4; op++)
{
ins.operators[op].dtfm_30 = in.opn[0].OPS[op].data[0];
ins.operators[op].level_40 = in.opn[0].OPS[op].data[1];
ins.operators[op].rsatk_50 = in.opn[0].OPS[op].data[2];
ins.operators[op].amdecay1_60 = in.opn[0].OPS[op].data[3];
ins.operators[op].decay2_70 = in.opn[0].OPS[op].data[4];
ins.operators[op].susrel_80 = in.opn[0].OPS[op].data[5];
ins.operators[op].ssgeg_90 = in.opn[0].OPS[op].data[6];
}
ins.delay_on_ms = in.ms_sound_kon;
ins.delay_off_ms = in.ms_sound_koff;
}