Mod Archive Forums Mod Archive Forums
Advanced search  

News:

Please note: Your main modarchive.org account will not work here, you must create a forum account to post on the forums.

Pages: [1]   Go Down

Author Topic: Loading IT samples... the correct way  (Read 1939 times)

0 Members and 1 Guest are viewing this topic.

Saga Musix

  • TMA Moderator
  • Too much pie
  • *****
  • Offline Offline
  • Posts: 2356
  • I love OpenMPT! And Modules! And TMA! And Pie! :>
    • View Profile
    • Saga Musix - free module music and more!
Loading IT samples... the correct way
« on: July 13, 2013, 22:16:11 »

MilkyPlay / MilkyTracker makes assumptions on the sample format in IT files solely based on the "made with" version found in the file header. This is not correct. The sample format flags should be used for this, so here's a fix for LoaderIT.cpp to pick the correct format, starting from line 622:

Code: [Select]
if (!(smp[i].type&16)) {

smp[i].sample = (mp_sbyte*)module->allocSampleMem(smp[i].samplen);

if (smp[i].sample == NULL)
{
return -7;
}

if (itSmp.Flg & 8)
{
if (!module->loadSample(f, smp[i].sample, smp[i].samplen, smp[i].samplen, (itSmp.Cvt & 4) ? XModule::ST_PACKING_IT215 : XModule::ST_PACKING_IT))
{
return -7;
}
}
else if (!module->loadSample(f,smp[i].sample,smp[i].samplen,smp[i].samplen, (itSmp.Cvt & 1) ? XModule::ST_DEFAULT : XModule::ST_UNSIGNED))
{
return -7;
}
}
else {

smp[i].sample = (mp_sbyte*)module->allocSampleMem(smp[i].samplen*2);

if (smp[i].sample == NULL)
{
return -7;
}

if (itSmp.Flg & 8)
{
if (!module->loadSample(f, smp[i].sample, smp[i].samplen, smp[i].samplen, (itSmp.Cvt & 4) ? (XModule::ST_PACKING_IT215 | XModule::ST_16BIT) : (XModule::ST_PACKING_IT | XModule::ST_16BIT)))
{
return -7;
}
}
else if (!module->loadSample(f,smp[i].sample,smp[i].samplen<<1,smp[i].samplen, XModule::ST_16BIT | ((itSmp.Cvt & 1) ? XModule::ST_DEFAULT : XModule::ST_UNSIGNED)))
{
return -7;
}
}

Notice the usage of itSmp.Cvt instead of cwt/cwtv variables.

Edit: applied by deltafire in svn, thanks!
« Last Edit: July 21, 2013, 16:02:49 by Saga Musix »
Logged
» My TMA artist profile
» Visit my music site: https://sagamusix.de/ [de, en]
» Visit my programming website: https://sagagames.de/ [de]
» Open ModPlug Tracker
Pages: [1]   Go Up