First post, by Ictoagh
I've been working on rearchetecting the MT-32 Emulator, to see if I can come up with something that will finally rid it of it's (very few, but hard to find) niggling audio problems.
One of the things that always chapped me when reviewing the code was the load procedure for the PCM ROM... Here's a newer, more efficient loading routine. I also simplified the dB --> linear conversion a bit, which yeilds a fairly good result
while (!feof(fIn)) {
short s;
*(((char*)&s)+1) = fgetc(fIn); *(((char*)&s)+0) = fgetc(fIn);
short e;
// Bits are ordered in the file as follows:
// 15;6;14;13 12;11;10;9 8;5;4;3 2;1;0;x
e = s & 0x8000;
e |= s << 8 & 0x4000;
e |= s >> 1 & 0x3F80;
e |= s << 1 & 0x007E;
// Get a normalized sample value
float ns = float((e) & 0x7fff)/32768.0;
// Convert Log to Linear, Multiply by bit depth
// I believe this is set up to be over a 100 dB
// range
float o = powf(10,5*(ns-1)) * 32767;
s = e&0x8000?-o:o;
m_PCMRom[i] = s;
i++;
}
For the life of me, I cannot figure out why the samples are stored in such a weird bit order (scambled?) Perhaps this has something to do with the address lines in the ROM?