Skip to content

Commit

Permalink
Fix: EDx has complicated trigger rules.
Browse files Browse the repository at this point in the history
Thanks @DanielOaks for noticing the issue.
  • Loading branch information
Artefact2 committed Aug 18, 2015
1 parent 33b8015 commit ecbbd32
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -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.
Expand Down
22 changes: 20 additions & 2 deletions src/play.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions src/xm_internal.h
Expand Up @@ -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;
Expand Down
File renamed without changes.
Binary file added tests/note-delay-retrig.xm
Binary file not shown.

0 comments on commit ecbbd32

Please sign in to comment.