From b15f8552d629021c3cadef3e7afcae2fa98dad1b Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Sun, 30 Jul 2017 05:06:18 +0300 Subject: 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 --- src/gen_adldata/progs_cache.h | 85 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/gen_adldata/progs_cache.h (limited to 'src/gen_adldata/progs_cache.h') diff --git a/src/gen_adldata/progs_cache.h b/src/gen_adldata/progs_cache.h new file mode 100644 index 0000000..6502925 --- /dev/null +++ b/src/gen_adldata/progs_cache.h @@ -0,0 +1,85 @@ +#ifndef PROGS_H +#define PROGS_H + +#include +#include +#include +#include +#include +#include +#include + +struct insdata +{ + uint8_t data[11]; + int8_t finetune; + bool diff; + bool operator==(const insdata &b) const + { + return std::memcmp(data, b.data, 11) == 0 && finetune == b.finetune && diff == b.diff; + } + bool operator< (const insdata &b) const + { + int c = std::memcmp(data, b.data, 11); + if(c != 0) return c < 0; + if(finetune != b.finetune) return finetune < b.finetune; + if(diff != b.diff) return (!diff) == (b.diff); + return 0; + } + bool operator!=(const insdata &b) const + { + return !operator==(b); + } +}; + +struct ins +{ + size_t insno1, insno2; + unsigned char notenum; + bool pseudo4op; + double fine_tune; + + bool operator==(const ins &b) const + { + return notenum == b.notenum + && insno1 == b.insno1 + && insno2 == b.insno2 + && pseudo4op == b.pseudo4op + && fine_tune == b.fine_tune; + } + bool operator< (const ins &b) const + { + if(insno1 != b.insno1) return insno1 < b.insno1; + if(insno2 != b.insno2) return insno2 < b.insno2; + if(notenum != b.notenum) return notenum < b.notenum; + if(pseudo4op != b.pseudo4op) return pseudo4op < b.pseudo4op; + if(fine_tune != b.fine_tune) return fine_tune < b.fine_tune; + return 0; + } + bool operator!=(const ins &b) const + { + return !operator==(b); + } +}; + +typedef std::map > > InstrumentDataTab; +extern InstrumentDataTab insdatatab; + +typedef std::map > > InstrumentsData; +extern InstrumentsData instab; + +typedef std::map > InstProgsData; +extern InstProgsData progs; + +extern std::vector banknames; + +//static std::map > Correlate; +//extern unsigned maxvalues[30]; + +void SetBank(unsigned bank, unsigned patch, size_t insno); + +size_t InsertIns(const insdata &id, const insdata &id2, ins &in, + const std::string &name, const std::string &name2 = ""); +size_t InsertNoSoundIns(); + +#endif // PROGS_H -- cgit v1.2.3