Mod Archive Forums

Music Production => MilkyTracker Bug Reports => MilkyTracker => Tracking => Bug Report Archive => Topic started by: Saga Musix on July 13, 2013, 22:16:11

Title: Loading IT samples... the correct way
Post by: Saga Musix 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!