mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-07-12 20:15:37 +02:00
New stuff
This commit is contained in:
@ -39,7 +39,7 @@ namespace io {
|
||||
outputParams.hostApiSpecificStreamInfo = NULL;
|
||||
outputParams.device = Pa_GetDefaultOutputDevice();
|
||||
outputParams.suggestedLatency = Pa_GetDeviceInfo(outputParams.device)->defaultLowOutputLatency;
|
||||
PaError err = Pa_OpenStream(&stream, NULL, &outputParams, 40000.0f, 320, paClipOff, _callback, this);
|
||||
PaError err = Pa_OpenStream(&stream, NULL, &outputParams, 48000.0f, 64, paClipOff, _callback, this);
|
||||
printf("%s\n", Pa_GetErrorText(err));
|
||||
err = Pa_StartStream(stream);
|
||||
printf("%s\n", Pa_GetErrorText(err));
|
||||
@ -49,6 +49,12 @@ namespace io {
|
||||
Pa_CloseStream(stream);
|
||||
}
|
||||
|
||||
void setBlockSize(int blockSize) {
|
||||
stop();
|
||||
_bufferSize = blockSize;
|
||||
start();
|
||||
}
|
||||
|
||||
private:
|
||||
static int _callback(const void *input,
|
||||
void *output,
|
||||
@ -58,10 +64,16 @@ namespace io {
|
||||
AudioSink* _this = (AudioSink*)userData;
|
||||
float* outbuf = (float*)output;
|
||||
_this->_input->read(_this->buffer, frameCount);
|
||||
|
||||
float vol = powf(_this->_volume, 2);
|
||||
for (int i = 0; i < frameCount; i++) {
|
||||
|
||||
|
||||
outbuf[(i * 2) + 0] = _this->buffer[i] * vol;
|
||||
outbuf[(i * 2) + 1] = _this->buffer[i] * vol;
|
||||
|
||||
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -66,6 +66,7 @@ namespace io {
|
||||
if (running) {
|
||||
return;
|
||||
}
|
||||
_sampleRate = sampleRate;
|
||||
dev->setSampleRate(SOAPY_SDR_RX, 0, sampleRate);
|
||||
}
|
||||
|
||||
@ -86,12 +87,17 @@ namespace io {
|
||||
|
||||
private:
|
||||
static void _worker(SoapyWrapper* _this) {
|
||||
dsp::complex_t* buf = new dsp::complex_t[32000];
|
||||
int blockSize = _this->_sampleRate / 200.0f;
|
||||
dsp::complex_t* buf = new dsp::complex_t[blockSize];
|
||||
int flags = 0;
|
||||
long long timeMs = 0;
|
||||
|
||||
while (_this->running) {
|
||||
_this->dev->readStream(_this->_stream, (void**)&buf, 32000, flags, timeMs);
|
||||
_this->output.write(buf, 32000);
|
||||
int res = _this->dev->readStream(_this->_stream, (void**)&buf, blockSize, flags, timeMs);
|
||||
if (res < 1) {
|
||||
continue;
|
||||
}
|
||||
_this->output.write(buf, res);
|
||||
}
|
||||
printf("Read worker terminated\n");
|
||||
delete[] buf;
|
||||
@ -102,5 +108,6 @@ namespace io {
|
||||
SoapySDR::Stream* _stream;
|
||||
std::thread _workerThread;
|
||||
bool running = false;
|
||||
float _sampleRate = 0;
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user