samples may have loop points

This commit is contained in:
tildearrow 2022-01-15 17:54:21 -05:00
parent 755042a8fe
commit 785f7e4d40
4 changed files with 16 additions and 6 deletions

View file

@ -210,7 +210,9 @@ size | description
2 | volume 2 | volume
2 | pitch 2 | pitch
1 | depth 1 | depth
7 | reserved 3 | reserved
4 | loop point (>=19)
| - -1 means no loop
2?? | sample data (always 16-bit) 2?? | sample data (always 16-bit)
# pattern # pattern

View file

@ -1312,7 +1312,13 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
sample->depth=reader.readC(); sample->depth=reader.readC();
// reserved // reserved
for (int j=0; j<7; j++) reader.readC(); for (int j=0; j<3; j++) reader.readC();
if (ds.version>=18) {
sample->loopStart=reader.readI();
} else {
reader.readI();
}
sample->data=new short[sample->length]; sample->data=new short[sample->length];
reader.read(sample->data,2*sample->length); reader.read(sample->data,2*sample->length);
@ -1777,9 +1783,10 @@ SafeWriter* DivEngine::saveFur() {
w->writeS(sample->vol); w->writeS(sample->vol);
w->writeS(sample->pitch); w->writeS(sample->pitch);
w->writeC(sample->depth); w->writeC(sample->depth);
for (int j=0; j<7; j++) { // reserved for (int j=0; j<3; j++) { // reserved
w->writeC(0); w->writeC(0);
} }
w->writeI(sample->loopStart);
w->write(sample->data,sample->length*2); w->write(sample->data,sample->length*2);
} }

View file

@ -9,8 +9,8 @@
#include <map> #include <map>
#include <queue> #include <queue>
#define DIV_VERSION "0.4pre2" #define DIV_VERSION "0.4pre3"
#define DIV_ENGINE_VERSION 18 #define DIV_ENGINE_VERSION 19
enum DivStatusView { enum DivStatusView {
DIV_STATUS_NOTHING=0, DIV_STATUS_NOTHING=0,

View file

@ -2,7 +2,7 @@
struct DivSample { struct DivSample {
String name; String name;
int length, rate; int length, rate, loopStart;
signed char vol, pitch; signed char vol, pitch;
unsigned char depth; unsigned char depth;
short* data; short* data;
@ -15,6 +15,7 @@ struct DivSample {
name(""), name(""),
length(0), length(0),
rate(32000), rate(32000),
loopStart(-1),
vol(0), vol(0),
pitch(0), pitch(0),
depth(16), depth(16),