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
Conversation
@@ -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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Nice addition! |
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.
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.
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.
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).