diff options
author | Wohlstand <admin@wohlnet.ru> | 2021-07-27 11:19:05 +0300 |
---|---|---|
committer | Wohlstand <admin@wohlnet.ru> | 2021-07-27 11:19:05 +0300 |
commit | 7dc1e46c13b897f19d185fd9fe0ddcffa7b3d890 (patch) | |
tree | c4f6278ec1422e88a96d097d9d4d2ca26fa08c41 /utils/gen_adldata | |
parent | 0f718097d700c93ff961630eb83903c730d04af9 (diff) | |
download | libADLMIDI-7dc1e46c13b897f19d185fd9fe0ddcffa7b3d890.tar.gz libADLMIDI-7dc1e46c13b897f19d185fd9fe0ddcffa7b3d890.tar.bz2 libADLMIDI-7dc1e46c13b897f19d185fd9fe0ddcffa7b3d890.zip |
gen_adldata: Added an option to minify the generated source file
Diffstat (limited to 'utils/gen_adldata')
-rw-r--r-- | utils/gen_adldata/CMakeLists.txt | 5 | ||||
-rw-r--r-- | utils/gen_adldata/progs_cache.cpp | 56 |
2 files changed, 55 insertions, 6 deletions
diff --git a/utils/gen_adldata/CMakeLists.txt b/utils/gen_adldata/CMakeLists.txt index 6f5216e..1e6d6a5 100644 --- a/utils/gen_adldata/CMakeLists.txt +++ b/utils/gen_adldata/CMakeLists.txt @@ -83,6 +83,11 @@ if(WITH_GENADLDATA_PROGRESS OR WITH_GENADLDATA_DEEPDEBUG) target_compile_options(gen_adldata PUBLIC "-DADL_GENDATA_PRINT_PROGRESS") endif() +option(WITH_GENADLDATA_MINIFY "Minify the printing result at gen_adldata" ON) +if(WITH_GENADLDATA_MINIFY) + target_compile_options(gen_adldata PUBLIC "-DADL_GENDATA_MINIFY") +endif() + if(WITH_GENADLDATA_COMMENTS) target_compile_options(gen_adldata PUBLIC "-DADLDATA_WITH_COMMENTS") endif() diff --git a/utils/gen_adldata/progs_cache.cpp b/utils/gen_adldata/progs_cache.cpp index 72e1fbc..9e430df 100644 --- a/utils/gen_adldata/progs_cache.cpp +++ b/utils/gen_adldata/progs_cache.cpp @@ -163,13 +163,20 @@ void BanksDump::exportBanks(const std::string &outPath, bool donntOverride, cons for(const BankEntry &be : banks) { +#ifndef ADL_GENDATA_MINIFY std::fprintf(out, "\t{0x%04lX, %zu, %zu, \"%s\", ", +#else + std::fprintf(out, "{0x%04lX,%zu,%zu,\"%s\",", +#endif be.bankSetup, be.melodic.size(), be.percussion.size(), be.bankTitle.c_str()); - +#ifndef ADL_GENDATA_MINIFY fprintf(out, "%zu, ", bankNumberLists.size()); // Use offset to point the common array of bank IDs +#else + fprintf(out, "%zu,", bankNumberLists.size()); // Use offset to point the common array of bank IDs +#endif for(const size_t &me : be.melodic) bankNumberLists.push_back(me); @@ -177,22 +184,35 @@ void BanksDump::exportBanks(const std::string &outPath, bool donntOverride, cons for(const size_t &me : be.percussion) bankNumberLists.push_back(me); - std::fprintf(out, "},\n"); + std::fprintf(out, "},"); +#ifndef ADL_GENDATA_MINIFY + std::fprintf(out, "\n"); +#endif } std::fprintf(out, "};\n\n"); +#ifdef ADL_GENDATA_MINIFY + std::fprintf(out, "#define q(x) g_embeddedBanks[x].title\n"); +#endif std::fprintf(out, "const char* const g_embeddedBankNames[] =\n" "{\n\t"); { bool commaNeeded = false; +#ifndef ADL_GENDATA_MINIFY size_t operatorEntryCounter = 0; +#endif for(const BankEntry &be : banks) { if(commaNeeded) +#ifndef ADL_GENDATA_MINIFY std::fprintf(out, ", "); +#else + std::fprintf(out, ","); +#endif else commaNeeded = true; +#ifndef ADL_GENDATA_MINIFY operatorEntryCounter++; if(operatorEntryCounter >= 25) { @@ -201,7 +221,13 @@ void BanksDump::exportBanks(const std::string &outPath, bool donntOverride, cons } if(operatorEntryCounter == 0) std::fprintf(out, "\t"); +#endif + +#ifdef ADL_GENDATA_MINIFY + std::fprintf(out, "q(%zu)", be.bankId); +#else std::fprintf(out, "g_embeddedBanks[%zu].title", be.bankId); +#endif } std::fprintf(out, ",\n\tNULL"); // Make a null entry as finalizer } @@ -227,7 +253,10 @@ void BanksDump::exportBanks(const std::string &outPath, bool donntOverride, cons for(const MidiBank &be : midiBanks) { bool commaNeeded = true; - std::fprintf(out, "\t{%u,%u,", be.msb, be.lsb); +#ifndef ADL_GENDATA_MINIFY + std::fprintf(out, "\t"); +#endif + std::fprintf(out, "{%u,%u,", be.msb, be.lsb); std::fprintf(out, "{"); commaNeeded = false; @@ -241,7 +270,10 @@ void BanksDump::exportBanks(const std::string &outPath, bool donntOverride, cons } std::fprintf(out, "}"); - std::fprintf(out, "},\n"); + std::fprintf(out, "},"); +#ifndef ADL_GENDATA_MINIFY + std::fprintf(out, "\n"); +#endif } std::fprintf(out, "};\n\n"); @@ -252,7 +284,10 @@ void BanksDump::exportBanks(const std::string &outPath, bool donntOverride, cons { size_t opsCount = ((be.instFlags & InstrumentEntry::WOPL_Ins_4op) != 0 || (be.instFlags & InstrumentEntry::WOPL_Ins_Pseudo4op) != 0) ? 4 : 2; - std::fprintf(out, "\t{%d,%d,%d,%u,%s%lX,%d,%s%lX,%s%lX,%s%lX,", +#ifndef ADL_GENDATA_MINIFY + std::fprintf(out, "\t"); +#endif + std::fprintf(out, "{%d,%d,%d,%u,%s%lX,%d,%s%lX,%s%lX,%s%lX,", be.noteOffset1, be.noteOffset2, be.midiVelocityOffset, @@ -270,26 +305,35 @@ void BanksDump::exportBanks(const std::string &outPath, bool donntOverride, cons std::fprintf(out, "{%ld,%ld}", be.ops[0], be.ops[1]); - std::fprintf(out, "},\n"); + std::fprintf(out, "},"); +#ifndef ADL_GENDATA_MINIFY + std::fprintf(out, "\n"); +#endif } std::fprintf(out, "};\n\n"); std::fprintf(out, "const BanksDump::Operator g_embeddedBanksOperators[] =\n" "{\n"); +#ifndef ADL_GENDATA_MINIFY size_t operatorEntryCounter = 0; +#endif for(const Operator &be : operators) { +#ifndef ADL_GENDATA_MINIFY if(operatorEntryCounter == 0) std::fprintf(out, "\t"); +#endif std::fprintf(out, "{0x%07lX,%s%02lX},", be.d_E862, (be.d_40 == 0 ? "" : "0x"), be.d_40); +#ifndef ADL_GENDATA_MINIFY operatorEntryCounter++; if(operatorEntryCounter >= 25) { std::fprintf(out, "\n"); operatorEntryCounter = 0; } +#endif } std::fprintf(out, "\n};\n\n"); |