load .brr loop position if present

This commit is contained in:
tildearrow 2022-11-01 02:47:27 -05:00
parent 4508fea6e0
commit 4531e9fc9c
2 changed files with 15 additions and 2 deletions

View File

@ -3067,8 +3067,20 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
if (extS==".brr") {
dataBuf=sample->dataBRR;
if ((len%9)==2) {
// ignore loop position
fseek(f,2,SEEK_SET);
// read loop position
unsigned short loopPos=0;
logD("BRR file has loop position");
if (fread(&loopPos,1,2,f)!=2) {
logW("could not read loop position! %s",strerror(errno));
} else {
#ifdef TA_BIG_ENDIAN
loopPos=(loopPos>>8)|(loopPos<<8);
#endif
sample->loopStart=16*(loopPos/9);
sample->loopEnd=sample->samples;
sample->loop=true;
sample->loopMode=DIV_SAMPLE_LOOP_FORWARD;
}
len-=2;
if (len==0) {
fclose(f);

View File

@ -369,6 +369,7 @@ void FurnaceGUI::drawPiano() {
pianoOptions=!pianoOptions;
}
// TODO: wave and sample preview
// first check released keys
for (int i=0; i<180; i++) {
int note=i-60;