Skip to content

Commit

Permalink
Fix IT sample global volume and sample vibrato.
Browse files Browse the repository at this point in the history
* IT sample global volume was being ignored in sample mode due to
  QUIRK_INSVOL not being enabled. QUIRK_INSVOL is now unconditionally
  enabled for IT modules.
* IT sample global volume was being ignored in instrument mode for
  IT 1.x modules due to QUIRK_INSVOL not being enabled for IT 1.x
  modules. QUIRK_INSVOL is now unconditionally enabled for IT modules.
* Fixed an incorrect bitshift on IT sample vibrato depth that resulted
  in IT sample vibrato being very weak.
* Sample vibrato rate is now rounded instead of truncated. The LFO
  period size should probably eventually be expanded instead.
  • Loading branch information
AliceLR committed Nov 11, 2020
1 parent b5d4239 commit c97020a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 3 additions & 6 deletions src/loaders/it_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ static int load_it_sample(struct module_data *m, int i, int start,

if (sample_mode) {
/* Create an instrument for each sample */
mod->xxi[i].vol = 64;
mod->xxi[i].sub[0].vol = ish.vol;
mod->xxi[i].sub[0].pan = 0x80;
mod->xxi[i].sub[0].sid = i;
Expand Down Expand Up @@ -782,7 +783,7 @@ static int load_it_sample(struct module_data *m, int i, int start,
sub->vol = ish.vol;
sub->gvl = ish.gvl;
sub->vra = ish.vis; /* sample to sub-instrument vibrato */
sub->vde = ish.vid >> 1;
sub->vde = ish.vid << 1;
sub->vwf = ish.vit;
sub->vsw = (0xff - ish.vir) >> 1;

Expand Down Expand Up @@ -1090,10 +1091,6 @@ static int it_load(struct module_data *m, HIO_HANDLE *f, const int start)
m->period_type = PERIOD_LINEAR;
}

if (!sample_mode && ifh.cmwt >= 0x200) {
m->quirk |= QUIRK_INSVOL;
}

for (i = 0; i < 64; i++) {
struct xmp_channel *xxc = &mod->xxc[i];

Expand Down Expand Up @@ -1328,7 +1325,7 @@ static int it_load(struct module_data *m, HIO_HANDLE *f, const int start)

/* Format quirks */

m->quirk |= QUIRKS_IT | QUIRK_ARPMEM;
m->quirk |= QUIRKS_IT | QUIRK_ARPMEM | QUIRK_INSVOL;

if (ifh.flags & IT_LINK_GXX) {
m->quirk |= QUIRK_PRENV;
Expand Down
5 changes: 4 additions & 1 deletion src/read_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@ static void set_effect_defaults(struct context_data *ctx, int note,
} */
#endif

/* TODO: should probably expand the LFO period size instead
* of reducing the vibrato rate precision here.
*/
libxmp_lfo_set_depth(&xc->insvib.lfo, sub->vde);
libxmp_lfo_set_rate(&xc->insvib.lfo, sub->vra >> 2);
libxmp_lfo_set_rate(&xc->insvib.lfo, (sub->vra + 2) >> 2);
libxmp_lfo_set_waveform(&xc->insvib.lfo, sub->vwf);
xc->insvib.sweep = sub->vsw;

Expand Down

0 comments on commit c97020a

Please sign in to comment.