1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#ifndef LOAD_BISQWIT_H
#define LOAD_BISQWIT_H
#include "../progs_cache.h"
#include "../midi_inst_list.h"
bool BankFormats::LoadBisqwit(BanksDump &db, const char *fn, unsigned bank, const std::string &bankTitle, const char *prefix)
{
#ifdef HARD_BANKS
writeIni("Bisqwit", fn, prefix, bank, INI_Both);
#endif
FILE *fp = std::fopen(fn, "rb");
if(!fp)
return false;
size_t bankDb = db.initBank(bank, bankTitle, BanksDump::BankEntry::SETUP_Generic);
BanksDump::MidiBank bnkMelodique;
BanksDump::MidiBank bnkPercussion;
for(uint32_t a = 0, patchId = 0; a < 256; ++a, patchId++)
{
//unsigned offset = a * 25;
uint32_t gmno = a;
bool isPercussion = gmno >= 128;
int32_t midi_index = gmno < 128 ? int32_t(gmno)
: gmno < 128 + 35 ? -1
: gmno < 128 + 88 ? int32_t(gmno - 35)
: -1;
if(patchId == 128)
patchId = 0;
BanksDump::MidiBank &bnk = isPercussion ? bnkPercussion : bnkMelodique;
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;
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);
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])
{
inst.instFlags |= BanksDump::InstrumentEntry::WOPL_Ins_4op;
db.toOps(tmp[1], 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;
db.addInstrument(bnk, patchId, inst, ops);
}
std::fclose(fp);
db.addMidiBank(bankDb, false, bnkMelodique);
db.addMidiBank(bankDb, true, bnkPercussion);
AdlBankSetup setup;
setup.volumeModel = VOLUME_Generic;
setup.deepTremolo = true;
setup.deepVibrato = true;
setup.scaleModulators = false;
SetBankSetup(bank, setup);
return true;
}
#endif // LOAD_BISQWIT_H
|