new ins format, part 5
This commit is contained in:
parent
38bb36363d
commit
a7b139cd00
|
@ -6,6 +6,8 @@ the aim of this new format is to greatly reduce the size of a resulting instrume
|
||||||
|
|
||||||
# header
|
# header
|
||||||
|
|
||||||
|
.fui files use the following header:
|
||||||
|
|
||||||
```
|
```
|
||||||
size | description
|
size | description
|
||||||
-----|------------------------------------
|
-----|------------------------------------
|
||||||
|
@ -15,6 +17,18 @@ size | description
|
||||||
??? | features...
|
??? | features...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
instruments in a .fur file use the following header instead:
|
||||||
|
|
||||||
|
```
|
||||||
|
size | description
|
||||||
|
-----|------------------------------------
|
||||||
|
4 | "INS2" block ID
|
||||||
|
4 | size of this block
|
||||||
|
2 | format version
|
||||||
|
2 | instrument type
|
||||||
|
??? | features...
|
||||||
|
```
|
||||||
|
|
||||||
a feature uses the following format:
|
a feature uses the following format:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -51,6 +65,7 @@ the following feature codes are recognized:
|
||||||
- `EN`: end of features
|
- `EN`: end of features
|
||||||
- if you find this feature code, stop reading the instrument.
|
- if you find this feature code, stop reading the instrument.
|
||||||
- it will usually appear only when there sample/wave lists.
|
- it will usually appear only when there sample/wave lists.
|
||||||
|
- instruments in a .fur shall end with this feature code.
|
||||||
|
|
||||||
# instrument name (NA)
|
# instrument name (NA)
|
||||||
|
|
||||||
|
|
|
@ -1720,17 +1720,16 @@ void DivInstrument::putInsData(SafeWriter* w) {
|
||||||
w->seek(0,SEEK_END);
|
w->seek(0,SEEK_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DivDataErrors DivInstrument::readInsDataNew(SafeReader& reader, short version, bool fui) {
|
||||||
|
logE("new ins reading not implemented yet!");
|
||||||
|
return DIV_DATA_INVALID_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
#define READ_MACRO_VALS(x,y) \
|
#define READ_MACRO_VALS(x,y) \
|
||||||
for (int macroValPos=0; macroValPos<y; macroValPos++) x[macroValPos]=reader.readI();
|
for (int macroValPos=0; macroValPos<y; macroValPos++) x[macroValPos]=reader.readI();
|
||||||
|
|
||||||
DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) {
|
DivDataErrors DivInstrument::readInsDataOld(SafeReader &reader, short version) {
|
||||||
char magic[4];
|
reader.readI(); // length. ignored.
|
||||||
reader.read(magic,4);
|
|
||||||
if (memcmp(magic,"INST",4)!=0) {
|
|
||||||
logE("invalid instrument header!");
|
|
||||||
return DIV_DATA_INVALID_HEADER;
|
|
||||||
}
|
|
||||||
reader.readI();
|
|
||||||
|
|
||||||
reader.readS(); // format version. ignored.
|
reader.readS(); // format version. ignored.
|
||||||
type=(DivInstrumentType)reader.readC();
|
type=(DivInstrumentType)reader.readC();
|
||||||
|
@ -2438,6 +2437,31 @@ DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) {
|
||||||
return DIV_DATA_SUCCESS;
|
return DIV_DATA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) {
|
||||||
|
// 0: old (INST)
|
||||||
|
// 1: new (INS2, length)
|
||||||
|
// 2: new (FINS, no length)
|
||||||
|
int type=-1;
|
||||||
|
|
||||||
|
char magic[4];
|
||||||
|
reader.read(magic,4);
|
||||||
|
if (memcmp(magic,"INST",4)==0) {
|
||||||
|
type=0;
|
||||||
|
} else if (memcmp(magic,"INS2",4)==0) {
|
||||||
|
type=1;
|
||||||
|
} else if (memcmp(magic,"FINS",4)==0) {
|
||||||
|
type=2;
|
||||||
|
} else {
|
||||||
|
logE("invalid instrument header!");
|
||||||
|
return DIV_DATA_INVALID_HEADER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type==1 || type==2) {
|
||||||
|
return readInsDataNew(reader,version,type==2);
|
||||||
|
}
|
||||||
|
return readInsDataOld(reader,version);
|
||||||
|
}
|
||||||
|
|
||||||
bool DivInstrument::save(const char* path) {
|
bool DivInstrument::save(const char* path) {
|
||||||
SafeWriter* w=new SafeWriter();
|
SafeWriter* w=new SafeWriter();
|
||||||
w->init();
|
w->init();
|
||||||
|
|
|
@ -661,6 +661,9 @@ struct DivInstrument {
|
||||||
void writeFeatureSU(SafeWriter* w);
|
void writeFeatureSU(SafeWriter* w);
|
||||||
void writeFeatureES(SafeWriter* w);
|
void writeFeatureES(SafeWriter* w);
|
||||||
void writeFeatureX1(SafeWriter* w);
|
void writeFeatureX1(SafeWriter* w);
|
||||||
|
|
||||||
|
DivDataErrors readInsDataOld(SafeReader& reader, short version);
|
||||||
|
DivDataErrors readInsDataNew(SafeReader& reader, short version, bool fui);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* save the instrument to a SafeWriter.
|
* save the instrument to a SafeWriter.
|
||||||
|
|
Loading…
Reference in a new issue