diff options
author | Wohlstand <admin@wohlnet.ru> | 2017-07-30 05:06:18 +0300 |
---|---|---|
committer | Wohlstand <admin@wohlnet.ru> | 2017-07-30 05:06:18 +0300 |
commit | b15f8552d629021c3cadef3e7afcae2fa98dad1b (patch) | |
tree | aa72effc4fb6690c73428fa26d1f8615383a6311 /src/gen_adldata/file_formats/load_bisqwit.h | |
parent | fd80dc0af0617a17f4604a9a12592398476eb5ed (diff) | |
download | libADLMIDI-b15f8552d629021c3cadef3e7afcae2fa98dad1b.tar.gz libADLMIDI-b15f8552d629021c3cadef3e7afcae2fa98dad1b.tar.bz2 libADLMIDI-b15f8552d629021c3cadef3e7afcae2fa98dad1b.zip |
Improve gen_adldata program
- Now it caches all generated data, so, we won't have to re-calculate same
- File is writing by gen_adldata nor by stdout forward
- Instead of hardcoded list of banks, I made the INI file which declares list of banks to generate
- Add simple validators to tell which bank is absense and can't be loaded
- Split code of gen_adldata.cc into multiple files of different role
Diffstat (limited to 'src/gen_adldata/file_formats/load_bisqwit.h')
-rw-r--r-- | src/gen_adldata/file_formats/load_bisqwit.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/gen_adldata/file_formats/load_bisqwit.h b/src/gen_adldata/file_formats/load_bisqwit.h new file mode 100644 index 0000000..98fcd83 --- /dev/null +++ b/src/gen_adldata/file_formats/load_bisqwit.h @@ -0,0 +1,53 @@ +#ifndef LOAD_BISQWIT_H +#define LOAD_BISQWIT_H + +#include "../progs_cache.h" +#include "../midi_inst_list.h" + +static bool LoadBisqwit(const char *fn, unsigned bank, const char *prefix) +{ + #ifdef HARD_BANKS + writeIni("Bisqwit", fn, prefix, bank, INI_Both); + #endif + FILE *fp = std::fopen(fn, "rb"); + if(!fp) + return false; + + for(uint32_t a = 0; a < 256; ++a) + { + //unsigned offset = a * 25; + uint32_t gmno = a; + int32_t midi_index = gmno < 128 ? int32_t(gmno) + : gmno < 128 + 35 ? -1 + : gmno < 128 + 88 ? int32_t(gmno - 35) + : -1; + + struct ins tmp2; + tmp2.notenum = (uint8_t)std::fgetc(fp); + tmp2.pseudo4op = false; + tmp2.fine_tune = 0.0; + + insdata tmp[2]; + for(int side = 0; side < 2; ++side) + { + tmp[side].finetune = (int8_t)std::fgetc(fp); + tmp[side].diff = false; + if(std::fread(tmp[side].data, 1, 11, fp) != 11) + return false; + } + + std::string name; + if(midi_index >= 0) name = std::string(1, '\377') + MidiInsName[midi_index]; + + char name2[512]; + sprintf(name2, "%s%c%u", prefix, + (gmno < 128 ? 'M' : 'P'), gmno & 127); + + size_t resno = InsertIns(tmp[0], tmp[1], tmp2, name, name2); + SetBank(bank, gmno, resno); + } + std::fclose(fp); + return true; +} + +#endif // LOAD_BISQWIT_H |