milkytracker / MilkyTracker

An FT2 compatible music tracker
http://milkytracker.github.io/
Other
1.69k stars 162 forks source link

8-bit samples not saved correctly #218

Closed JPDevAcc closed 3 years ago

JPDevAcc commented 3 years ago

Looks like 8-bit samples are inverted when they're saved (and loaded) in WAV format

I think the culprit is https://github.com/milkytracker/MilkyTracker/blob/6f95303feaf1801e9a814dfc143e2cb8f6bbff3e/src/milkyplay/SampleLoaderWAV.cpp#L692

*dstPtr++ = ((mp_sbyte)smp->getSampleValue(i))^127; <-- I think this should be a 128?

Edit: This off-by-one XORing appears in other places too such as: https://github.com/milkytracker/MilkyTracker/blob/6f95303feaf1801e9a814dfc143e2cb8f6bbff3e/src/milkyplay/XModule.cpp#L1542 https://github.com/milkytracker/MilkyTracker/blob/6f95303feaf1801e9a814dfc143e2cb8f6bbff3e/src/milkyplay/XModule.cpp#L1522