Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix S3M ADPCM4 samples #163

Merged
merged 1 commit into from Oct 27, 2020
Merged

Fix S3M ADPCM4 samples #163

merged 1 commit into from Oct 27, 2020

Conversation

AliceLR
Copy link
Contributor

@AliceLR AliceLR commented Apr 4, 2020

This branch fixes playback of S3Ms containing ADPCM4 samples using the same method libmodplug uses to detect them.

Example S3M file that relies on ADPCM4 samples: mm2flash.s3m.zip (seems to be a resaved copy of this).

@@ -619,6 +620,11 @@ static int s3m_load(struct module_data *m, HIO_HANDLE * f, const int start)
xxs->flg |= XMP_SAMPLE_16BIT;
}

load_sample_flags = (sfh.ffi == 1) ? 0 : SAMPLE_FLAG_UNS;
if (sih.pack == 4) {
load_sample_flags = SAMPLE_FLAG_ADPCM;
Copy link
Contributor

@NoSuck NoSuck May 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to bitwise OR the assignment on line 625? The logic in libxmp_load_sample does not indicate the flags here are mutually exclusive--and if they were, this block should be refactored to prevent the redundant check/assignment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, nice catch. The reason I implemented it like this is that's how the copy of libmodplug 0.8.9.0 I used as a reference does it, but there's no guarantee that's correct. I'll look into it more...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: from what I can gather MOD Plugin is the source of ADPCM4 samples in S3Ms (and OpenMPT's handling of these attributes them to MOD Plugin), so libmodplug's behavior is probably correct. Probably also worth noting that in the same file I linked in the previous comment, the code for saving ADPCM4 samples similarly overrides the U8 flag.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you still need a confirmation: Yes, ModPlug ADPCM is exclusively 8-bit mono. It must not be combined with any other flags because it is neither defined how to handle stereo ADPCM samples, nor is there any other algorithm defined apart from 4-to-8-bit expansion.

@NoSuck
Copy link
Contributor

NoSuck commented May 3, 2020

Nice addition!

sezero pushed a commit to sezero/libxmp that referenced this pull request Oct 22, 2020
@sezero sezero merged commit f11ebc6 into libxmp:master Oct 27, 2020
@AliceLR AliceLR deleted the fix-s3m-adpcm branch November 12, 2020 04:59
AliceLR added a commit to AliceLR/libxmp that referenced this pull request Nov 26, 2020
Adds tests for:
* Fix S3M ADPCM4 samples. (libxmp#163, f11ebc6)
* Fix OctaMED 'tracker compatibility' tempos. (libxmp#177, 29b5d06)
* Fix MEDs with pattern lengths >256, MED instrument corruption. (libxmp#185, a07c760)
* Fix Schism Tracker version date calculation. (libxmp#190, 7e20a82)

Also reformats the test-dev Makefile.in loader tests list, which
was starting to get messy.
AliceLR added a commit to AliceLR/libxmp that referenced this pull request Nov 26, 2020
Adds tests for:
* Fix S3M ADPCM4 samples. (libxmp#163, f11ebc6)
* Fix OctaMED 'tracker compatibility' tempos. (libxmp#177, 29b5d06)
* Fix MEDs with pattern lengths >256, MED instrument corruption. (libxmp#185, a07c760)
* Fix Schism Tracker version date calculation. (libxmp#190, 7e20a82)

Also reformats the test-dev Makefile.in loader tests list, which
was starting to get messy.
AliceLR added a commit to AliceLR/libxmp that referenced this pull request Nov 26, 2020
Adds tests for:
* Fix S3M ADPCM4 samples. (libxmp#163, f11ebc6)
* Fix OctaMED 'tracker compatibility' tempos. (libxmp#177, 29b5d06)
* Fix MEDs with pattern lengths >256, MED instrument corruption. (libxmp#185, a07c760)
* Fix Schism Tracker version date calculation. (libxmp#190, 7e20a82)

Also reformats the test-dev Makefile.in loader tests list, which
was starting to get messy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants