Amiga: take loop pos into account

This commit is contained in:
tildearrow 2022-01-15 18:03:37 -05:00
parent 785f7e4d40
commit 31f8378cef
3 changed files with 19 additions and 2 deletions

View File

@ -1314,7 +1314,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
// reserved
for (int j=0; j<3; j++) reader.readC();
if (ds.version>=18) {
if (ds.version>=19) {
sample->loopStart=reader.readI();
} else {
reader.readI();

View File

@ -20,7 +20,11 @@ void DivPlatformAmiga::acquire(short* bufL, short* bufR, size_t start, size_t le
chan[i].audDat=s->rendData[chan[i].audPos++]>>8;
}
if (chan[i].audPos>=s->rendLength) {
chan[i].sample=-1;
if (s->loopStart>=0 && s->loopStart<=(int)s->rendLength) {
chan[i].audPos=s->loopStart;
} else {
chan[i].sample=-1;
}
}
chan[i].audSub+=chan[i].freq;
}

View File

@ -1214,6 +1214,19 @@ void FurnaceGUI::drawSampleEdit() {
if (sample->rate>32000) sample->rate=32000;
}
ImGui::Text("effective rate: %dHz",e->getEffectiveSampleRate(sample->rate));
bool doLoop=(sample->loopStart>=0);
if (ImGui::Checkbox("Loop",&doLoop)) {
if (doLoop) {
sample->loopStart=0;
} else {
sample->loopStart=-1;
}
}
if (doLoop) if (ImGui::SliderInt("##LoopPosition",&sample->loopStart,0,sample->length-1)) {
if (sample->loopStart<0 || sample->loopStart>=sample->length) {
sample->loopStart=0;
}
}
if (ImGui::SliderScalar("Volume",ImGuiDataType_S8,&sample->vol,&_ZERO,&_ONE_HUNDRED,fmt::sprintf("%d%%%%",sample->vol*2).c_str())) {
if (sample->vol<0) sample->vol=0;
if (sample->vol>100) sample->vol=100;