mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-22 16:08:39 -05:00
FileSource channel: fixed 16 bits sample size processing and play loop
This commit is contained in:
parent
5676cb8674
commit
9526d82ab8
@ -117,31 +117,24 @@ void FileSource::pull(Sample& sample)
|
|||||||
|
|
||||||
if (m_sampleSize == 16)
|
if (m_sampleSize == 16)
|
||||||
{
|
{
|
||||||
if (SDR_RX_SAMP_SZ == 16)
|
Sample16 sample16;
|
||||||
{
|
m_ifstream.read(reinterpret_cast<char*>(&sample16), sizeof(Sample16));
|
||||||
m_ifstream.read(reinterpret_cast<char*>(&sample), sizeof(Sample));
|
|
||||||
|
|
||||||
if (m_ifstream.eof()) {
|
if (m_ifstream.eof()) {
|
||||||
handleEOF();
|
handleEOF();
|
||||||
} else {
|
} else {
|
||||||
m_samplesCount++;
|
m_samplesCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SDR_TX_SAMP_SZ == 16)
|
||||||
|
{
|
||||||
|
sample.setReal(sample16.real);
|
||||||
|
sample.setImag(sample16.imag);
|
||||||
}
|
}
|
||||||
else if (SDR_RX_SAMP_SZ == 24)
|
else if (SDR_TX_SAMP_SZ == 24)
|
||||||
{
|
{
|
||||||
Sample16 sample16;
|
sample.setReal(sample16.real << 8);
|
||||||
m_ifstream.read(reinterpret_cast<char*>(&sample16), sizeof(Sample16));
|
sample.setImag(sample16.imag << 8);
|
||||||
|
|
||||||
if (m_ifstream.eof())
|
|
||||||
{
|
|
||||||
handleEOF();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sample.setReal(sample16.real << 8);
|
|
||||||
sample.setImag(sample16.imag << 8);
|
|
||||||
m_samplesCount++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -151,31 +144,24 @@ void FileSource::pull(Sample& sample)
|
|||||||
}
|
}
|
||||||
else if (m_sampleSize == 24)
|
else if (m_sampleSize == 24)
|
||||||
{
|
{
|
||||||
if (SDR_RX_SAMP_SZ == 24)
|
Sample24 sample24;
|
||||||
{
|
m_ifstream.read(reinterpret_cast<char*>(&sample24), sizeof(Sample24));
|
||||||
m_ifstream.read(reinterpret_cast<char*>(&sample), sizeof(Sample));
|
|
||||||
|
|
||||||
if (m_ifstream.eof()) {
|
if (m_ifstream.eof()) {
|
||||||
handleEOF();
|
handleEOF();
|
||||||
} else {
|
} else {
|
||||||
m_samplesCount++;
|
m_samplesCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SDR_TX_SAMP_SZ == 24)
|
||||||
|
{
|
||||||
|
sample.setReal(sample24.real);
|
||||||
|
sample.setImag(sample24.imag);
|
||||||
}
|
}
|
||||||
else if (SDR_RX_SAMP_SZ == 16)
|
else if (SDR_TX_SAMP_SZ == 16)
|
||||||
{
|
{
|
||||||
Sample24 sample24;
|
sample.setReal(sample24.real >> 8);
|
||||||
m_ifstream.read(reinterpret_cast<char*>(&sample24), sizeof(Sample24));
|
sample.setImag(sample24.imag >> 8);
|
||||||
|
|
||||||
if (m_ifstream.eof())
|
|
||||||
{
|
|
||||||
handleEOF();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sample.setReal(sample24.real >> 8);
|
|
||||||
sample.setImag(sample24.imag >> 8);
|
|
||||||
m_samplesCount++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -440,8 +426,6 @@ void FileSource::seekFileStream(int seekMillis)
|
|||||||
|
|
||||||
void FileSource::handleEOF()
|
void FileSource::handleEOF()
|
||||||
{
|
{
|
||||||
stop();
|
|
||||||
|
|
||||||
if (getMessageQueueToGUI())
|
if (getMessageQueueToGUI())
|
||||||
{
|
{
|
||||||
MsgReportFileSourceStreamTiming *report = MsgReportFileSourceStreamTiming::create(getSamplesCount());
|
MsgReportFileSourceStreamTiming *report = MsgReportFileSourceStreamTiming::create(getSamplesCount());
|
||||||
@ -450,12 +434,14 @@ void FileSource::handleEOF()
|
|||||||
|
|
||||||
if (m_settings.m_loop)
|
if (m_settings.m_loop)
|
||||||
{
|
{
|
||||||
|
stop();
|
||||||
seekFileStream(0);
|
seekFileStream(0);
|
||||||
m_samplesCount = 0;
|
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
stop();
|
||||||
|
|
||||||
if (getMessageQueueToGUI())
|
if (getMessageQueueToGUI())
|
||||||
{
|
{
|
||||||
MsgPlayPause *report = MsgPlayPause::create(false);
|
MsgPlayPause *report = MsgPlayPause::create(false);
|
||||||
|
@ -182,7 +182,8 @@ FileSourceGUI::FileSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Bas
|
|||||||
m_channelMarker.blockSignals(true);
|
m_channelMarker.blockSignals(true);
|
||||||
m_channelMarker.setColor(m_settings.m_rgbColor);
|
m_channelMarker.setColor(m_settings.m_rgbColor);
|
||||||
m_channelMarker.setCenterFrequency(0);
|
m_channelMarker.setCenterFrequency(0);
|
||||||
m_channelMarker.setTitle("Remote source");
|
m_channelMarker.setTitle("File source");
|
||||||
|
m_channelMarker.setMovable(false); // do not let user move the center arbitrarily
|
||||||
m_channelMarker.setSourceOrSinkStream(false);
|
m_channelMarker.setSourceOrSinkStream(false);
|
||||||
m_channelMarker.blockSignals(false);
|
m_channelMarker.blockSignals(false);
|
||||||
m_channelMarker.setVisible(true); // activate signal on the last setting only
|
m_channelMarker.setVisible(true); // activate signal on the last setting only
|
||||||
@ -245,7 +246,9 @@ void FileSourceGUI::configureFileName()
|
|||||||
|
|
||||||
void FileSourceGUI::updateWithAcquisition()
|
void FileSourceGUI::updateWithAcquisition()
|
||||||
{
|
{
|
||||||
|
ui->play->blockSignals(true);
|
||||||
ui->play->setChecked(m_acquisition);
|
ui->play->setChecked(m_acquisition);
|
||||||
|
ui->play->blockSignals(false);
|
||||||
ui->showFileDialog->setEnabled(!m_acquisition);
|
ui->showFileDialog->setEnabled(!m_acquisition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user