mciSendStringでMP3再生するときID3v2のせいで起こる遅延の計算(C++コード付き)

昨日言ったこと。
自分で書いた計算のC++コードは大体この感じ


double CheckMp3_mciSendStringWorkAround(std::istream& mp3file)
{
char id3[3];

mp3file.read(id3, 3);
if(mp3file.gcount() != 3) throw MyException("Fail to read id3v2 tag");

if(std::equal(id3, id3 + 3, "ID3")) {
//start workaround
//skip 3 byte, advanced to id3v2 frame size
mp3file.ignore(3);
unsigned char id3v2size[4];

mp3file.read(reinterpret_cast<char*>(id3v2size), 4);
if (mp3file.gcount() != 4) throw MyException("Fail to read id3v2 size");

int nId3v2size = id3v2size[0] * 0x80 * 0x80 * 0x80
+ id3v2size[1] * 0x80 * 0x80
+ id3v2size[2] * 0x80
+ id3v2size[3];

int id3end = nId3v2size + 10;
mp3file.seekg(0, std::ios::beg);
char buf[8]; //frame header + crc
mp3file.read(buf, 8);
if (mp3file.gcount() != 8) throw MyException("Fail to read mp3 frames");
if (buf[1] & 1) {//check if there are crc
nId3v2size -= 4;
} else {
if ( (buf[4] | buf[5] | buf[6] | buf[7]) == 0 )
nId3v2size -= 8;
else
return 0;
}

//get duration
return double(nId3v2size) * 8 / 128000;
} else
//no need to work around
return 0;
}

試したことはまた少ない。
少なくとも試したMP3だけ一応計算できる

その128000にまた知らないことがあります。
ほかの計算方法あるのかなって

・・・クソ、MCIでMP3を再生するの仕様