
Originally Posted by
wysota
Read four bytes, cast them to uchar* and pass to qFromLittleEndian().
Is it possible to elaborate a little?
I've tried many combinations, and read many posts on the net, but...
Is it like this you mean?
audioFil.seek(24);
tst = audioFil.read(4);
tst[0] = (uchar)tst[0];
tst[1] = (uchar)tst[1];
tst[2] = (uchar)tst[2];
tst[3] = (uchar)tst[3];
sampleRate = qFromLittleEndian<quint32>(*tst);
// sampleRate = GetLittleEndianInteger(tst,0);
qDebug() << "sampleRate: " << sampleRate;
audioFil.seek(24);
tst = audioFil.read(4);
tst[0] = (uchar)tst[0];
tst[1] = (uchar)tst[1];
tst[2] = (uchar)tst[2];
tst[3] = (uchar)tst[3];
sampleRate = qFromLittleEndian<quint32>(*tst);
// sampleRate = GetLittleEndianInteger(tst,0);
qDebug() << "sampleRate: " << sampleRate;
To copy to clipboard, switch view to plain text mode
The debug-output is 'sampleRate: 68'. 68 = 'D' = tst[0].
I don't really get it. Hence 'Beginner'...
EDITED:
when I read my reply it dawned a little. This works:
uchar* cc;
audioFil.seek(24);
tst = audioFil.read(4);
cc[0] = tst[0];
cc[1] = tst[1];
cc[2] = tst[2];
cc[3] = tst[3];
sampleRate = qFromLittleEndian<qint32>(cc);
// sampleRate = GetLittleEndianInteger(tst,0);
qDebug() << "sampleRate: " << sampleRate;
uchar* cc;
audioFil.seek(24);
tst = audioFil.read(4);
cc[0] = tst[0];
cc[1] = tst[1];
cc[2] = tst[2];
cc[3] = tst[3];
sampleRate = qFromLittleEndian<qint32>(cc);
// sampleRate = GetLittleEndianInteger(tst,0);
qDebug() << "sampleRate: " << sampleRate;
To copy to clipboard, switch view to plain text mode
...but could it be done more effectively?
Bookmarks