aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorVitaly Novichkov <admin@wohlnet.ru>2019-07-02 03:45:50 +0300
committerVitaly Novichkov <admin@wohlnet.ru>2019-07-02 03:45:50 +0300
commit068f54a35f704e8feb56849e9ac37dc981bf665f (patch)
tree4308813725803a20d40ab1a99faebba27c5a3a12 /utils
parentfc0f78939aac278efbc285250cdcbfc31cc92c57 (diff)
downloadlibADLMIDI-068f54a35f704e8feb56849e9ac37dc981bf665f.tar.gz
libADLMIDI-068f54a35f704e8feb56849e9ac37dc981bf665f.tar.bz2
libADLMIDI-068f54a35f704e8feb56849e9ac37dc981bf665f.zip
Draft for silent instrument detector
Logically identify instruments which will result you a silence
Diffstat (limited to 'utils')
-rw-r--r--utils/gen_adldata/progs_cache.cpp110
-rw-r--r--utils/gen_adldata/progs_cache.h4
2 files changed, 113 insertions, 1 deletions
diff --git a/utils/gen_adldata/progs_cache.cpp b/utils/gen_adldata/progs_cache.cpp
index cb07092..60324f6 100644
--- a/utils/gen_adldata/progs_cache.cpp
+++ b/utils/gen_adldata/progs_cache.cpp
@@ -365,6 +365,116 @@ void BanksDump::exportBanks(const std::string &outPath, const std::string &heade
std::fclose(out);
}
+bool BanksDump::isSilent(const BanksDump::Operator *ops, uint_fast16_t fbConn, size_t countOps, bool pseudo4op)
+{
+ // TODO: Implement this completely!!!
+ const uint_fast8_t conn1 = (fbConn) & 0x01;
+ const uint_fast8_t conn2 = (fbConn >> 8) & 0x01;
+ const uint_fast8_t egEn[4] =
+ {
+ static_cast<uint_fast8_t>(((ops[0].d_E862 & 0xFF) >> 5) & 0x01),
+ static_cast<uint_fast8_t>(((ops[1].d_E862 & 0xFF) >> 5) & 0x01),
+ static_cast<uint_fast8_t>(((ops[2].d_E862 & 0xFF) >> 5) & 0x01),
+ static_cast<uint_fast8_t>(((ops[3].d_E862 & 0xFF) >> 5) & 0x01)
+ };
+ const uint_fast8_t attack[4] =
+ {
+ static_cast<uint_fast8_t>((((ops[0].d_E862 >> 8) & 0xFF) >> 4) & 0x0F),
+ static_cast<uint_fast8_t>((((ops[1].d_E862 >> 8) & 0xFF) >> 4) & 0x0F),
+ static_cast<uint_fast8_t>((((ops[2].d_E862 >> 8) & 0xFF) >> 4) & 0x0F),
+ static_cast<uint_fast8_t>((((ops[3].d_E862 >> 8) & 0xFF) >> 4) & 0x0F)
+ };
+ const uint_fast8_t decay[4] =
+ {
+ static_cast<uint_fast8_t>((ops[0].d_E862 >> 8) & 0x0F),
+ static_cast<uint_fast8_t>((ops[1].d_E862 >> 8) & 0x0F),
+ static_cast<uint_fast8_t>((ops[2].d_E862 >> 8) & 0x0F),
+ static_cast<uint_fast8_t>((ops[3].d_E862 >> 8) & 0x0F)
+ };
+ const uint_fast8_t sustain[4] =
+ {
+ static_cast<uint_fast8_t>((((ops[0].d_E862 >> 16) & 0xFF) >> 4) & 0x0F),
+ static_cast<uint_fast8_t>((((ops[1].d_E862 >> 16) & 0xFF) >> 4) & 0x0F),
+ static_cast<uint_fast8_t>((((ops[2].d_E862 >> 16) & 0xFF) >> 4) & 0x0F),
+ static_cast<uint_fast8_t>((((ops[3].d_E862 >> 16) & 0xFF) >> 4) & 0x0F)
+ };
+ const uint_fast8_t level[4] =
+ {
+ static_cast<uint_fast8_t>(ops[0].d_40),
+ static_cast<uint_fast8_t>(ops[1].d_40),
+ static_cast<uint_fast8_t>(ops[2].d_40),
+ static_cast<uint_fast8_t>(ops[3].d_40)
+ };
+
+ // level=0x3f - silence
+ // attack=0x00 - silence
+ // attack=0x0F & sustain=0 & decay=0x0F & egOff - silence
+
+ if(countOps == 2)
+ {
+ if(conn1 == 0)
+ {
+ if(level[1] == 0x3F)
+ return true;
+ if(attack[1] == 0x00)
+ return true;
+ if(attack[1] == 0x0F && sustain[1] == 0x00 && decay[1] == 0x0F && !egEn[1])
+ return true;
+ }
+ if(conn1 == 1)
+ {
+ if(level[0] == 0x3F && level[1] == 0x3F)
+ return true;
+ if(attack[0] == 0x00 && attack[1] == 0x00)
+ return true;
+ if(attack[0] == 0x0F && sustain[0] == 0x00 && decay[0] == 0x0F && !egEn[0] &&
+ attack[1] == 0x0F && sustain[1] == 0x00 && decay[1] == 0x0F && !egEn[1])
+ return true;
+ }
+ }
+ else if(countOps == 4 && pseudo4op)
+ {
+ bool silent1 = false;
+ bool silent2 = false;
+ if(conn1 == 0 && (level[1] == 0x3F))
+ silent1 = true;
+ if(conn1 == 1 && (level[0] == 0x3F) && (level[1] == 0x3F))
+ silent1 = true;
+ if(conn2 == 0 && (level[3] == 0x3F))
+ silent2 = true;
+ if(conn2 == 1 && (level[2] == 0x3F) && (level[3] == 0x3F))
+ silent2 = true;
+ if(silent1 && silent2)
+ return true;
+ }
+ else if(countOps == 4 && !pseudo4op)
+ {
+ if(conn1 == 0 && conn1 == 0) // FM-FM [0, 0, 0, 1]
+ {
+ if(level[3] == 0x3F )
+ return true;
+ }
+
+ if(conn1 == 1 && conn1 == 0) // AM-FM [1, 0, 0, 1]
+ {
+ if(level[0] == 0x3F && level[3] == 0x3F)
+ return true;
+ }
+ if(conn1 == 0 && conn1 == 1) // FM-AM [0, 1, 0, 1]
+ {
+ if(level[1] == 0x3F && level[3] == 0x3F)
+ return true;
+ }
+ if(conn1 == 1 && conn1 == 1) // FM-AM [1, 0, 1, 1]
+ {
+ if(level[0] == 0x3F && level[2] == 0x3F && level[3] == 0x3F)
+ return true;
+ }
+ }
+
+ return false;
+}
+
void BanksDump::InstrumentEntry::setFbConn(uint_fast16_t fbConn1, uint_fast16_t fbConn2)
{
fbConn = (static_cast<uint_fast16_t>(fbConn1 & 0x0F)) |
diff --git a/utils/gen_adldata/progs_cache.h b/utils/gen_adldata/progs_cache.h
index 34e42a3..239187b 100644
--- a/utils/gen_adldata/progs_cache.h
+++ b/utils/gen_adldata/progs_cache.h
@@ -357,7 +357,9 @@ struct BanksDump
std::vector<InstrumentEntry> instruments;
std::vector<Operator> operators;
- void toOps(const insdata &inData, Operator *outData, size_t begin = 0);
+ static void toOps(const insdata &inData, Operator *outData, size_t begin = 0);
+ //! WIP
+ static bool isSilent(const Operator *ops, uint_fast16_t fbConn, size_t countOps = 2, bool pseudo4op = false);
size_t initBank(size_t bankId, const std::string &title, uint_fast16_t bankSetup);
void addMidiBank(size_t bankId, bool percussion, MidiBank b);