mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-26 06:25:16 +00:00
new ins format, part 5
This commit is contained in:
parent
38bb36363d
commit
a7b139cd00
3 changed files with 50 additions and 8 deletions
|
@ -6,6 +6,8 @@ the aim of this new format is to greatly reduce the size of a resulting instrume
|
|||
|
||||
# header
|
||||
|
||||
.fui files use the following header:
|
||||
|
||||
```
|
||||
size | description
|
||||
-----|------------------------------------
|
||||
|
@ -15,6 +17,18 @@ size | description
|
|||
??? | 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:
|
||||
|
||||
```
|
||||
|
@ -51,6 +65,7 @@ the following feature codes are recognized:
|
|||
- `EN`: end of features
|
||||
- if you find this feature code, stop reading the instrument.
|
||||
- it will usually appear only when there sample/wave lists.
|
||||
- instruments in a .fur shall end with this feature code.
|
||||
|
||||
# instrument name (NA)
|
||||
|
||||
|
|
|
@ -1720,17 +1720,16 @@ void DivInstrument::putInsData(SafeWriter* w) {
|
|||
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) \
|
||||
for (int macroValPos=0; macroValPos<y; macroValPos++) x[macroValPos]=reader.readI();
|
||||
|
||||
DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) {
|
||||
char magic[4];
|
||||
reader.read(magic,4);
|
||||
if (memcmp(magic,"INST",4)!=0) {
|
||||
logE("invalid instrument header!");
|
||||
return DIV_DATA_INVALID_HEADER;
|
||||
}
|
||||
reader.readI();
|
||||
DivDataErrors DivInstrument::readInsDataOld(SafeReader &reader, short version) {
|
||||
reader.readI(); // length. ignored.
|
||||
|
||||
reader.readS(); // format version. ignored.
|
||||
type=(DivInstrumentType)reader.readC();
|
||||
|
@ -2438,6 +2437,31 @@ DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) {
|
|||
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) {
|
||||
SafeWriter* w=new SafeWriter();
|
||||
w->init();
|
||||
|
|
|
@ -661,6 +661,9 @@ struct DivInstrument {
|
|||
void writeFeatureSU(SafeWriter* w);
|
||||
void writeFeatureES(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.
|
||||
|
|
Loading…
Reference in a new issue