From dbcd7f31a879334471e4e02e473921a0ddd6120a Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 17 Nov 2022 19:07:40 -0500 Subject: [PATCH] prepare for implementing new ins format --- papers/newIns.md | 60 +++++++++++++++++++++++++++++++++++++++ src/engine/instrument.cpp | 12 ++++++++ src/engine/instrument.h | 6 ++++ 3 files changed, 78 insertions(+) diff --git a/papers/newIns.md b/papers/newIns.md index 3b7c1991c..d0967205b 100644 --- a/papers/newIns.md +++ b/papers/newIns.md @@ -27,6 +27,7 @@ size | description the following feature codes are recognized: +- `NA`: instrument name - `FM`: FM ins data - `MA`: macro data - `64`: C64 ins data @@ -76,3 +77,62 @@ size | description 1 | | S L | R R | 1 | | DVB | SSG | 1 | | DAM | W S | +``` + +# macro data (MA) + +``` +size | description +-----|------------------------------------ + 2 | length of macro header + ??? | data... +``` + +each macro is represented like this: + +``` +size | description +-----|------------------------------------ + 1 | macro code + | - 0: vol + | - 1: arp + | - 2: duty + | - 3: wave + | - 4: pitch + | - 5: ex1 + | - 6: ex2 + | - 7: ex3 + | - 8: alg + | - 9: fb + | - 10: fms + | - 11: ams + | - 12: panL + | - 13: panR + | - 14: phaseReset + | - 15: ex4 + | - 16: ex5 + | - 17: ex6 + | - 17: ex7 + | - 18: ex8 + | - 255: stop reading and move on + 1 | macro length + 1 | macro loop + 1 | macro release + 1 | macro mode + 1 | macro open/type/word size + | - bit 6-7: word size + | - 0: 8-bit unsigned + | - 1: 8-bit signed + | - 2: 16-bit signed + | - 3: 32-bit signed + | - bit 1-2: type + | - 0: normal + | - 1: ADSR + | - 2: LFO + | - bit 0: open + 1 | macro delay + 1 | macro speed + ??? | macro data + | - length: macro length × word sizs +``` + diff --git a/src/engine/instrument.cpp b/src/engine/instrument.cpp index 2b7112383..6a687627b 100644 --- a/src/engine/instrument.cpp +++ b/src/engine/instrument.cpp @@ -23,6 +23,18 @@ #include "../ta-log.h" #include "../fileutils.h" +void DivInstrument::putInsData2(SafeWriter* w, bool fui) { + size_t blockStartSeek, blockEndSeek; + + if (fui) { + w->write("FINS",4); + } else { + w->write("INST",4); + blockStartSeek=w->tell(); + w->writeI(0); + } +} + void DivInstrument::putInsData(SafeWriter* w) { size_t blockStartSeek, blockEndSeek; diff --git a/src/engine/instrument.h b/src/engine/instrument.h index 7afa9f93a..0f434181c 100644 --- a/src/engine/instrument.h +++ b/src/engine/instrument.h @@ -571,6 +571,12 @@ struct DivInstrument { */ void putInsData(SafeWriter* w); + /** + * save the instrument to a SafeWriter using new format. + * @param w the SafeWriter in question. + */ + void putInsData2(SafeWriter* w, bool fui=false); + /** * read instrument data in .fui format. * @param reader the reader.