From ecbbd32426202c6f76855b1a8538b15b7d0febbd Mon Sep 17 00:00:00 2001 From: Artefact2 Date: Tue, 18 Aug 2015 12:51:44 +0200 Subject: [PATCH] Fix: EDx has complicated trigger rules. Thanks @DanielOaks for noticing the issue. --- README.md | 3 ++- src/play.c | 22 ++++++++++++++++-- src/xm_internal.h | 1 + ...host-note-delay.xm => note-delay-ghost.xm} | Bin tests/note-delay-retrig.xm | Bin 0 -> 40927 bytes 5 files changed, 23 insertions(+), 3 deletions(-) rename tests/{ghost-note-delay.xm => note-delay-ghost.xm} (100%) create mode 100644 tests/note-delay-retrig.xm diff --git a/README.md b/README.md index 94de324..bbb232c 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,8 @@ they are supposed to test) is in the table below. -------------------------------+----------------+------------------------+------------------------------------------------ amiga.xm | FAIL | MilkyTracker, xmp | Should sound identical. finetune.xm | PASS | MilkyTracker | Left and right channels should sound identical. -ghost-note-delay.xm | FAIL | MilkyTracker | Should sound identical. +note-delay-ghost.xm | PASS | MilkyTracker, FT2 | Should sound identical. +note-delay-retrig.xm | PASS | MilkyTracker | Should sound identical. pattern-loop-quirk.xm | PASS | MilkyTracker | Should play the same notes at the same time. ramping.xm | PASS | MilkyTracker | If XM_RAMPING is ON, no loud clicks should be heard. ramping2.xm | PASS | MilkyTracker | If XM_RAMPING is ON, no loud clicks should be heard. diff --git a/src/play.c b/src/play.c index 591e2d8..11edd05 100644 --- a/src/play.c +++ b/src/play.c @@ -446,7 +446,7 @@ static void xm_handle_note_and_instrument(xm_context_t* ctx, xm_channel_context_ ch->frame_count = 0; #endif ch->sample = instr->samples + instr->sample_of_notes[s->note - 1]; - ch->note = s->note + ch->sample->relative_note + ch->orig_note = ch->note = s->note + ch->sample->relative_note + ch->sample->finetune / 128.f - 1.f; if(s->instrument > 0) { xm_trigger_note(ctx, ch, 0); @@ -672,7 +672,25 @@ static void xm_handle_note_and_instrument(xm_context_t* ctx, xm_channel_context_ break; case 0xD: /* EDy: Note delay */ - /* Already taken care of */ + /* XXX: figure this out better. EDx triggers + * the note even when there no note and no + * instrument. But ED0 acts like like a ghost + * note, EDx (x ≠ 0) does not. */ + if(s->note == 0 && s->instrument == 0) { + unsigned int flags = XM_TRIGGER_KEEP_VOLUME; + + if(ch->current->effect_param & 0x0F) { + ch->note = ch->orig_note; + xm_trigger_note(ctx, ch, flags); + } else { + xm_trigger_note( + ctx, ch, + flags + | XM_TRIGGER_KEEP_PERIOD + | XM_TRIGGER_KEEP_SAMPLE_POSITION + ); + } + } break; case 0xE: /* EEy: Pattern delay */ diff --git a/src/xm_internal.h b/src/xm_internal.h index 7f8042d..d8f6f2b 100644 --- a/src/xm_internal.h +++ b/src/xm_internal.h @@ -154,6 +154,7 @@ struct xm_sample_s { struct xm_channel_context_s { float note; + float orig_note; /* The original note before effect modifications, as read in the pattern. */ xm_instrument_t* instrument; /* Could be NULL */ xm_sample_t* sample; /* Could be NULL */ xm_pattern_slot_t* current; diff --git a/tests/ghost-note-delay.xm b/tests/note-delay-ghost.xm similarity index 100% rename from tests/ghost-note-delay.xm rename to tests/note-delay-ghost.xm diff --git a/tests/note-delay-retrig.xm b/tests/note-delay-retrig.xm new file mode 100644 index 0000000000000000000000000000000000000000..6c15fb912cb7f950276c94c3c760c2d4369adfb9 GIT binary patch literal 40927 zcmeI3zjD(+5Qk3&251-xDhkGBDkhYqN<*0r9w5OkGVz3&jQLlQmwL)#Hx))^hT&h8|YSJ#;6d7sbh=#iieVXlRDH?(C%k_G<;~ z|8MS$RCwe2RqnNKh1+Z2k$LpcJ-$)Iv8x_^x6!DsFJYO>FYV|3{_fn%ug?9vS0>)L zxP0c`oX=0^v+3md$Kwy}=P(L^;Sumx>H2xC=?bwsk^BrJ+#euh}LSNwR(H$)KagfueG$)lUI#iHF>qA zeXZQ;7NA;)YX5sB5Mj-cyK3qe!9Xe)5Wz%6s*})!80AV9yDBNU-`9#DmNcm~HY5z% zW-|zY-!`s7)zgeQ5JQwbI-Pxk|u>RbbGxfRcIPjtX!SNLWpRo zgSCv1Xj(H)yH0BdBI1oAYree#?k+TJg=AnTI8YCJ@ z)eXxFA$KJAhqv+T>0wUYR-Lib+=-4|Z zBHG8^qIi?w*gHWYIe@(-=_avpcY;K80DFt#je}$Fn22m2d&}~TqGRs}h-?>k%kqt* tWAB)VXdiov;!T2M?*xhD0QQ!oo5sf8DHFjF>@5g44UM}~CXyrje*k+ak`n*` literal 0 HcmV?d00001