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

[Bug] Psirius Memories of Time differs between OMPT and libxmp #588

Open
knight-ryu12 opened this issue Jun 9, 2022 · 8 comments
Open

Comments

@knight-ryu12
Copy link

knight-ryu12 commented Jun 9, 2022

This have playback issues between OMPT and Libxmp with weird artifact plays on Ord 1 on libxmp, where OpenMPT doesn't.

Modarchive

@sezero
Copy link
Collaborator

sezero commented Jun 9, 2022

@AliceLR ?

@sezero
Copy link
Collaborator

sezero commented Jun 13, 2022

Is Alice unwell?

@knight-ryu12
Copy link
Author

I wonder as well...

@AliceLR
Copy link
Contributor

AliceLR commented Jul 15, 2022

Is the issue specifically in channels 21 and 22, i.e. does this command produce all of the affected notes?

xmp psirius_-_memories_of_time.xm -s 1 -M 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,22,23,24,25,26,27,28,29,30,31

This is the only problem I've heard so far. The affected instrument has some very weird sample loop parameters that OpenMPT and libxmp truncate differently. i am dumb it's just stereo

@knight-ryu12
Copy link
Author

Yeah it does; some high-pitched (wrong instrument?), and yes. probably issue with older OMPT (Since this module indicate itself as saved with OMPT)

@AliceLR
Copy link
Contributor

AliceLR commented Jul 16, 2022

Does it sound alright with this patch? This doesn't fix the fundamental issue (missing stereo sample support), just the junk sample data from delta decoding the right channel.

diff --git a/src/loaders/xm.h b/src/loaders/xm.h
index 6a863183..4d41486c 100644
--- a/src/loaders/xm.h
+++ b/src/loaders/xm.h
@@ -14,6 +14,7 @@
 #define XM_LOOP_FORWARD 1
 #define XM_LOOP_PINGPONG 2
 #define XM_SAMPLE_16BIT 0x10
+#define XM_SAMPLE_STEREO 0x20
 #define XM_ENVELOPE_ON 0x01
 #define XM_ENVELOPE_SUSTAIN 0x02
 #define XM_ENVELOPE_LOOP 0x04
diff --git a/src/loaders/xm_load.c b/src/loaders/xm_load.c
index 9919ad82..282cbe28 100644
--- a/src/loaders/xm_load.c
+++ b/src/loaders/xm_load.c
@@ -683,6 +683,12 @@ static int load_instruments(struct module_data *m, int version, HIO_HANDLE *f)
 				xxs->lps >>= 1;
 				xxs->lpe >>= 1;
 			}
+			if (xsh[j].type & XM_SAMPLE_STEREO) {
+				/* xxs->flg |= XMP_SAMPLE_STEREO; */
+				xxs->len >>= 1;
+				xxs->lps >>= 1;
+				xxs->lpe >>= 1;
+			}
 
 			xxs->flg |= xsh[j].type & XM_LOOP_FORWARD ? XMP_SAMPLE_LOOP : 0;
 			xxs->flg |= xsh[j].type & XM_LOOP_PINGPONG ? XMP_SAMPLE_LOOP | XMP_SAMPLE_LOOP_BIDIR : 0;
@@ -736,6 +742,11 @@ static int load_instruments(struct module_data *m, int version, HIO_HANDLE *f)
 				} else {
 					total_sample_size += xsh[j].length;
 				}
+
+				/* TODO: workaround for missing stereo sample support */
+				if (xsh[j].type & XM_SAMPLE_STEREO) {
+					hio_seek(f, xsh[j].length >> 1, SEEK_CUR);
+				}
 			}
 		}
 

@knight-ryu12
Copy link
Author

Will check in few.

@knight-ryu12
Copy link
Author

Just tested; It works fine.

@AliceLR AliceLR added this to the 4.7.0 milestone Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants