fix loading 24-bit samples

This commit is contained in:
tildearrow 2022-06-23 22:33:25 -05:00
parent e34de2262b
commit b66cc81fc6

View file

@ -2221,9 +2221,15 @@ int DivEngine::addSampleFromFile(const char* path) {
buf=new short[si.channels*si.frames]; buf=new short[si.channels*si.frames];
sampleLen=sizeof(short); sampleLen=sizeof(short);
} }
if ((si.format&SF_FORMAT_SUBMASK)==SF_FORMAT_PCM_U8 || (si.format&SF_FORMAT_SUBMASK)==SF_FORMAT_FLOAT) {
if (sf_read_raw(f,buf,si.frames*si.channels*sampleLen)!=(si.frames*si.channels*sampleLen)) { if (sf_read_raw(f,buf,si.frames*si.channels*sampleLen)!=(si.frames*si.channels*sampleLen)) {
logW("sample read size mismatch!"); logW("sample read size mismatch!");
} }
} else {
if (sf_read_short(f,(short*)buf,si.frames*si.channels)!=(si.frames*si.channels)) {
logW("sample read size mismatch!");
}
}
DivSample* sample=new DivSample; DivSample* sample=new DivSample;
int sampleCount=(int)song.sample.size(); int sampleCount=(int)song.sample.size();
sample->name=stripPath; sample->name=stripPath;