diff options
Diffstat (limited to 'utils/gen_adldata/gen_adldata.cc')
-rw-r--r-- | utils/gen_adldata/gen_adldata.cc | 202 |
1 files changed, 71 insertions, 131 deletions
diff --git a/utils/gen_adldata/gen_adldata.cc b/utils/gen_adldata/gen_adldata.cc index 7cb4528..e62ddf2 100644 --- a/utils/gen_adldata/gen_adldata.cc +++ b/utils/gen_adldata/gen_adldata.cc @@ -15,17 +15,6 @@ #include "midi_inst_list.h" -#include "file_formats/load_ail.h" -#include "file_formats/load_bisqwit.h" -#include "file_formats/load_bnk2.h" -#include "file_formats/load_bnk.h" -#include "file_formats/load_ibk.h" -#include "file_formats/load_jv.h" -#include "file_formats/load_op2.h" -#include "file_formats/load_tmb.h" -#include "file_formats/load_wopl.h" -#include "file_formats/load_ea.h" - int main(int argc, char**argv) { if(argc == 1) @@ -39,13 +28,18 @@ int main(int argc, char**argv) const char *outFile_s = argv[1]; +#if 0 FILE *outFile = std::fopen(outFile_s, "w"); if(!outFile) { std::fprintf(stderr, "Can't open %s file for write!\n", outFile_s); return 1; } +#endif + + BanksDump db; +#if 0 std::fprintf(outFile, "\ #include \"adldata.hh\"\n\ \n\ @@ -54,6 +48,9 @@ int main(int argc, char**argv) * PREPROCESSED, CONVERTED, AND POSTPROCESSED OFF-SCREEN.\n\ */\n\ "); +#endif + + { IniProcessing ini; if(!ini.open("banks.ini")) @@ -106,13 +103,13 @@ int main(int argc, char**argv) return 1; } - banknames.push_back(bank_name); +// banknames.push_back(bank_name); //printf("Loading %s...\n", filepath.c_str()); if(format == "AIL") { - if(!LoadMiles(filepath.c_str(), bank, prefix.c_str())) + if(!BankFormats::LoadMiles(db, filepath.c_str(), bank, bank_name, prefix.c_str())) { std::fprintf(stderr, "Failed to load bank %u, file %s!\n", bank, filepath.c_str()); return 1; @@ -121,7 +118,7 @@ int main(int argc, char**argv) else if(format == "Bisqwit") { - if(!LoadBisqwit(filepath.c_str(), bank, prefix.c_str())) + if(!BankFormats::LoadBisqwit(db, filepath.c_str(), bank, bank_name, prefix.c_str())) { std::fprintf(stderr, "Failed to load bank %u, file %s!\n", bank, filepath.c_str()); return 1; @@ -130,7 +127,7 @@ int main(int argc, char**argv) else if(format == "WOPL") { - if(!LoadWopl(filepath.c_str(), bank, prefix.c_str())) + if(!BankFormats::LoadWopl(db, filepath.c_str(), bank, bank_name, prefix.c_str())) { std::fprintf(stderr, "Failed to load bank %u, file %s!\n", bank, filepath.c_str()); return 1; @@ -139,7 +136,7 @@ int main(int argc, char**argv) else if(format == "OP2") { - if(!LoadDoom(filepath.c_str(), bank, prefix.c_str())) + if(!BankFormats::LoadDoom(db, filepath.c_str(), bank, bank_name, prefix.c_str())) { std::fprintf(stderr, "Failed to load bank %u, file %s!\n", bank, filepath.c_str()); return 1; @@ -148,7 +145,7 @@ int main(int argc, char**argv) else if(format == "EA") { - if(!LoadEA(filepath.c_str(), bank, prefix.c_str())) + if(!BankFormats::LoadEA(db, filepath.c_str(), bank, bank_name, prefix.c_str())) { std::fprintf(stderr, "Failed to load bank %u, file %s!\n", bank, filepath.c_str()); return 1; @@ -157,7 +154,7 @@ int main(int argc, char**argv) else if(format == "TMB") { - if(!LoadTMB(filepath.c_str(), bank, prefix.c_str())) + if(!BankFormats::LoadTMB(db, filepath.c_str(), bank, bank_name, prefix.c_str())) { std::fprintf(stderr, "Failed to load bank %u, file %s!\n", bank, filepath.c_str()); return 1; @@ -166,7 +163,7 @@ int main(int argc, char**argv) else if(format == "Junglevision") { - if(!LoadJunglevision(filepath.c_str(), bank, prefix.c_str())) + if(!BankFormats::LoadJunglevision(db, filepath.c_str(), bank, bank_name, prefix.c_str())) { std::fprintf(stderr, "Failed to load bank %u, file %s!\n", bank, filepath.c_str()); return 1; @@ -175,7 +172,7 @@ int main(int argc, char**argv) else if(format == "AdLibGold") { - if(!LoadBNK2(filepath.c_str(), bank, prefix.c_str(), filter_m, filter_p)) + if(!BankFormats::LoadBNK2(db, filepath.c_str(), bank, bank_name, prefix.c_str(), filter_m, filter_p)) { std::fprintf(stderr, "Failed to load bank %u, file %s!\n", bank, filepath.c_str()); return 1; @@ -184,14 +181,14 @@ int main(int argc, char**argv) else if(format == "HMI") { - if(!LoadBNK(filepath.c_str(), bank, prefix.c_str(), false, false)) + if(!BankFormats::LoadBNK(db, filepath.c_str(), bank, bank_name, prefix.c_str(), false, false)) { std::fprintf(stderr, "Failed to load bank %u, file %s!\n", bank, filepath.c_str()); return 1; } if(!filepath_d.empty()) { - if(!LoadBNK(filepath_d.c_str(),bank, prefix_d.c_str(), false, true)) + if(!BankFormats::LoadBNK(db, filepath_d.c_str(), bank, bank_name, prefix_d.c_str(), false, true)) { std::fprintf(stderr, "Failed to load bank %u, file %s!\n", bank, filepath.c_str()); return 1; @@ -201,7 +198,7 @@ int main(int argc, char**argv) else if(format == "IBK") { - if(!LoadIBK(filepath.c_str(), bank, prefix.c_str(), false)) + if(!BankFormats::LoadIBK(db, filepath.c_str(), bank, bank_name, prefix.c_str(), false)) { std::fprintf(stderr, "Failed to load bank %u, file %s!\n", bank, filepath.c_str()); return 1; @@ -209,7 +206,7 @@ int main(int argc, char**argv) if(!filepath_d.empty()) { //printf("Loading %s... \n", filepath_d.c_str()); - if(!LoadIBK(filepath_d.c_str(),bank, prefix_d.c_str(), true, noRhythmMode)) + if(!BankFormats::LoadIBK(db, filepath_d.c_str(),bank, bank_name, prefix_d.c_str(), true, noRhythmMode)) { std::fprintf(stderr, "Failed to load bank %u, file %s!\n", bank, filepath.c_str()); return 1; @@ -260,117 +257,34 @@ int main(int argc, char**argv) } #endif - std::printf("Writing raw instrument data...\n"); - std::fflush(stdout); - { - std::fprintf(outFile, - /* - "static const struct\n" - "{\n" - " unsigned modulator_E862, carrier_E862; // See below\n" - " unsigned char modulator_40, carrier_40; // KSL/attenuation settings\n" - " unsigned char feedconn; // Feedback/connection bits for the channel\n" - " signed char finetune; // Finetune\n" - "} adl[] =\n"*/ - "const adldata adl[%u] =\n" - "{ // ,---------+-------- Wave select settings\n" - " // | ,-------ч-+------ Sustain/release rates\n" - " // | | ,-----ч-ч-+---- Attack/decay rates\n" - " // | | | ,---ч-ч-ч-+-- AM/VIB/EG/KSR/Multiple bits\n" - " // | | | | | | | |\n" - " // | | | | | | | | ,----+-- KSL/attenuation settings\n" - " // | | | | | | | | | | ,----- Feedback/connection bits\n" - " // | | | | | | | | | | | ,----- Fine tune\n\n" - " // | | | | | | | | | | | |\n" - " // | | | | | | | | | | | |\n", (unsigned)insdatatab.size()); - - for(size_t b = insdatatab.size(), c = 0; c < b; ++c) - { - for(std::map<insdata, std::pair<size_t, std::set<std::string> > > - ::const_iterator - i = insdatatab.begin(); - i != insdatatab.end(); - ++i) - { - if(i->second.first != c) continue; - std::fprintf(outFile, " { "); - - uint32_t carrier_E862 = - uint32_t(i->first.data[6] << 24) - + uint32_t(i->first.data[4] << 16) - + uint32_t(i->first.data[2] << 8) - + uint32_t(i->first.data[0] << 0); - uint32_t modulator_E862 = - uint32_t(i->first.data[7] << 24) - + uint32_t(i->first.data[5] << 16) - + uint32_t(i->first.data[3] << 8) - + uint32_t(i->first.data[1] << 0); - - std::fprintf(outFile, "0x%07X,0x%07X, 0x%02X,0x%02X, 0x%X, %+d", - carrier_E862, - modulator_E862, - i->first.data[8], - i->first.data[9], - i->first.data[10], - i->first.finetune); - -#ifdef ADLDATA_WITH_COMMENTS - std::string names; - for(std::set<std::string>::const_iterator - j = i->second.second.begin(); - j != i->second.second.end(); - ++j) - { - if(!names.empty()) names += "; "; - if((*j)[0] == '\377') - names += j->substr(1); - else - names += *j; - } - std::fprintf(outFile, " }, // %u: %s\n", (unsigned)c, names.c_str()); -#else - std::fprintf(outFile, " },\n"); -#endif - } - } - std::fprintf(outFile, "};\n"); - } - - /*std::fprintf(outFile, "static const struct\n" - "{\n" - " unsigned short adlno1, adlno2;\n" - " unsigned char tone;\n" - " unsigned char flags;\n" - " long ms_sound_kon; // Number of milliseconds it produces sound;\n" - " long ms_sound_koff;\n" - " double voice2_fine_tune;\n" - "} adlins[] =\n");*/ - - std::fprintf(outFile, "const struct adlinsdata adlins[%u] =\n", (unsigned)instab.size()); - std::fprintf(outFile, "{\n"); +// std::printf("Writing raw instrument data...\n"); +// std::fflush(stdout); MeasureThreaded measureCounter; - { - std::printf("Beginning to generate measures data... (hardware concurrency of %d)\n", std::thread::hardware_concurrency()); - std::fflush(stdout); - measureCounter.LoadCache("fm_banks/adldata-cache.dat"); - measureCounter.m_total = instab.size(); - for(size_t b = instab.size(), c = 0; c < b; ++c) - { - for(std::map<ins, std::pair<size_t, std::set<std::string> > >::const_iterator i = instab.begin(); i != instab.end(); ++i) - { - if(i->second.first != c) continue; - measureCounter.run(i); - } - } - std::fflush(stdout); - measureCounter.waitAll(); - measureCounter.SaveCache("fm_banks/adldata-cache.dat"); - } +//#ifndef GEN_ADLDATA_DEEP_DEBUG // Skip slowest place to work with a debug +// { +// std::printf("Beginning to generate measures data... (hardware concurrency of %d)\n", std::thread::hardware_concurrency()); +// std::fflush(stdout); +// measureCounter.LoadCache("fm_banks/adldata-cache.dat"); +// measureCounter.m_total = instab.size(); +// for(size_t b = instab.size(), c = 0; c < b; ++c) +// { +// for(std::map<ins, std::pair<size_t, std::set<std::string> > >::const_iterator i = instab.begin(); i != instab.end(); ++i) +// { +// if(i->second.first != c) continue; +// measureCounter.run(i); +// } +// } +// std::fflush(stdout); +// measureCounter.waitAll(); +// measureCounter.SaveCache("fm_banks/adldata-cache.dat"); +// } +//#endif - std::printf("Writing generated measure data...\n"); - std::fflush(stdout); +// std::printf("Writing generated measure data...\n"); +// std::fflush(stdout); +#if 0 std::vector<unsigned> adlins_flags; for(size_t b = instab.size(), c = 0; c < b; ++c) @@ -476,6 +390,7 @@ int main(int argc, char**argv) } std::set<size_t> listed; + std::fprintf(outFile, "\n\n//Returns total number of generated banks\n" "int maxAdlBanks()\n" @@ -538,6 +453,10 @@ int main(int argc, char**argv) #endif } +#endif + + +#if 0 std::fprintf(outFile, "};\n\n"); std::fflush(outFile); @@ -564,6 +483,27 @@ int main(int argc, char**argv) std::fflush(outFile); std::fclose(outFile); +#endif + + { + measureCounter.LoadCacheX("fm_banks/adldata-cache.dat"); + measureCounter.m_durationInfo.clear(); + measureCounter.m_cache_matches = 0; + measureCounter.m_done = 0; + measureCounter.m_total = db.instruments.size(); + std::printf("Beginning to generate measures data... (hardware concurrency of %d)\n", std::thread::hardware_concurrency()); + std::fflush(stdout); + for(size_t b = 0; b < db.instruments.size(); ++b) + { + assert(db.instruments[b].instId == b); + measureCounter.run(db, db.instruments[b]); + } + std::fflush(stdout); + measureCounter.waitAll(); + measureCounter.SaveCacheX("fm_banks/adldata-cache.dat"); + } + + db.exportBanks(std::string(outFile_s)); std::printf("Generation of ADLMIDI data has been completed!\n"); std::fflush(stdout); |