From 6545b648cded507215be777864194f4cc961f877 Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Thu, 10 May 2018 15:03:47 +0200 Subject: meaningful handling of pitch bend sensitivity --- src/adlmidi_private.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 9fd6f97..5ac6ebc 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -599,6 +599,7 @@ public: uint8_t panning, vibrato, sustain; char ____padding[6]; double bend, bendsense; + int bendsense_lsb, bendsense_msb; double vibpos, vibspeed, vibdepth; int64_t vibdelay; uint8_t lastlrpn, lastmrpn; @@ -791,7 +792,9 @@ public: void resetAllControllers() { bend = 0.0; - bendsense = 2 / 8192.0; + bendsense_msb = 2; + bendsense_lsb = 0; + updateBendSensitivity(); volume = 100; expression = 127; sustain = 0; @@ -803,6 +806,11 @@ public: portamento = 0; brightness = 127; } + void updateBendSensitivity() + { + int cent = bendsense_msb * 100 + bendsense_lsb; + bendsense = cent * (0.01 / 8192.0); + } MIDIchannel() { activenotes_clear(); -- cgit v1.2.3 From 25ce6c5132d52def02653b08de65447b38d26419 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Mon, 14 May 2018 03:44:25 +0300 Subject: Attempt to fix the build on MinGW without C++11 --- src/adlmidi_private.hpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 9fd6f97..d66daf4 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -88,17 +88,13 @@ typedef int32_t ssize_t; #include #include #include -#if !(defined(__APPLE__) && defined(__GLIBCXX__)) && !defined(__ANDROID__) -#include //PRId32, PRIu32, etc. -#else -#include -#endif #include // vector #include // deque #include // exp, log, ceil #if defined(__WATCOMC__) #include // round, sqrt #endif +#include #include #include #include // numeric_limit @@ -110,6 +106,28 @@ typedef int32_t ssize_t; #include #include +/* + * Workaround for some compilers are has no those macros in their headers! + */ +#ifndef INT8_MIN +#define INT8_MIN (-0x7f - 1) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-0x7fff - 1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-0x7fffffff - 1) +#endif +#ifndef INT8_MAX +#define INT8_MAX 0x7f +#endif +#ifndef INT16_MAX +#define INT16_MAX 0x7fff +#endif +#ifndef INT32_MAX +#define INT32_MAX 0x7fffffff +#endif + #ifdef _MSC_VER #pragma warning(disable:4319) #pragma warning(disable:4267) -- cgit v1.2.3 From 5fdd39289affe341151839a48e227d51b08c4a25 Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Tue, 15 May 2018 18:09:04 +0200 Subject: specialized hash table for bank number mappings --- src/adlmidi_private.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 65cb4bc..b23e845 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -145,6 +145,7 @@ typedef int32_t ssize_t; #ifndef ADLMIDI_DISABLE_CPP_EXTRAS #include "adlmidi.hpp" //Extra C++ API #endif +#include "adlmidi_bankmap.h" #define ADL_UNUSED(x) (void)x @@ -335,7 +336,7 @@ private: std::vector dynamic_instruments; // Replaces adl[] when CMF file size_t dynamic_percussion_offset; - typedef std::map BankMap; + typedef BasicBankMap BankMap; BankMap dynamic_melodic_banks; BankMap dynamic_percussion_banks; const unsigned DynamicInstrumentTag /* = 0x8000u*/, -- cgit v1.2.3 From f7e659977e033f491f00d7e8720c8a4acfc62daf Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Wed, 16 May 2018 03:38:54 +0300 Subject: Move smart pointer classes into separated header --- src/adlmidi_private.hpp | 112 +----------------------------------------------- 1 file changed, 1 insertion(+), 111 deletions(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index b23e845..10bd517 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -145,6 +145,7 @@ typedef int32_t ssize_t; #ifndef ADLMIDI_DISABLE_CPP_EXTRAS #include "adlmidi.hpp" //Extra C++ API #endif +#include "adlmidi_ptr.hpp" #include "adlmidi_bankmap.h" #define ADL_UNUSED(x) (void)x @@ -200,117 +201,6 @@ inline int32_t adl_cvtU32(int32_t x) return (uint32_t)adl_cvtS32(x) - (uint32_t)INT32_MIN; } -/* - Smart pointer for C heaps, created with malloc() call. - FAQ: Why not std::shared_ptr? Because of Android NDK now doesn't supports it -*/ -template -class AdlMIDI_CPtr -{ - PTR *m_p; -public: - AdlMIDI_CPtr() : m_p(NULL) {} - ~AdlMIDI_CPtr() - { - reset(NULL); - } - - void reset(PTR *p = NULL) - { - if(p != m_p) { - if(m_p) - free(m_p); - m_p = p; - } - } - - PTR *get() - { - return m_p; - } - PTR &operator*() - { - return *m_p; - } - PTR *operator->() - { - return m_p; - } -private: - AdlMIDI_CPtr(const AdlMIDI_CPtr &); - AdlMIDI_CPtr &operator=(const AdlMIDI_CPtr &); -}; - -/* - Shared pointer with non-atomic counter - FAQ: Why not std::shared_ptr? Because of Android NDK now doesn't supports it -*/ -template -class AdlMIDI_SPtr -{ - VALUE *m_p; - size_t *m_counter; -public: - AdlMIDI_SPtr() : m_p(NULL), m_counter(NULL) {} - ~AdlMIDI_SPtr() - { - reset(NULL); - } - - AdlMIDI_SPtr(const AdlMIDI_SPtr &other) - : m_p(other.m_p), m_counter(other.m_counter) - { - if(m_counter) - ++*m_counter; - } - - AdlMIDI_SPtr &operator=(const AdlMIDI_SPtr &other) - { - if(this == &other) - return *this; - reset(); - m_p = other.m_p; - m_counter = other.m_counter; - if(m_counter) - ++*m_counter; - return *this; - } - - void reset(VALUE *p = NULL) - { - if(p != m_p) { - if(m_p && --*m_counter == 0) - delete m_p; - m_p = p; - if(!p) { - if(m_counter) { - delete m_counter; - m_counter = NULL; - } - } - else - { - if(!m_counter) - m_counter = new size_t; - *m_counter = 1; - } - } - } - - VALUE *get() - { - return m_p; - } - VALUE &operator*() - { - return *m_p; - } - VALUE *operator->() - { - return m_p; - } -}; - class MIDIplay; struct ADL_MIDIPlayer; class OPL3 -- cgit v1.2.3 From 9b478615e7f0cd73c360fd289b05db52b5f730f1 Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Wed, 16 May 2018 01:31:18 +0200 Subject: storing adldata and adlinsdata in unified structures --- src/adlmidi_private.hpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 10bd517..89d3236 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -215,13 +215,13 @@ public: std::vector > cardsOP2; #endif private: - std::vector ins; // index to adl[], cached, needed by Touch() + std::vector ins; // patch data, cached, needed by Touch() std::vector pit; // value poked to B0, cached, needed by NoteOff)( std::vector regBD; friend int adlRefreshNumCards(ADL_MIDIPlayer *device); //! Meta information about every instrument - std::vector dynamic_metainstruments; // Replaces adlins[] when CMF file + std::vector dynamic_metainstruments; // Replaces adlins[] when CMF file //! Raw instrument data ready to be sent to the chip std::vector dynamic_instruments; // Replaces adl[] when CMF file size_t dynamic_percussion_offset; @@ -231,9 +231,8 @@ private: BankMap dynamic_percussion_banks; const unsigned DynamicInstrumentTag /* = 0x8000u*/, DynamicMetaInstrumentTag /* = 0x4000000u*/; - const adlinsdata &GetAdlMetaIns(size_t n); + adlinsdata2 GetAdlMetaIns(size_t n); size_t GetAdlMetaNumber(size_t midiins); - const adldata &GetAdlIns(size_t insno); public: void setEmbeddedBank(unsigned int bank); @@ -292,7 +291,7 @@ public: void Touch_Real(unsigned c, unsigned volume, uint8_t brightness = 127); //void Touch(unsigned c, unsigned volume) - void Patch(uint16_t c, size_t i); + void Patch(uint16_t c, const adldata &adli); void Pan(unsigned c, unsigned value); void Silence(); void updateFlags(); @@ -539,18 +538,18 @@ public: //! Destination chip channel uint16_t chip_chan; //! ins, inde to adl[] - size_t insId; + adldata ains; //! Is this voice must be detunable? bool pseudo4op; void assign(const Phys &oth) { - insId = oth.insId; + ains = oth.ains; pseudo4op = oth.pseudo4op; } bool operator==(const Phys &oth) const { - return (insId == oth.insId) && (pseudo4op == oth.pseudo4op); + return (ains == oth.ains) && (pseudo4op == oth.pseudo4op); } bool operator!=(const Phys &oth) const { -- cgit v1.2.3 From bed6bcb220346c622a307bf405b9a1e87fd99db5 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sat, 19 May 2018 19:55:47 +0300 Subject: OpenWatcom compilation fix --- src/adlmidi_private.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 89d3236..07f15f2 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -569,7 +569,7 @@ public: ph = &chip_channels[i]; return ph; } - Phys *phys_find_or_create(unsigned chip_chan) + Phys *phys_find_or_create(uint16_t chip_chan) { Phys *ph = phys_find(chip_chan); if(!ph) { @@ -580,7 +580,7 @@ public: } return ph; } - Phys *phys_ensure_find_or_create(unsigned chip_chan) + Phys *phys_ensure_find_or_create(uint16_t chip_chan) { Phys *ph = phys_find_or_create(chip_chan); assert(ph); @@ -679,7 +679,7 @@ public: void activenotes_clear() { - for(unsigned i = 0; i < 128; ++i) { + for(uint8_t i = 0; i < 128; ++i) { activenotes[i].note = i; activenotes[i].active = false; } -- cgit v1.2.3 From bb4797ee68c0f12018196d3ee8caddcdcad9fe38 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sat, 19 May 2018 22:33:37 +0300 Subject: Works and fixes - Fixed an incorrect calculation of 4-op channels and choosing 4-op channels for 2-op only banks - Resolved trouble with automatically chosen flags because of internal confusion --- src/adlmidi_private.hpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 07f15f2..e43bd4e 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -229,6 +229,7 @@ private: typedef BasicBankMap BankMap; BankMap dynamic_melodic_banks; BankMap dynamic_percussion_banks; + AdlBankSetup dynamic_bank_setup; const unsigned DynamicInstrumentTag /* = 0x8000u*/, DynamicMetaInstrumentTag /* = 0x4000000u*/; adlinsdata2 GetAdlMetaIns(size_t n); -- cgit v1.2.3 From 56c0cd7f2439898080df2e0a8129b72d2d85ca70 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Thu, 31 May 2018 02:05:58 +0300 Subject: Small polishing of volume model and CMF/RSXX tempo - Removed "Logarithmic volumes" flag as volume models concept successfuly serves this task. "Logarithmic volumes" flag is useless when we have volume models. - Fixed "too fast" tempo while playing CMF and EA-MUS (aka RSXX) files --- src/adlmidi_private.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index e43bd4e..b20a2b4 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -251,8 +251,8 @@ public: bool AdlPercussionMode; //! Carriers-only are scaled by default by volume level. This flag will tell to scale modulators too. bool ScaleModulators; - //! Required to play CMF files. Can be turned on by using of "CMF" volume model - bool LogarithmicVolumes; + // ! Required to play CMF files. Can be turned on by using of "CMF" volume model + //bool LogarithmicVolumes; //[REPLACED WITH "m_volumeScale == VOLUME_NATIVE", DEPRECATED!!!] // ! Required to play EA-MUS files [REPLACED WITH "m_musicMode", DEPRECATED!!!] //bool CartoonersVolumes; enum MusicMode @@ -268,7 +268,7 @@ public: enum VolumesScale { VOLUME_Generic, - VOLUME_CMF, + VOLUME_NATIVE, VOLUME_DMX, VOLUME_APOGEE, VOLUME_9X -- cgit v1.2.3 From 17127e55c549ea59bb43bb6da7d06f11fd84db53 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Thu, 31 May 2018 03:36:40 +0300 Subject: Implement correct support for after-touch feature --- src/adlmidi_private.hpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index b20a2b4..0e3affe 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -505,7 +505,13 @@ public: uint8_t bank_lsb, bank_msb; uint8_t patch; uint8_t volume, expression; - uint8_t panning, vibrato, sustain; + uint8_t panning, vibrato, aftertouch, sustain; + //! Per note Aftertouch values + uint8_t noteAftertouch[128]; + //! Zero-filled array. Is used to compare with note aftertouch range + uint8_t noteAftertouch_Zero[128]; + //! Is note aftertouch has any non-zero value + bool noteAfterTouchInUse; char ____padding[6]; double bend, bendsense; int bendsense_lsb, bendsense_msb; @@ -521,7 +527,8 @@ public: bool active; // Current pressure uint8_t vol; - char ____padding[1]; + // Note vibrato (a part of Note Aftertouch feature) + uint8_t vibrato; // Tone selected on noteon: int16_t tone; char ____padding2[4]; @@ -617,7 +624,7 @@ public: for(++ptr; ptr && !ptr->active;) ptr = (ptr->note == 127) ? 0 : (ptr + 1); return *this; - }; + } activenoteiterator operator++(int) { activenoteiterator pos = *this; @@ -708,6 +715,10 @@ public: expression = 127; sustain = 0; vibrato = 0; + aftertouch = 0; + std::memset(noteAftertouch, 0, 128); + std::memset(noteAftertouch_Zero, 0, 128); + noteAfterTouchInUse = false; vibspeed = 2 * 3.141592653 * 5.0; vibdepth = 0.5 / 127; vibdelay = 0; @@ -715,6 +726,10 @@ public: portamento = 0; brightness = 127; } + bool hasVibrato() + { + return (vibrato > 0) || (aftertouch > 0) || noteAfterTouchInUse; + } void updateBendSensitivity() { int cent = bendsense_msb * 100 + bendsense_lsb; -- cgit v1.2.3 From 9007918bce92c5af1305426ead055591e29dd6b9 Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Thu, 31 May 2018 07:36:51 +0200 Subject: rewrite the check of whether aftertouch is used --- src/adlmidi_private.hpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 0e3affe..ee73c61 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -508,8 +508,6 @@ public: uint8_t panning, vibrato, aftertouch, sustain; //! Per note Aftertouch values uint8_t noteAftertouch[128]; - //! Zero-filled array. Is used to compare with note aftertouch range - uint8_t noteAftertouch_Zero[128]; //! Is note aftertouch has any non-zero value bool noteAfterTouchInUse; char ____padding[6]; @@ -717,7 +715,6 @@ public: vibrato = 0; aftertouch = 0; std::memset(noteAftertouch, 0, 128); - std::memset(noteAftertouch_Zero, 0, 128); noteAfterTouchInUse = false; vibspeed = 2 * 3.141592653 * 5.0; vibdepth = 0.5 / 127; -- cgit v1.2.3 From c4ed5cf15e64a84129865a58b5063ef0e73f0bcf Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Wed, 16 May 2018 14:27:04 +0200 Subject: bank storage inside dynamic map --- src/adlmidi_private.hpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index ee73c61..2010b4e 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -220,22 +220,19 @@ private: std::vector regBD; friend int adlRefreshNumCards(ADL_MIDIPlayer *device); - //! Meta information about every instrument - std::vector dynamic_metainstruments; // Replaces adlins[] when CMF file - //! Raw instrument data ready to be sent to the chip - std::vector dynamic_instruments; // Replaces adl[] when CMF file - size_t dynamic_percussion_offset; - - typedef BasicBankMap BankMap; - BankMap dynamic_melodic_banks; - BankMap dynamic_percussion_banks; +public: + struct Bank + { + adlinsdata2 ins[128]; + }; + typedef BasicBankMap BankMap; +private: + BankMap dynamic_banks; AdlBankSetup dynamic_bank_setup; - const unsigned DynamicInstrumentTag /* = 0x8000u*/, - DynamicMetaInstrumentTag /* = 0x4000000u*/; - adlinsdata2 GetAdlMetaIns(size_t n); - size_t GetAdlMetaNumber(size_t midiins); public: void setEmbeddedBank(unsigned int bank); + static const adlinsdata2 emptyInstrument; + enum { PercussionTag = 1 << 15 }; //! Total number of running concurrent emulated chips unsigned int NumCards; @@ -530,10 +527,10 @@ public: // Tone selected on noteon: int16_t tone; char ____padding2[4]; - // Patch selected on noteon; index to banks[AdlBank][] + // Patch selected on noteon; index to bank.ins[] size_t midiins; - // Index to physical adlib data structure, adlins[] - size_t insmeta; + // Patch selected + const adlinsdata2 *ains; enum { MaxNumPhysChans = 2, -- cgit v1.2.3 From 461bc4c3c4a89852bcd70c793f55cda3eba2ff4c Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sat, 2 Jun 2018 01:25:49 +0300 Subject: Remove duplicated "Poke" function call It's no sense to have uint32-argument poke function as all emulators are using uint16 and uint8 data only --- src/adlmidi_private.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 2010b4e..8e3b158 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -281,8 +281,7 @@ public: // 7 = percussion Hihat // 8 = percussion slave - void Poke(size_t card, uint32_t index, uint32_t value); - void PokeN(size_t card, uint16_t index, uint8_t value); + void Poke(size_t card, uint16_t index, uint8_t value); void NoteOff(size_t c); void NoteOn(unsigned c, double hertz); -- cgit v1.2.3 From d7b9439df5d09d121c55a15f2bc25c360deeebe0 Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Thu, 17 May 2018 21:33:28 +0200 Subject: dynamic instrument API --- src/adlmidi_private.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 8e3b158..63b4854 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -35,6 +35,9 @@ # endif #endif +// Require declarations of unstable API for extern "C" +#define ADLMIDI_UNSTABLE_API + #ifdef _WIN32 #define NOMINMAX #endif @@ -226,7 +229,6 @@ public: adlinsdata2 ins[128]; }; typedef BasicBankMap BankMap; -private: BankMap dynamic_banks; AdlBankSetup dynamic_bank_setup; public: -- cgit v1.2.3 From adcf702a7e18846ad4f8753ec5a32cf56585ca23 Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Sun, 3 Jun 2018 15:46:50 +0300 Subject: Bugfixes - Fixed all MSVC 2015/2017 warnings in both 32 and 64 bit builds - Fixed weird behavior when using adl_setHVibrato, adl_setHTremolo, adl_setScaleModulators, and adl_setVolumeRangeModel when passing the -1 "Auto" state - Move arpeggio counter into the MIDIPlay class as originally it was a global static variable which is ugly and danger when running multiple instances of the same library --- src/adlmidi_private.hpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 63b4854..0584587 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -131,13 +131,6 @@ typedef int32_t ssize_t; #define INT32_MAX 0x7fffffff #endif -#ifdef _MSC_VER -#pragma warning(disable:4319) -#pragma warning(disable:4267) -#pragma warning(disable:4244) -#pragma warning(disable:4146) -#endif - #include "fraction.hpp" #ifndef ADLMIDI_HW_OPL #include "chips/opl_chip_base.h" @@ -167,12 +160,14 @@ inline Real adl_cvtReal(int32_t x) { return x * ((Real)1 / INT16_MAX); } + inline int32_t adl_cvtS16(int32_t x) { - x = (x < INT16_MIN) ? INT16_MIN : x; - x = (x > INT16_MAX) ? INT16_MAX : x; + x = (x < INT16_MIN) ? (INT16_MIN) : x; + x = (x > INT16_MAX) ? (INT16_MAX) : x; return x; } + inline int32_t adl_cvtS8(int32_t x) { return adl_cvtS16(x) / 256; @@ -485,7 +480,7 @@ public: bool eof() { if(fp) - return std::feof(fp); + return (std::feof(fp) != 0); else return mp_tell >= mp_size; } @@ -592,9 +587,9 @@ public: } void phys_erase_at(const Phys *ph) { - unsigned pos = ph - chip_channels; - assert(pos < chip_channels_count); - for(unsigned i = pos + 1; i < chip_channels_count; ++i) + intptr_t pos = ph - chip_channels; + assert(pos < static_cast(chip_channels_count)); + for(intptr_t i = pos + 1; i < static_cast(chip_channels_count); ++i) chip_channels[i - 1] = chip_channels[i]; --chip_channels_count; } @@ -976,6 +971,8 @@ private: char ____padding[7]; std::vector ch; + //! Counter of arpeggio processing + size_t m_arpeggioCounter; #ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER std::vector > TrackData; @@ -1199,7 +1196,7 @@ private: // Determine how good a candidate this adlchannel // would be for playing a note from this instrument. - int64_t CalculateAdlChannelGoodness(unsigned c, const MIDIchannel::NoteInfo::Phys &ins, uint16_t /*MidCh*/) const; + int64_t CalculateAdlChannelGoodness(size_t c, const MIDIchannel::NoteInfo::Phys &ins, uint16_t /*MidCh*/) const; // A new note will be played on this channel using this instrument. // Kill existing notes on this channel (or don't, if we do arpeggio) -- cgit v1.2.3 From 51a7cb19a8656c91baf616df5986d8e4c4cce97d Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Mon, 4 Jun 2018 03:30:28 +0300 Subject: Fixed bend sensitivity processing --- src/adlmidi_private.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 0584587..c720fc2 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -504,6 +504,7 @@ public: //! Is note aftertouch has any non-zero value bool noteAfterTouchInUse; char ____padding[6]; + double bendSrc; double bend, bendsense; int bendsense_lsb, bendsense_msb; double vibpos, vibspeed, vibdepth; @@ -698,6 +699,7 @@ public: } void resetAllControllers() { + bendSrc = 0.0; bend = 0.0; bendsense_msb = 2; bendsense_lsb = 0; @@ -722,8 +724,9 @@ public: } void updateBendSensitivity() { - int cent = bendsense_msb * 100 + bendsense_lsb; - bendsense = cent * (0.01 / 8192.0); + int cent = bendsense_msb + static_cast(static_cast(bendsense_lsb) * (1.0 / 128.0)); + bendsense = static_cast(cent) / 8192.0; + bend = bendSrc * bendsense; } MIDIchannel() { -- cgit v1.2.3 From d8142ef298fa4ce54a8dbf8977709b9209c148e6 Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Mon, 4 Jun 2018 09:36:27 +0200 Subject: new pitchbend strategy --- src/adlmidi_private.hpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index c720fc2..3aaeaf0 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -504,8 +504,8 @@ public: //! Is note aftertouch has any non-zero value bool noteAfterTouchInUse; char ____padding[6]; - double bendSrc; - double bend, bendsense; + int bend; + double bendsense; int bendsense_lsb, bendsense_msb; double vibpos, vibspeed, vibdepth; int64_t vibdelay; @@ -699,8 +699,7 @@ public: } void resetAllControllers() { - bendSrc = 0.0; - bend = 0.0; + bend = 0; bendsense_msb = 2; bendsense_lsb = 0; updateBendSensitivity(); @@ -724,9 +723,8 @@ public: } void updateBendSensitivity() { - int cent = bendsense_msb + static_cast(static_cast(bendsense_lsb) * (1.0 / 128.0)); - bendsense = static_cast(cent) / 8192.0; - bend = bendSrc * bendsense; + int cent = bendsense_msb * 128 + bendsense_lsb; + bendsense = cent * (1.0 / (128 * 8192)); } MIDIchannel() { -- cgit v1.2.3 From 04ea6707d9d0922b001c373d7f67fdfa5d93e44f Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Wed, 6 Jun 2018 16:40:09 +0200 Subject: fix a use of uninitialized memory --- src/adlmidi_private.hpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 3aaeaf0..ed654ac 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -781,15 +781,21 @@ public: AdlChannel(const AdlChannel &oth): koff_time_until_neglible(oth.koff_time_until_neglible) { - users_assign(oth.users_first, oth.users_size); + if(oth.users_first) + { + users_first = NULL; + users_assign(oth.users_first, oth.users_size); + } + else + users_clear(); } AdlChannel &operator=(const AdlChannel &oth) - { - koff_time_until_neglible = oth.koff_time_until_neglible; - users_assign(oth.users_first, oth.users_size); - return *this; - } + { + koff_time_until_neglible = oth.koff_time_until_neglible; + users_assign(oth.users_first, oth.users_size); + return *this; + } void AddAge(int64_t ms); }; -- cgit v1.2.3 From 70c83caace9911dc5d8b80c1653c96b073f88e4a Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Fri, 15 Jun 2018 01:37:43 +0300 Subject: Give more live to very long sustaining notes --- src/adlmidi_private.hpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/adlmidi_private.hpp') diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index ed654ac..2499bad 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -752,6 +752,9 @@ public: bool sustained; char ____padding[7]; MIDIchannel::NoteInfo::Phys ins; // a copy of that in phys[] + //! Has fixed sustain, don't iterate "on" timeout + bool fixed_sustain; + //! Timeout until note will be allowed to be killed by channel manager while it is on int64_t kon_time_until_neglible; int64_t vibdelay; }; -- cgit v1.2.3