aboutsummaryrefslogtreecommitdiff
path: root/utils/gen_adldata
diff options
context:
space:
mode:
authorWohlstand <admin@wohlnet.ru>2020-08-23 23:54:07 +0300
committerWohlstand <admin@wohlnet.ru>2020-08-23 23:54:07 +0300
commit1b4237dffce60e8546e550767b2816c1979bbb9d (patch)
treeac6b7f10b05bfe47a3b6b8884b43993a11c928b7 /utils/gen_adldata
parentf656802667e93be893ebc30a18b0f12482586e6f (diff)
downloadlibADLMIDI-1b4237dffce60e8546e550767b2816c1979bbb9d.tar.gz
libADLMIDI-1b4237dffce60e8546e550767b2816c1979bbb9d.tar.bz2
libADLMIDI-1b4237dffce60e8546e550767b2816c1979bbb9d.zip
gen_adldata: Remove more old code
Diffstat (limited to 'utils/gen_adldata')
-rw-r--r--utils/gen_adldata/file_formats/common.h1
-rw-r--r--utils/gen_adldata/file_formats/load_ail.h23
-rw-r--r--utils/gen_adldata/file_formats/load_bisqwit.h31
-rw-r--r--utils/gen_adldata/file_formats/load_bnk.h14
-rw-r--r--utils/gen_adldata/file_formats/load_bnk2.h16
-rw-r--r--utils/gen_adldata/file_formats/load_ea.h15
-rw-r--r--utils/gen_adldata/file_formats/load_ibk.h18
-rw-r--r--utils/gen_adldata/file_formats/load_jv.h35
-rw-r--r--utils/gen_adldata/file_formats/load_op2.h86
-rw-r--r--utils/gen_adldata/file_formats/load_tmb.h14
-rw-r--r--utils/gen_adldata/file_formats/load_wopl.h72
-rw-r--r--utils/gen_adldata/gen_adldata.cc1
-rw-r--r--utils/gen_adldata/measurer.h3
-rw-r--r--utils/gen_adldata/progs_cache.cpp29
-rw-r--r--utils/gen_adldata/progs_cache.h129
15 files changed, 157 insertions, 330 deletions
diff --git a/utils/gen_adldata/file_formats/common.h b/utils/gen_adldata/file_formats/common.h
index a03ca5d..644e7a6 100644
--- a/utils/gen_adldata/file_formats/common.h
+++ b/utils/gen_adldata/file_formats/common.h
@@ -1,3 +1,4 @@
+#pragma once
#ifndef COMMON_H
#define COMMON_H
diff --git a/utils/gen_adldata/file_formats/load_ail.h b/utils/gen_adldata/file_formats/load_ail.h
index 3ab38ef..d6fa014 100644
--- a/utils/gen_adldata/file_formats/load_ail.h
+++ b/utils/gen_adldata/file_formats/load_ail.h
@@ -104,7 +104,7 @@ bool BankFormats::LoadMiles(BanksDump &db, const char *fn, unsigned bank,
sprintf(name2, "%s%c%u", prefix,
(gmno < 128 ? 'M' : 'P'), gmno & 127);
- insdata tmp[200];
+ InstBuffer tmp[200];
const unsigned inscount = (length - 3) / 11;
// bool twoOp = (inscount == 1);
@@ -114,8 +114,8 @@ bool BankFormats::LoadMiles(BanksDump &db, const char *fn, unsigned bank,
if(i >= 2)
break;
unsigned o = offset + 3 + i * 11;
- tmp[i].finetune = (gmno < 128 && i == 0) ? notenum : 0;
- tmp[i].diff = (i == 1);
+// tmp[i].finetune = (gmno < 128 && i == 0) ? notenum : 0;
+// tmp[i].diff = (i == 1);
uint8_t temp[11] = {0};
if(o < data.size())
@@ -144,18 +144,19 @@ bool BankFormats::LoadMiles(BanksDump &db, const char *fn, unsigned bank,
tmp[0].data[10] = fb_c & 0x0F;
tmp[1].data[10] = uint8_t((fb_c & 0x0E) | (fb_c >> 7));
}
- db.toOps(tmp[i], ops, i * 2);
+ db.toOps(tmp[i].d, ops, i * 2);
}
if(inscount <= 2)
{
- struct ins tmp2;
- tmp2.notenum = gmno < 128 ? 0 : (unsigned char)notenum;
- tmp2.pseudo4op = false;
- tmp2.real4op = (inscount > 1);
- tmp2.voice2_fine_tune = 0.0;
- tmp2.midi_velocity_offset = 0;
- tmp2.rhythmModeDrum = 0;
+// struct ins tmp2;
+// tmp2.notenum = gmno < 128 ? 0 : (unsigned char)notenum;
+// tmp2.pseudo4op = false;
+// tmp2.real4op = (inscount > 1);
+// tmp2.voice2_fine_tune = 0.0;
+// tmp2.midi_velocity_offset = 0;
+// tmp2.rhythmModeDrum = 0;
+
// std::string name;
// if(midi_index >= 0) name = std::string(1, '\377') + MidiInsName[midi_index];
// if(h.bank == 0 || h.bank == 0x7F)
diff --git a/utils/gen_adldata/file_formats/load_bisqwit.h b/utils/gen_adldata/file_formats/load_bisqwit.h
index 478935f..63d133f 100644
--- a/utils/gen_adldata/file_formats/load_bisqwit.h
+++ b/utils/gen_adldata/file_formats/load_bisqwit.h
@@ -6,9 +6,9 @@
bool BankFormats::LoadBisqwit(BanksDump &db, const char *fn, unsigned bank, const std::string &bankTitle, const char *prefix)
{
- #ifdef HARD_BANKS
+#ifdef HARD_BANKS
writeIni("Bisqwit", fn, prefix, bank, INI_Both);
- #endif
+#endif
FILE *fp = std::fopen(fn, "rb");
if(!fp)
return false;
@@ -33,18 +33,12 @@ bool BankFormats::LoadBisqwit(BanksDump &db, const char *fn, unsigned bank, cons
BanksDump::InstrumentEntry inst;
BanksDump::Operator ops[5];
- struct ins tmp2;
- tmp2.notenum = (uint8_t)std::fgetc(fp);
- tmp2.pseudo4op = false;
- tmp2.voice2_fine_tune = 0.0;
- tmp2.midi_velocity_offset = 0;
- tmp2.rhythmModeDrum = 0;
+ uint8_t notenum = static_cast<uint8_t>(std::fgetc(fp));
- insdata tmp[2];
+ InstBuffer tmp[2];
for(int side = 0; side < 2; ++side)
{
- tmp[side].finetune = (int8_t)std::fgetc(fp);
- tmp[side].diff = false;
+ std::fseek(fp, +1, SEEK_CUR); // skip first byte, unused "fine tune"
if(std::fread(tmp[side].data, 1, 11, fp) != 11)
return false;
}
@@ -56,21 +50,16 @@ bool BankFormats::LoadBisqwit(BanksDump &db, const char *fn, unsigned bank, cons
sprintf(name2, "%s%c%u", prefix,
(gmno < 128 ? 'M' : 'P'), gmno & 127);
- tmp[1].diff = (tmp[0] != tmp[1]);
- tmp2.real4op = tmp[1].diff;
-// size_t resno = InsertIns(tmp[0], tmp[1], tmp2, name, name2, (tmp[0] == tmp[1]));
-// SetBank(bank, gmno, resno);
-
- db.toOps(tmp[0], ops, 0);
- if(tmp[0] != tmp[1])
+ db.toOps(tmp[0].d, ops, 0);
+ if(tmp[0].d != tmp[1].d)
{
inst.instFlags |= BanksDump::InstrumentEntry::WOPL_Ins_4op;
- db.toOps(tmp[1], ops, 2);
+ db.toOps(tmp[1].d, ops, 2);
}
inst.fbConn = uint_fast16_t(tmp[0].data[10]) | (uint_fast16_t(tmp[1].data[10]) << 8);
- inst.percussionKeyNumber = a >= 128 ? tmp2.notenum : 0;
- inst.noteOffset1 = a < 128 ? tmp2.notenum : 0;
+ inst.percussionKeyNumber = a >= 128 ? notenum : 0;
+ inst.noteOffset1 = a < 128 ? notenum : 0;
db.addInstrument(bnk, patchId, inst, ops, fn);
}
std::fclose(fp);
diff --git a/utils/gen_adldata/file_formats/load_bnk.h b/utils/gen_adldata/file_formats/load_bnk.h
index ed47567..29f5494 100644
--- a/utils/gen_adldata/file_formats/load_bnk.h
+++ b/utils/gen_adldata/file_formats/load_bnk.h
@@ -88,7 +88,7 @@ bool BankFormats::LoadBNK(BanksDump &db, const char *fn, unsigned bank,
BanksDump::InstrumentEntry inst;
BanksDump::Operator ops[5];
- insdata tmp;
+ InstBuffer tmp;
tmp.data[0] = uint8_t(
(op1[ 9] << 7) // TREMOLO FLAG
+ (op1[10] << 6) // VIBRATO FLAG
@@ -110,21 +110,13 @@ bool BankFormats::LoadBNK(BanksDump &db, const char *fn, unsigned bank,
tmp.data[8] = op1[0] * 0x40 + op1[8]; // KSL , LEVEL
tmp.data[9] = op2[0] * 0x40 + op2[8]; // KSL , LEVEL
tmp.data[10] = op1[2] * 2 + op1[12]; // FEEDBACK, ADDITIVEFLAG
- tmp.finetune = 0;
- tmp.diff = false;
+
// Note: op2[2] and op2[12] are unused and contain garbage.
- ins tmp2;
- tmp2.notenum = is_fat ? voice_num : (percussive ? usage_flag : 0);
- tmp2.pseudo4op = false;
- tmp2.real4op = false;
- tmp2.voice2_fine_tune = 0.0;
- tmp2.midi_velocity_offset = 0;
- tmp2.rhythmModeDrum = 0;
if(is_fat)
tmp.data[10] ^= 1;
- db.toOps(tmp, ops, 0);
+ db.toOps(tmp.d, ops, 0);
inst.percussionKeyNumber = is_fat ? voice_num : (percussive ? usage_flag : 0);
inst.setFbConn(op1[2] * 2 + op1[12]);
diff --git a/utils/gen_adldata/file_formats/load_bnk2.h b/utils/gen_adldata/file_formats/load_bnk2.h
index 1d78c4b..46ba604 100644
--- a/utils/gen_adldata/file_formats/load_bnk2.h
+++ b/utils/gen_adldata/file_formats/load_bnk2.h
@@ -83,7 +83,7 @@ bool BankFormats::LoadBNK2(BanksDump &db, const char *fn, unsigned bank,
BanksDump::InstrumentEntry inst;
BanksDump::Operator opsD[5];
- struct insdata tmp[2];
+ InstBuffer tmp[2];
for(unsigned a = 0; a < 2; ++a)
{
tmp[a].data[0] = ops[a * 2 + 0][0];
@@ -96,21 +96,11 @@ bool BankFormats::LoadBNK2(BanksDump &db, const char *fn, unsigned bank,
tmp[a].data[7] = ops[a * 2 + 1][4] & 0x07;
tmp[a].data[8] = ops[a * 2 + 0][1];
tmp[a].data[9] = ops[a * 2 + 1][1];
- tmp[a].finetune = (int8_t)TTTTTTTT;
- tmp[a].diff = false;
- db.toOps(tmp[a], opsD, a * 2);
+ db.toOps(tmp[a].d, opsD, a * 2);
}
tmp[0].data[10] = C4xxxFFFC & 0x0F;
tmp[1].data[10] = (tmp[0].data[10] & 0x0E) | (C4xxxFFFC >> 7);
- ins tmp2;
- tmp2.notenum = (gmno & 128) ? 35 : 0;
- tmp2.pseudo4op = false;
- tmp2.real4op = false;
- tmp2.voice2_fine_tune = 0.0;
- tmp2.midi_velocity_offset = 0;
- tmp2.rhythmModeDrum = 0;
-
inst.setFbConn(C4xxxFFFC & 0x0F, (tmp[0].data[10] & 0x0E) | (C4xxxFFFC >> 7));
inst.noteOffset1 = (int8_t)TTTTTTTT;
inst.percussionKeyNumber = (gmno & 128) ? 35 : 0;
@@ -118,8 +108,6 @@ bool BankFormats::LoadBNK2(BanksDump &db, const char *fn, unsigned bank,
if(xxP24NNN & 8)
{
// dual-op
- tmp2.real4op = true;
- tmp[1].diff = true;
inst.instFlags |= BanksDump::InstrumentEntry::WOPL_Ins_4op;
db.addInstrument(bnk, patchId, inst, opsD, fn);
}
diff --git a/utils/gen_adldata/file_formats/load_ea.h b/utils/gen_adldata/file_formats/load_ea.h
index 43d4d5d..5e5711e 100644
--- a/utils/gen_adldata/file_formats/load_ea.h
+++ b/utils/gen_adldata/file_formats/load_ea.h
@@ -69,7 +69,7 @@ bool BankFormats::LoadEA(BanksDump &db, const char *fn, unsigned bank,
BanksDump::InstrumentEntry inst;
BanksDump::Operator ops[5];
- insdata tmp;
+ InstBuffer tmp;
tmp.data[0] = bytes[0]; // reg 0x20: modulator AM/VIG/EG/KSR
tmp.data[8] = bytes[1]; // reg 0x40: modulator ksl/attenuation
tmp.data[2] = bytes[2]; // reg 0x60: modulator attack/decay
@@ -86,17 +86,10 @@ bool BankFormats::LoadEA(BanksDump &db, const char *fn, unsigned bank,
tmp.data[10] = bytes[8]; // reg 0xC0 (feedback and connection)
- tmp.finetune = int8_t(bytes[9] + 12); // finetune
tmp.data[6] = 0; // reg 0xE0: modulator, never seems to be set
tmp.data[7] = 0; // reg 0xE0: carrier, never seems to be set
- ins tmp2;
- tmp2.notenum = 0;
- tmp2.pseudo4op = false;
- tmp2.real4op = false;
- tmp2.rhythmModeDrum = 0;
-
- db.toOps(tmp, ops, 0);
+ db.toOps(tmp.d, ops, 0);
inst.setFbConn(bytes[8]);
inst.noteOffset1 = int8_t(bytes[9] + 12);
@@ -115,28 +108,24 @@ bool BankFormats::LoadEA(BanksDump &db, const char *fn, unsigned bank,
if(gmno == 10)
{
- /*tmp.finetune=0;*/ tmp2.notenum = 0x49;
inst.percussionKeyNumber = 0x49;
db.addInstrument(bnkPercussion, 0x36, inst, ops, fn);
}
if(gmno == 18)
{
- /*tmp.finetune=0;*/ tmp2.notenum = 0x17;
inst.percussionKeyNumber = 0x17;
db.addInstrument(bnkPercussion, 0x2A, inst, ops, fn);
}
if(gmno == 16)
{
- /*tmp.finetune=0;*/ tmp2.notenum = 0x0C;
inst.percussionKeyNumber = 0x0C;
db.addInstrument(bnkPercussion, 0x24, inst, ops, fn);
}
if(gmno == 17)
{
- /*tmp.finetune=0;*/ tmp2.notenum = 0x01;
inst.percussionKeyNumber = 0x01;
db.addInstrument(bnkPercussion, 0x26, inst, ops, fn);
}
diff --git a/utils/gen_adldata/file_formats/load_ibk.h b/utils/gen_adldata/file_formats/load_ibk.h
index d5794c5..f95a244 100644
--- a/utils/gen_adldata/file_formats/load_ibk.h
+++ b/utils/gen_adldata/file_formats/load_ibk.h
@@ -51,7 +51,7 @@ bool BankFormats::LoadIBK(BanksDump &db, const char *fn, unsigned bank,
BanksDump::InstrumentEntry inst;
BanksDump::Operator ops[5];
- insdata tmp;
+ InstBuffer tmp;
tmp.data[0] = data[offset2 + 0];
tmp.data[1] = data[offset2 + 1];
tmp.data[8] = data[offset2 + 2];
@@ -65,44 +65,30 @@ bool BankFormats::LoadIBK(BanksDump &db, const char *fn, unsigned bank,
tmp.data[10] = data[offset2 + 10];
// bisqwit: [+11] seems to be used also, what is it for?
// Wohlstand: You wanna know? It's the rhythm-mode drum number! If 0 - melodic, >0 - rhythm-mode drum
- tmp.finetune = percussive ? 0 : data[offset2 + 12];
- tmp.diff = false;
- struct ins tmp2;
- tmp2.notenum = percussive ? data[offset2 + 13] : 0;
- tmp2.pseudo4op = false;
- tmp2.real4op = false;
- tmp2.voice2_fine_tune = 0.0;
- tmp2.midi_velocity_offset = 0;
- db.toOps(tmp, ops, 0);
+ db.toOps(tmp.d, ops, 0);
inst.noteOffset1 = percussive ? 0 : data[offset2 + 12];
inst.percussionKeyNumber = percussive ? data[offset2 + 13] : 0;
inst.setFbConn(data[offset2 + 10]);
- tmp2.rhythmModeDrum = 0;
if(percussive && !noRhythmMode)
{
int rm = data[offset2 + 11];
switch(rm)
{
case 6:
- tmp2.rhythmModeDrum = ins::Flag_RM_BassDrum;
inst.instFlags |= BanksDump::InstrumentEntry::WOPL_RM_BassDrum;
break;
case 7:
- tmp2.rhythmModeDrum = ins::Flag_RM_Snare;
inst.instFlags |= BanksDump::InstrumentEntry::WOPL_RM_Snare;
break;
case 8:
- tmp2.rhythmModeDrum = ins::Flag_RM_TomTom;
inst.instFlags |= BanksDump::InstrumentEntry::WOPL_RM_TomTom;
break;
case 9:
- tmp2.rhythmModeDrum = ins::Flag_RM_Cymbal;
inst.instFlags |= BanksDump::InstrumentEntry::WOPL_RM_Cymbal;
break;
case 10:
- tmp2.rhythmModeDrum = ins::Flag_RM_HiHat;
inst.instFlags |= BanksDump::InstrumentEntry::WOPL_RM_HiHat;
break;
default:
diff --git a/utils/gen_adldata/file_formats/load_jv.h b/utils/gen_adldata/file_formats/load_jv.h
index 381f562..9281114 100644
--- a/utils/gen_adldata/file_formats/load_jv.h
+++ b/utils/gen_adldata/file_formats/load_jv.h
@@ -47,8 +47,9 @@ bool BankFormats::LoadJunglevision(BanksDump &db, const char *fn, unsigned bank,
BanksDump::MidiBank &bnk = isPercussion ? bnkPercussion : bnkMelodique;
BanksDump::InstrumentEntry inst;
BanksDump::Operator ops[5];
+ uint8_t notenum;
- insdata tmp[2];
+ InstBuffer tmp[2];
tmp[0].data[0] = data[offset + 2];
tmp[0].data[1] = data[offset + 8];
@@ -61,8 +62,7 @@ bool BankFormats::LoadJunglevision(BanksDump &db, const char *fn, unsigned bank,
tmp[0].data[8] = data[offset + 3];
tmp[0].data[9] = data[offset + 9];
tmp[0].data[10] = data[offset + 7] & 0x0F;//~0x30;
- tmp[0].finetune = 0;
- tmp[0].diff = false;
+ inst.noteOffset1 = 0;
tmp[1].data[0] = data[offset + 2 + 11];
tmp[1].data[1] = data[offset + 8 + 11];
@@ -75,30 +75,23 @@ bool BankFormats::LoadJunglevision(BanksDump &db, const char *fn, unsigned bank,
tmp[1].data[8] = data[offset + 3 + 11];
tmp[1].data[9] = data[offset + 9 + 11];
tmp[1].data[10] = data[offset + 7 + 11] & 0x0F;//~0x30;
- tmp[1].finetune = 0;
- tmp[1].diff = (data[offset] != 0);
-
- struct ins tmp2;
- tmp2.notenum = data[offset + 1];
- tmp2.pseudo4op = false;
- tmp2.real4op = (data[offset] != 0);
- tmp2.voice2_fine_tune = 0.0;
- tmp2.midi_velocity_offset = 0;
- tmp2.rhythmModeDrum = 0;
-
- while(tmp2.notenum && tmp2.notenum < 20)
+ inst.noteOffset2 = 0;
+
+ notenum = data[offset + 1];
+
+ while(notenum && notenum < 20)
{
- tmp2.notenum += 12;
- tmp[0].finetune -= 12;
- tmp[1].finetune -= 12;
+ notenum += 12;
+ inst.noteOffset1 -= 12;
+ inst.noteOffset2 -= 12;
}
if(data[offset] != 0)
inst.instFlags |= BanksDump::InstrumentEntry::WOPL_Ins_4op;
- inst.percussionKeyNumber = data[offset + 1];
+ inst.percussionKeyNumber = notenum;
inst.setFbConn(data[offset + 7], data[offset + 7 + 11]);
- db.toOps(tmp[0], ops, 0);
- db.toOps(tmp[1], ops, 2);
+ db.toOps(tmp[0].d, ops, 0);
+ db.toOps(tmp[1].d, ops, 2);
std::string name;
if(midi_index >= 0)
diff --git a/utils/gen_adldata/file_formats/load_op2.h b/utils/gen_adldata/file_formats/load_op2.h
index 0c56ef6..e43f17f 100644
--- a/utils/gen_adldata/file_formats/load_op2.h
+++ b/utils/gen_adldata/file_formats/load_op2.h
@@ -2,6 +2,9 @@
#define LOAD_OP2_H
#include "../progs_cache.h"
+#ifndef COMMON_H
+#include "common.h"
+#endif
#ifndef _MSC_VER
#define PACKED_STRUCT __attribute__((packed))
@@ -15,32 +18,32 @@
struct Doom_OPL2instrument
{
- unsigned char trem_vibr_1; /* OP 1: tremolo/vibrato/sustain/KSR/multi */
- unsigned char att_dec_1; /* OP 1: attack rate/decay rate */
- unsigned char sust_rel_1; /* OP 1: sustain level/release rate */
- unsigned char wave_1; /* OP 1: waveform select */
- unsigned char scale_1; /* OP 1: key scale level */
- unsigned char level_1; /* OP 1: output level */
- unsigned char feedback; /* feedback/AM-FM (both operators) */
- unsigned char trem_vibr_2; /* OP 2: tremolo/vibrato/sustain/KSR/multi */
- unsigned char att_dec_2; /* OP 2: attack rate/decay rate */
- unsigned char sust_rel_2; /* OP 2: sustain level/release rate */
- unsigned char wave_2; /* OP 2: waveform select */
- unsigned char scale_2; /* OP 2: key scale level */
- unsigned char level_2; /* OP 2: output level */
- unsigned char unused;
- short basenote; /* base note offset */
+ uint8_t trem_vibr_1; /* OP 1: tremolo/vibrato/sustain/KSR/multi */
+ uint8_t att_dec_1; /* OP 1: attack rate/decay rate */
+ uint8_t sust_rel_1; /* OP 1: sustain level/release rate */
+ uint8_t wave_1; /* OP 1: waveform select */
+ uint8_t scale_1; /* OP 1: key scale level */
+ uint8_t level_1; /* OP 1: output level */
+ uint8_t feedback; /* feedback/AM-FM (both operators) */
+ uint8_t trem_vibr_2; /* OP 2: tremolo/vibrato/sustain/KSR/multi */
+ uint8_t att_dec_2; /* OP 2: attack rate/decay rate */
+ uint8_t sust_rel_2; /* OP 2: sustain level/release rate */
+ uint8_t wave_2; /* OP 2: waveform select */
+ uint8_t scale_2; /* OP 2: key scale level */
+ uint8_t level_2; /* OP 2: output level */
+ uint8_t unused;
+ uint8_t basenote[2]; /* base note offset */
} PACKED_STRUCT;
struct Doom_opl_instr
{
- unsigned short flags;
+ uint8_t flags[2];
#define FL_FIXED_PITCH 0x0001 // note has fixed pitch (drum note)
-#define FL_UNKNOWN 0x0002 // ??? (used in instrument #65 only)
+#define FL_VIB_DELAY 0x0002 // vib_delay (used in instrument #65 only)
#define FL_DOUBLE_VOICE 0x0004 // use two voices instead of one
- unsigned char finetune;
- unsigned char note;
+ uint8_t finetune;
+ uint8_t note;
struct Doom_OPL2instrument patchdata[2];
} PACKED_STRUCT;
@@ -92,10 +95,11 @@ bool BankFormats::LoadDoom(BanksDump &db, const char *fn, unsigned bank, const s
snprintf(name2, 512, "%s%c%u", prefix, (gmno < 128 ? 'M' : 'P'), gmno & 127);
Doom_opl_instr &ins = *(Doom_opl_instr *) &data[offset2];
+ uint16_t flags = toSint16LE(ins.flags);
+
+ InstBuffer tmp[2] = {MakeNoSoundIns1(), MakeNoSoundIns1()};
+ int16_t noteOffset[2];
- insdata tmp[2] = {MakeNoSoundIns(), MakeNoSoundIns()};
- tmp[0].diff = false;
- tmp[1].diff = false;
for(size_t index = 0; index < 2; ++index)
{
const Doom_OPL2instrument &src = ins.patchdata[index];
@@ -110,40 +114,28 @@ bool BankFormats::LoadDoom(BanksDump &db, const char *fn, unsigned bank, const s
tmp[index].data[8] = src.scale_1 | src.level_1;
tmp[index].data[9] = src.scale_2 | src.level_2;
tmp[index].data[10] = src.feedback;
- tmp[index].finetune = int8_t(src.basenote + 12);
+ noteOffset[index] = toSint16LE(src.basenote) + 12;
inst.fbConn |= (uint_fast16_t(src.feedback) << (index == 1 ? 8 : 0));
- db.toOps(tmp[index], ops, index * 2);
+ db.toOps(tmp[index].d, ops, index * 2);
}
- struct ins tmp2;
- tmp2.notenum = ins.note;
- tmp2.pseudo4op = false;
- tmp2.real4op = false;
- tmp2.voice2_fine_tune = 0.0;
- tmp2.midi_velocity_offset = 0;
- tmp2.rhythmModeDrum = 0;
-
- while(tmp2.notenum && tmp2.notenum < 20)
+
+ uint8_t notenum = ins.note;
+
+ while(notenum && notenum < 20)
{
- tmp2.notenum += 12;
- tmp[0].finetune -= 12;
- tmp[1].finetune -= 12;
+ notenum += 12;
+ noteOffset[0] -= 12;
+ noteOffset[1] -= 12;
}
- inst.noteOffset1 = int8_t(tmp[0].finetune);
- inst.noteOffset2 = int8_t(tmp[1].finetune);
+ inst.noteOffset1 = noteOffset[0];
+ inst.noteOffset2 = noteOffset[1];
- if((ins.flags & FL_DOUBLE_VOICE) != 0)
+ if((flags & FL_DOUBLE_VOICE) != 0)
inst.instFlags |= BanksDump::InstrumentEntry::WOPL_Ins_4op | BanksDump::InstrumentEntry::WOPL_Ins_Pseudo4op;
- inst.percussionKeyNumber = tmp2.notenum;
+ inst.percussionKeyNumber = notenum;
inst.secondVoiceDetune = static_cast<char>(static_cast<int>(ins.finetune) - 128);
- if((ins.flags & FL_DOUBLE_VOICE) != 0)
- {
- tmp2.pseudo4op = true;
- // Simulate behavior of DMX second voice detune
- tmp2.voice2_fine_tune = (double)((ins.finetune >> 1) - 64) / 32.0;
- }
-
db.addInstrument(bnk, patchId, inst, ops, fn);
/*const Doom_OPL2instrument& A = ins.patchdata[0];
diff --git a/utils/gen_adldata/file_formats/load_tmb.h b/utils/gen_adldata/file_formats/load_tmb.h
index 76478d1..d6fa588 100644
--- a/utils/gen_adldata/file_formats/load_tmb.h
+++ b/utils/gen_adldata/file_formats/load_tmb.h
@@ -41,7 +41,7 @@ bool BankFormats::LoadTMB(BanksDump &db, const char *fn, unsigned bank, const st
BanksDump::InstrumentEntry inst;
BanksDump::Operator ops[5];
- insdata tmp;
+ InstBuffer tmp;
tmp.data[0] = data[offset + 0];
tmp.data[1] = data[offset + 1];
@@ -54,21 +54,11 @@ bool BankFormats::LoadTMB(BanksDump &db, const char *fn, unsigned bank, const st
tmp.data[8] = data[offset + 2];
tmp.data[9] = data[offset + 3];
tmp.data[10] = data[offset + 10];
- tmp.finetune = 0;
- tmp.diff = false;
-
- struct ins tmp2;
- tmp2.notenum = data[offset + 11];
- tmp2.pseudo4op = false;
- tmp2.real4op = false;
- tmp2.voice2_fine_tune = 0.0;
- tmp2.midi_velocity_offset = (int8_t)data[offset + 12];
- tmp2.rhythmModeDrum = 0;
inst.percussionKeyNumber = data[offset + 11];
inst.midiVelocityOffset = (int8_t)data[offset + 12];
inst.fbConn = data[offset + 10];
- db.toOps(tmp, ops, 0);
+ db.toOps(tmp.d, ops, 0);
std::string name;
if(midi_index >= 0) name = std::string(1, '\377') + MidiInsName[midi_index];
diff --git a/utils/gen_adldata/file_formats/load_wopl.h b/utils/gen_adldata/file_formats/load_wopl.h
index 1d24dc6..6705bd9 100644
--- a/utils/gen_adldata/file_formats/load_wopl.h
+++ b/utils/gen_adldata/file_formats/load_wopl.h
@@ -128,7 +128,7 @@ bool BankFormats::LoadWopl(BanksDump &db, const char *fn, unsigned bank, const s
{
uint32_t offset = bank_offset + uint32_t(i * insSize);
std::string name;
- insdata tmp[2];
+ InstBuffer tmp[2];
BanksDump::InstrumentEntry inst;
BanksDump::Operator ops[5];
@@ -151,53 +151,40 @@ bool BankFormats::LoadWopl(BanksDump &db, const char *fn, unsigned bank, const s
8 Systain and Release register data
9 Wave form
*/
- tmp[0].data[0] = data[offset + 42 + 5];//AMVIB op1
- tmp[0].data[1] = data[offset + 42 + 0];//AMVIB op2
- tmp[0].data[2] = data[offset + 42 + 7];//AtDec op1
- tmp[0].data[3] = data[offset + 42 + 2];//AtDec op2
- tmp[0].data[4] = data[offset + 42 + 8];//SusRel op1
- tmp[0].data[5] = data[offset + 42 + 3];//SusRel op2
- tmp[0].data[6] = data[offset + 42 + 9];//Wave op1
- tmp[0].data[7] = data[offset + 42 + 4];//Wave op2
- tmp[0].data[8] = data[offset + 42 + 6];//KSL op1
- tmp[0].data[9] = data[offset + 42 + 1];//KSL op2
- tmp[0].data[10] = data[offset + 40]; //FeedBack/Connection
-
- tmp[1].data[0] = data[offset + 52 + 5];
- tmp[1].data[1] = data[offset + 52 + 0];
- tmp[1].data[2] = data[offset + 52 + 7];
- tmp[1].data[3] = data[offset + 52 + 2];
- tmp[1].data[4] = data[offset + 52 + 8];
- tmp[1].data[5] = data[offset + 52 + 3];
- tmp[1].data[6] = data[offset + 52 + 9];
- tmp[1].data[7] = data[offset + 52 + 4];
- tmp[1].data[8] = data[offset + 52 + 6];
- tmp[1].data[9] = data[offset + 52 + 1];
- tmp[1].data[10] = data[offset + 41];
+ tmp[0].d.op1_amvib = data[offset + 42 + 5];//AMVIB op1
+ tmp[0].d.op2_amvib = data[offset + 42 + 0];//AMVIB op2
+ tmp[0].d.op1_atdec = data[offset + 42 + 7];//AtDec op1
+ tmp[0].d.op2_atdec = data[offset + 42 + 2];//AtDec op2
+ tmp[0].d.op1_susrel = data[offset + 42 + 8];//SusRel op1
+ tmp[0].d.op2_susrel = data[offset + 42 + 3];//SusRel op2
+ tmp[0].d.op1_wave = data[offset + 42 + 9];//Wave op1
+ tmp[0].d.op2_wave = data[offset + 42 + 4];//Wave op2
+ tmp[0].d.op1_ksltl = data[offset + 42 + 6];//KSL op1
+ tmp[0].d.op2_ksltl = data[offset + 42 + 1];//KSL op2
+ tmp[0].d.fbconn = data[offset + 40]; //FeedBack/Connection
+
+ tmp[1].d.op1_amvib = data[offset + 52 + 5];
+ tmp[1].d.op2_amvib = data[offset + 52 + 0];
+ tmp[1].d.op1_atdec = data[offset + 52 + 7];
+ tmp[1].d.op2_atdec = data[offset + 52 + 2];
+ tmp[1].d.op1_susrel = data[offset + 52 + 8];
+ tmp[1].d.op2_susrel = data[offset + 52 + 3];
+ tmp[1].d.op1_wave = data[offset + 52 + 9];
+ tmp[1].d.op2_wave = data[offset + 52 + 4];
+ tmp[1].d.op1_ksltl = data[offset + 52 + 6];
+ tmp[1].d.op2_ksltl = data[offset + 52 + 1];
+ tmp[1].d.fbconn = data[offset + 41];
/*
* We will don't read two millisecond delays on tail of instrument
* as there are will be re-calculated by measurer here.
* Those fields are made for hot-loading while runtime, but not
* for generation of embedded banks database.
*/
- db.toOps(tmp[0], ops, 0);
- db.toOps(tmp[1], ops, 2);
+ db.toOps(tmp[0].d, ops, 0);
+ db.toOps(tmp[1].d, ops, 2);
-
- tmp[0].finetune = int8_t(toSint16BE((const uint8_t *)data.data() + offset + 32));
- tmp[1].finetune = int8_t(toSint16BE((const uint8_t *)data.data() + offset + 34));
uint8_t flags = data[offset + 39];
- struct ins tmp2;
- tmp2.notenum = is_percussion ? data[offset + 38] : 0;
- bool real4op = (flags & (uint8_t)WOPL_Flags::Mode_4op) != 0;
- tmp2.pseudo4op = (flags & (uint8_t)WOPL_Flags::Mode_DoubleVoice) != 0;
- tmp2.real4op = real4op && !tmp2.pseudo4op;
- tmp2.voice2_fine_tune = 0;
- tmp2.midi_velocity_offset = (int8_t)data[offset + 36];
- tmp2.rhythmModeDrum = (flags & (uint8_t)WOPL_Flags::WOPL_RhythmModeMask);
- tmp[0].diff = false;
- tmp[1].diff = real4op && !tmp2.pseudo4op;
//----------------
inst.instFlags = flags;
inst.percussionKeyNumber = is_percussion ? data[offset + 38] : 0;
@@ -214,13 +201,6 @@ bool BankFormats::LoadWopl(BanksDump &db, const char *fn, unsigned bank, const s
}
//----------------
- int8_t fine_tune = (int8_t)data[offset + 37];
- if(fine_tune != 0)
- {
- // Simulate behavior of DMX second voice detune
- tmp2.voice2_fine_tune = (double)((((int)fine_tune + 128) >> 1) - 64) / 32.0;
- }
-
uint32_t gmno = is_percussion ? i + 128 : i;
if(is_percussion)
diff --git a/utils/gen_adldata/gen_adldata.cc b/utils/gen_adldata/gen_adldata.cc
index b67e53b..fe369d9 100644
--- a/utils/gen_adldata/gen_adldata.cc
+++ b/utils/gen_adldata/gen_adldata.cc
@@ -213,7 +213,6 @@ int main(int argc, char**argv)
{
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();
diff --git a/utils/gen_adldata/measurer.h b/utils/gen_adldata/measurer.h
index 5a6acd1..ca05532 100644
--- a/utils/gen_adldata/measurer.h
+++ b/utils/gen_adldata/measurer.h
@@ -56,14 +56,12 @@ private:
struct MeasureThreaded
{
typedef std::array<int_fast32_t, 10> OperatorsKey;
- typedef std::map<ins, DurationInfo> DurationInfoCache;
typedef std::map<OperatorsKey, DurationInfo> DurationInfoCacheX;
MeasureThreaded();
Semaphore m_semaphore;
std::mutex m_durationInfo_mx;
- DurationInfoCache m_durationInfo;
DurationInfoCacheX m_durationInfoX;
std::atomic_bool m_delete_tail;
size_t m_total = 0;
@@ -84,7 +82,6 @@ struct MeasureThreaded
m_work.join();
}
MeasureThreaded *myself;
- std::map<ins, std::pair<size_t, std::set<std::string> > >::const_iterator i;
BanksDump *bd;
BanksDump::InstrumentEntry *bd_ins;
std::thread m_work;
diff --git a/utils/gen_adldata/progs_cache.cpp b/utils/gen_adldata/progs_cache.cpp
index 3ae5514..60518ba 100644
--- a/utils/gen_adldata/progs_cache.cpp
+++ b/utils/gen_adldata/progs_cache.cpp
@@ -12,31 +12,28 @@
#include "file_formats/load_ea.h"
-insdata MakeNoSoundIns()
+InstBuffer MakeNoSoundIns1()
{
- insdata nosnd;
+ InstBuffer nosnd;
uint8_t d[] = {0x00, 0x10, 0x07, 0x07, 0xF7, 0xF7, 0x00, 0x00, 0xFF, 0xFF, 0x00};
std::memcpy(nosnd.data, d, 11);
- nosnd.finetune = 0;
- nosnd.diff = false;
return nosnd;
}
-
-void BanksDump::toOps(const insdata &inData, BanksDump::Operator *outData, size_t begin)
+void BanksDump::toOps(const InstBuffer_t &inData, BanksDump::Operator *outData, size_t begin)
{
outData[begin + 0].d_E862 =
- uint_fast32_t(inData.data[6] << 24)
- + uint_fast32_t(inData.data[4] << 16)
- + uint_fast32_t(inData.data[2] << 8)
- + uint_fast32_t(inData.data[0] << 0);
+ uint_fast32_t(inData.op1_wave << 24)
+ + uint_fast32_t(inData.op1_susrel << 16)
+ + uint_fast32_t(inData.op1_atdec << 8)
+ + uint_fast32_t(inData.op1_amvib << 0);
outData[begin + 1].d_E862 =
- uint_fast32_t(inData.data[7] << 24)
- + uint_fast32_t(inData.data[5] << 16)
- + uint_fast32_t(inData.data[3] << 8)
- + uint_fast32_t(inData.data[1] << 0);
- outData[begin + 0].d_40 = inData.data[8];
- outData[begin + 1].d_40 = inData.data[9];
+ uint_fast32_t(inData.op2_wave << 24)
+ + uint_fast32_t(inData.op2_susrel << 16)
+ + uint_fast32_t(inData.op2_atdec << 8)
+ + uint_fast32_t(inData.op2_amvib << 0);
+ outData[begin + 0].d_40 = inData.op1_ksltl;
+ outData[begin + 1].d_40 = inData.op2_ksltl;
}
size_t BanksDump::initBank(size_t bankId, const std::string &title, uint_fast16_t bankSetup)
diff --git a/utils/gen_adldata/progs_cache.h b/utils/gen_adldata/progs_cache.h
index 2780345..6573307 100644
--- a/utils/gen_adldata/progs_cache.h
+++ b/utils/gen_adldata/progs_cache.h
@@ -1,3 +1,4 @@
+#pragma once
#ifndef PROGS_H
#define PROGS_H
@@ -17,45 +18,49 @@
#include <cassert>
-struct insdata
+struct InstBuffer_t
{
- uint8_t data[11];
- int8_t finetune;
- bool diff;
- explicit insdata()
+ uint8_t op1_amvib; // 0
+ uint8_t op2_amvib; // 1
+ uint8_t op1_atdec; // 2
+ uint8_t op2_atdec; // 3
+ uint8_t op1_susrel; // 4
+ uint8_t op2_susrel; // 5
+ uint8_t op1_wave; // 6
+ uint8_t op2_wave; // 7
+ uint8_t op1_ksltl; // 8
+ uint8_t op2_ksltl; // 9
+ uint8_t fbconn; // 10
+
+ bool operator==(const InstBuffer_t &b) const
{
- std::memset(data, 0, 11);
- finetune = 0;
- diff = false;
+ return std::memcmp(this, &b, sizeof(InstBuffer_t)) == 0;
}
- insdata(const insdata &b)
- {
- std::memcpy(data, b.data, 11);
- finetune = b.finetune;
- diff = b.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
+
+ bool operator!=(const InstBuffer_t &b) const
{
return !operator==(b);
}
- bool operator<(const insdata &b) const
+
+ bool operator<(const InstBuffer_t &b) const
{
- int c = std::memcmp(data, b.data, 11);
+ int c = std::memcmp(this, &b, 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
+
+ bool operator>(const InstBuffer_t &b) const
{
return !operator<(b) && operator!=(b);
}
};
+union InstBuffer
+{
+ InstBuffer_t d;
+ uint8_t data[11];
+};
+
inline bool equal_approx(double const a, double const b)
{
int_fast64_t ai = static_cast<int_fast64_t>(a * 1000000.0);
@@ -63,78 +68,6 @@ inline bool equal_approx(double const a, double const b)
return ai == bi;
}
-struct ins
-{
- enum { Flag_Pseudo4op = 0x01, Flag_NoSound = 0x02, Flag_Real4op = 0x04 };
-
- enum { Flag_RM_BassDrum = 0x08, Flag_RM_Snare = 0x10, Flag_RM_TomTom = 0x18,
- Flag_RM_Cymbal = 0x20, Flag_RM_HiHat = 0x28, Mask_RhythmMode = 0x38 };
-
- size_t insno1, insno2;
- insdata instCache1, instCache2;
- unsigned char notenum;
- bool pseudo4op;
- bool real4op;
- uint32_t rhythmModeDrum;
- double voice2_fine_tune;
- int8_t midi_velocity_offset;
- explicit ins() :
- insno1(0),
- insno2(0),
- notenum(0),
- pseudo4op(false),
- real4op(false),
- rhythmModeDrum(false),
- voice2_fine_tune(0.0),
- midi_velocity_offset(0)
- {}
-
- ins(const ins &o) :
- insno1(o.insno1),
- insno2(o.insno2),
- instCache1(o.instCache1),
- instCache2(o.instCache2),
- notenum(o.notenum),
- pseudo4op(o.pseudo4op),
- real4op(o.real4op),
- rhythmModeDrum(o.rhythmModeDrum),
- voice2_fine_tune(o.voice2_fine_tune),
- midi_velocity_offset(o.midi_velocity_offset)
- {}
-
- bool operator==(const ins &b) const
- {
- return notenum == b.notenum
- && insno1 == b.insno1
- && insno2 == b.insno2
- && instCache1 == b.instCache2
- && instCache2 == b.instCache2
- && pseudo4op == b.pseudo4op
- && real4op == b.real4op
- && rhythmModeDrum == b.rhythmModeDrum
- && equal_approx(voice2_fine_tune, b.voice2_fine_tune)
- && midi_velocity_offset == b.midi_velocity_offset;
- }
- bool operator< (const ins &b) const
- {
- if(insno1 != b.insno1) return insno1 < b.insno1;
- if(insno2 != b.insno2) return insno2 < b.insno2;
- if(instCache1 != b.instCache1) return instCache1 < b.instCache1;
- if(instCache2 != b.instCache2) return instCache2 < b.instCache2;
- if(notenum != b.notenum) return notenum < b.notenum;
- if(pseudo4op != b.pseudo4op) return pseudo4op < b.pseudo4op;
- if(real4op != b.real4op) return real4op < b.real4op;
- if(rhythmModeDrum != b.rhythmModeDrum) return rhythmModeDrum < b.rhythmModeDrum;
- if(!equal_approx(voice2_fine_tune, b.voice2_fine_tune)) return voice2_fine_tune < b.voice2_fine_tune;
- if(midi_velocity_offset != b.midi_velocity_offset) return midi_velocity_offset < b.midi_velocity_offset;
- return 0;
- }
- bool operator!=(const ins &b) const
- {
- return !operator==(b);
- }
-};
-
enum VolumesModels
{
VOLUME_Generic,
@@ -144,7 +77,7 @@ enum VolumesModels
VOLUME_9X
};
-insdata MakeNoSoundIns();
+InstBuffer MakeNoSoundIns1();
@@ -360,7 +293,7 @@ struct BanksDump
std::vector<InstrumentEntry> instruments;
std::vector<Operator> operators;
- static void toOps(const insdata &inData, Operator *outData, size_t begin = 0);
+ static void toOps(const InstBuffer_t &inData, Operator *outData, size_t begin = 0);
//! WIP
static bool isSilent(const BanksDump &db, const BanksDump::InstrumentEntry &ins, bool moreInfo = false);
static bool isSilent(const Operator *ops, uint_fast16_t fbConn, size_t countOps = 2, bool pseudo4op = false, bool moreInfo = false);