mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-10 17:58:36 -04:00
File Input: acceleration and loop handling phase 1
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
|
||||
#include "filesourcesettings.h"
|
||||
|
||||
const unsigned int FileSourceSettings::m_accelerationMaxScale = 1;
|
||||
|
||||
FileSourceSettings::FileSourceSettings()
|
||||
{
|
||||
resetToDefaults();
|
||||
@@ -28,12 +30,16 @@ void FileSourceSettings::resetToDefaults()
|
||||
m_centerFrequency = 435000000;
|
||||
m_sampleRate = 48000;
|
||||
m_fileName = "./test.sdriq";
|
||||
m_accelerationFactor = 1;
|
||||
m_loop = true;
|
||||
}
|
||||
|
||||
QByteArray FileSourceSettings::serialize() const
|
||||
{
|
||||
SimpleSerializer s(1);
|
||||
s.writeString(1, m_fileName);
|
||||
s.writeU32(2, m_accelerationFactor);
|
||||
s.writeBool(3, m_loop);
|
||||
return s.final();
|
||||
}
|
||||
|
||||
@@ -48,6 +54,8 @@ bool FileSourceSettings::deserialize(const QByteArray& data)
|
||||
|
||||
if(d.getVersion() == 1) {
|
||||
d.readString(1, &m_fileName, "./test.sdriq");
|
||||
d.readU32(2, &m_accelerationFactor, 1);
|
||||
d.readBool(3, &m_loop, true);
|
||||
return true;
|
||||
} else {
|
||||
resetToDefaults();
|
||||
@@ -55,6 +63,60 @@ bool FileSourceSettings::deserialize(const QByteArray& data)
|
||||
}
|
||||
}
|
||||
|
||||
int FileSourceSettings::getAccelerationIndex(int accelerationValue)
|
||||
{
|
||||
if (accelerationValue <= 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int v = accelerationValue;
|
||||
int j = 0;
|
||||
|
||||
for (int i = 0; i <= accelerationValue; i++)
|
||||
{
|
||||
if (v < 20)
|
||||
{
|
||||
if (v < 2) {
|
||||
j = 0;
|
||||
} else if (v < 5) {
|
||||
j = 1;
|
||||
} else if (v < 10) {
|
||||
j = 2;
|
||||
} else {
|
||||
j = 3;
|
||||
}
|
||||
|
||||
return 3*i + j;
|
||||
}
|
||||
|
||||
v /= 10;
|
||||
}
|
||||
|
||||
return 3*m_accelerationMaxScale + 3;
|
||||
}
|
||||
|
||||
int FileSourceSettings::getAccelerationValue(int accelerationIndex)
|
||||
{
|
||||
if (accelerationIndex <= 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int v = accelerationIndex - 1;
|
||||
int m = pow(10.0, v/3 > m_accelerationMaxScale ? m_accelerationMaxScale : v/3);
|
||||
int x;
|
||||
|
||||
if (v % 3 == 0) {
|
||||
x = 2;
|
||||
} else if (v % 3 == 1) {
|
||||
x = 5;
|
||||
} else if (v % 3 == 2) {
|
||||
x = 10;
|
||||
}
|
||||
|
||||
return x * m;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user