JustAudio/io/int.cpp
Maurice O'Neal 73a8c03fa1 Added a logo to the project and changed the "settings" button to "menu"
and added some options to the menu that changes the behaviour of the
app. such as turning on/off the auto playing of files and the directory
and volume control. this is all kept persistent using an IDM formated
file in the app's config directory. still having issues with it not
calculating the durations properly but i now know why. it's because
QMediaPlayer can't calculate the durations of VBR files (variable bit-
rate) properly. other than that, everything seems to be working
perfectly. i'll add more feasures such as a next/previous file button
and a stop button.
2016-10-16 17:04:21 -04:00

59 lines
1013 B
C++

#include "int.h"
quint64 rdInt(const QByteArray &data)
{
quint64 out = 0;
quint64 outBit = 1;
for (int i = data.size() - 1; i >= 0; --i)
{
int byte = data[i];
for (int inBit = 1; inBit <= 128; inBit *= 2, outBit *= 2)
{
if ((byte & inBit) != 0) out |= outBit;
}
}
return out;
}
float rdFloat(const QByteArray &data)
{
return data.toFloat();
}
QByteArray wrInt(quint64 value, int intSize)
{
QByteArray out;
quint64 inBit = 1;
while (value != 0)
{
int byte = 0;
for (int outBit = 1; outBit <= 128; outBit *= 2, inBit *= 2)
{
if (value & inBit)
{
byte |= outBit;
value ^= inBit;
}
}
out.insert(0, byte);
}
return out.rightJustified(intSize, 0);
}
QByteArray wrInt(quint64 value)
{
return wrInt(value, INT_SIZE);
}
QByteArray wrFloat(float value)
{
return QByteArray().setNum(value);
}