mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-09-09 10:17:47 -04:00
HackRF output plugin: corrected sample size
This commit is contained in:
parent
212a8ad2f9
commit
64246c5c6a
@ -7,10 +7,10 @@ if(LIBUSB_FOUND AND LIBBLADERF_FOUND)
|
|||||||
add_subdirectory(bladerfoutput)
|
add_subdirectory(bladerfoutput)
|
||||||
endif(LIBUSB_FOUND AND LIBBLADERF_FOUND)
|
endif(LIBUSB_FOUND AND LIBBLADERF_FOUND)
|
||||||
|
|
||||||
#find_package(LibHACKRF)
|
find_package(LibHACKRF)
|
||||||
#if(LIBUSB_FOUND AND LIBHACKRF_FOUND)
|
if(LIBUSB_FOUND AND LIBHACKRF_FOUND)
|
||||||
# add_subdirectory(hackrfoutput)
|
add_subdirectory(hackrfoutput)
|
||||||
#endif(LIBUSB_FOUND AND LIBHACKRF_FOUND)
|
endif(LIBUSB_FOUND AND LIBHACKRF_FOUND)
|
||||||
|
|
||||||
if (BUILD_DEBIAN)
|
if (BUILD_DEBIAN)
|
||||||
add_subdirectory(bladerfoutput)
|
add_subdirectory(bladerfoutput)
|
||||||
|
@ -25,12 +25,10 @@ HackRFOutputThread::HackRFOutputThread(hackrf_device* dev, SampleSourceFifo* sam
|
|||||||
QThread(parent),
|
QThread(parent),
|
||||||
m_running(false),
|
m_running(false),
|
||||||
m_dev(dev),
|
m_dev(dev),
|
||||||
m_convertBuffer(HACKRF_BLOCKSIZE),
|
|
||||||
m_sampleFifo(sampleFifo),
|
m_sampleFifo(sampleFifo),
|
||||||
m_samplerate(10),
|
m_samplerate(10),
|
||||||
m_log2Interp(0)
|
m_log2Interp(0)
|
||||||
{
|
{
|
||||||
qDebug("HackRFOutputThread::HackRFOutputThread: m_dev: %lx m_sampleFifo: %lx", (uint64_t) m_dev, (uint64_t) m_sampleFifo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HackRFOutputThread::~HackRFOutputThread()
|
HackRFOutputThread::~HackRFOutputThread()
|
||||||
@ -81,11 +79,6 @@ void HackRFOutputThread::run()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug("HackRFOutputThread::run: this: %lx start HackRF Tx: m_dev: %lx m_sampleFifo: %lx",
|
|
||||||
(uint64_t) this,
|
|
||||||
(uint64_t) m_dev,
|
|
||||||
(uint64_t) m_sampleFifo);
|
|
||||||
|
|
||||||
while ((m_running) && (hackrf_is_streaming(m_dev) == HACKRF_TRUE))
|
while ((m_running) && (hackrf_is_streaming(m_dev) == HACKRF_TRUE))
|
||||||
{
|
{
|
||||||
sleep(1);
|
sleep(1);
|
||||||
@ -107,37 +100,37 @@ void HackRFOutputThread::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Interpolate according to specified log2 (ex: log2=4 => interp=16)
|
// Interpolate according to specified log2 (ex: log2=4 => interp=16)
|
||||||
void HackRFOutputThread::callback(qint16* buf, qint32 len)
|
void HackRFOutputThread::callback(qint8* buf, qint32 len)
|
||||||
{
|
{
|
||||||
SampleVector::iterator beginRead;
|
SampleVector::iterator beginRead;
|
||||||
m_sampleFifo->readAdvance(beginRead, len/(1<<m_log2Interp));
|
m_sampleFifo->readAdvance(beginRead, len/(2*(1<<m_log2Interp)));
|
||||||
beginRead -= len;
|
beginRead -= len/2;
|
||||||
|
|
||||||
if (m_log2Interp == 0)
|
if (m_log2Interp == 0)
|
||||||
{
|
{
|
||||||
m_interpolators.interpolate1(&beginRead, buf, len*2);
|
m_interpolators.interpolate1(&beginRead, buf, len);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (m_log2Interp)
|
switch (m_log2Interp)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
m_interpolators.interpolate2_cen(&beginRead, buf, len*2);
|
m_interpolators.interpolate2_cen(&beginRead, buf, len);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
m_interpolators.interpolate4_cen(&beginRead, buf, len*2);
|
m_interpolators.interpolate4_cen(&beginRead, buf, len);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
m_interpolators.interpolate8_cen(&beginRead, buf, len*2);
|
m_interpolators.interpolate8_cen(&beginRead, buf, len);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
m_interpolators.interpolate16_cen(&beginRead, buf, len*2);
|
m_interpolators.interpolate16_cen(&beginRead, buf, len);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
m_interpolators.interpolate32_cen(&beginRead, buf, len*2);
|
m_interpolators.interpolate32_cen(&beginRead, buf, len);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
m_interpolators.interpolate64_cen(&beginRead, buf, len*2);
|
m_interpolators.interpolate64_cen(&beginRead, buf, len);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -148,7 +141,7 @@ void HackRFOutputThread::callback(qint16* buf, qint32 len)
|
|||||||
int HackRFOutputThread::tx_callback(hackrf_transfer* transfer)
|
int HackRFOutputThread::tx_callback(hackrf_transfer* transfer)
|
||||||
{
|
{
|
||||||
HackRFOutputThread *thread = (HackRFOutputThread *) transfer->tx_ctx;
|
HackRFOutputThread *thread = (HackRFOutputThread *) transfer->tx_ctx;
|
||||||
qint32 bytes_to_write = transfer->valid_length;
|
qint32 bytes_to_write = transfer->valid_length;
|
||||||
thread->callback((qint16 *) transfer->buffer, bytes_to_write);
|
thread->callback((qint8 *) transfer->buffer, bytes_to_write);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "dsp/samplesourcefifo.h"
|
#include "dsp/samplesourcefifo.h"
|
||||||
#include "dsp/interpolators.h"
|
#include "dsp/interpolators.h"
|
||||||
|
|
||||||
#define HACKRF_BLOCKSIZE (1<<17)
|
#define HACKRF_BLOCKSIZE (1<<18)
|
||||||
|
|
||||||
class HackRFOutputThread : public QThread {
|
class HackRFOutputThread : public QThread {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -45,17 +45,16 @@ private:
|
|||||||
bool m_running;
|
bool m_running;
|
||||||
|
|
||||||
hackrf_device* m_dev;
|
hackrf_device* m_dev;
|
||||||
qint16 m_buf[2*HACKRF_BLOCKSIZE];
|
qint8 m_buf[2*HACKRF_BLOCKSIZE];
|
||||||
SampleVector m_convertBuffer;
|
|
||||||
SampleSourceFifo* m_sampleFifo;
|
SampleSourceFifo* m_sampleFifo;
|
||||||
|
|
||||||
int m_samplerate;
|
int m_samplerate;
|
||||||
unsigned int m_log2Interp;
|
unsigned int m_log2Interp;
|
||||||
|
|
||||||
Interpolators<qint16, SDR_SAMP_SZ, 12> m_interpolators;
|
Interpolators<qint8, SDR_SAMP_SZ, 8> m_interpolators;
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
void callback(qint16* buf, qint32 len);
|
void callback(qint8* buf, qint32 len);
|
||||||
static int tx_callback(hackrf_transfer* transfer);
|
static int tx_callback(hackrf_transfer* transfer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user