diff --git a/core/src/dsp/demodulator.h b/core/src/dsp/demodulator.h index c2914a95..b08cd820 100644 --- a/core/src/dsp/demodulator.h +++ b/core/src/dsp/demodulator.h @@ -37,7 +37,7 @@ namespace dsp { _in = in; _sampleRate = sampleRate; _deviation = deviation; - phasorSpeed = (_sampleRate / _deviation) / (2 * FL_M_PI); + phasorSpeed = (2 * FL_M_PI) / (_sampleRate / _deviation); generic_block::registerInput(_in); generic_block::registerOutput(&out); } @@ -55,7 +55,7 @@ namespace dsp { std::lock_guard lck(generic_block::ctrlMtx); generic_block::tempStop(); _sampleRate = sampleRate; - phasorSpeed = (_sampleRate / _deviation) / (2 * FL_M_PI); + phasorSpeed = (2 * FL_M_PI) / (_sampleRate / _deviation); generic_block::tempStart(); } @@ -67,7 +67,7 @@ namespace dsp { std::lock_guard lck(generic_block::ctrlMtx); generic_block::tempStop(); _deviation = deviation; - phasorSpeed = (_sampleRate / _deviation) / (2 * FL_M_PI); + phasorSpeed = (2 * FL_M_PI) / (_sampleRate / _deviation); generic_block::tempStart(); } @@ -87,8 +87,9 @@ namespace dsp { for (int i = 0; i < count; i++) { currentPhase = fast_arctan2(_in->data[i].i, _in->data[i].q); diff = currentPhase - phase; - if (diff > FL_M_PI) { out.data[i] = (diff - 2 * FL_M_PI) * phasorSpeed; } - else if (diff <= -FL_M_PI) { out.data[i] = (diff + 2 * FL_M_PI) * phasorSpeed; } + if (diff > 3.1415926535f) { diff -= 2 * 3.1415926535f; } + else if (diff <= -3.1415926535f) { diff += 2 * 3.1415926535f; } + out.data[i] = diff / phasorSpeed; phase = currentPhase; } diff --git a/core/src/dsp/filter.h b/core/src/dsp/filter.h index e530b295..e59c34a9 100644 --- a/core/src/dsp/filter.h +++ b/core/src/dsp/filter.h @@ -135,11 +135,12 @@ namespace dsp { count = _in->read(); if (count < 0) { return -1; } - if (bypass || true) { + if (bypass) { if (out.aquire() < 0) { return -1; } memcpy(out.data, _in->data, count * sizeof(float)); _in->flush(); out.write(count); + return count; } if (isnan(lastOut)) { diff --git a/core/src/dsp/resampling.h b/core/src/dsp/resampling.h index 2c88504c..0abbf6fa 100644 --- a/core/src/dsp/resampling.h +++ b/core/src/dsp/resampling.h @@ -29,14 +29,10 @@ namespace dsp { tapCount = _window->getTapCount(); taps = (float*)volk_malloc(tapCount * sizeof(float), volk_get_alignment()); - _window->createTaps(taps, tapCount); - for (int i = 0; i < tapCount / 2; i++) { - float tap = taps[tapCount - i - 1]; - taps[tapCount - i - 1] = taps[i] * (float)_interp; - taps[i] = tap * (float)_interp; - } + _window->createTaps(taps, tapCount, _interp); buffer = (T*)volk_malloc(STREAM_BUFFER_SIZE * sizeof(T) * 2, volk_get_alignment()); + memset(buffer, 0, STREAM_BUFFER_SIZE * sizeof(T) * 2); bufStart = &buffer[tapCount]; generic_block>::registerInput(_in); generic_block>::registerOutput(&out); @@ -86,12 +82,7 @@ namespace dsp { volk_free(taps); tapCount = window->getTapCount(); taps = (float*)volk_malloc(tapCount * sizeof(float), volk_get_alignment()); - window->createTaps(taps, tapCount); - for (int i = 0; i < tapCount / 2; i++) { - float tap = taps[tapCount - i - 1]; - taps[tapCount - i - 1] = taps[i] * (float)_interp; - taps[i] = tap * (float)_interp; - } + window->createTaps(taps, tapCount, _interp); bufStart = &buffer[tapCount]; generic_block>::tempStart(); } @@ -117,9 +108,6 @@ namespace dsp { } int outIndex = 0; if constexpr (std::is_same_v) { - for (int i = 0; i < count; i++) { - buffer[tapCount + i] = 1.0f; - } for (int i = 0; outIndex < outCount; i += _decim) { out.data[outIndex] = 0; for (int j = i % _interp; j < tapCount; j += _interp) { diff --git a/core/src/dsp/window.h b/core/src/dsp/window.h index b71070e7..aca55df3 100644 --- a/core/src/dsp/window.h +++ b/core/src/dsp/window.h @@ -6,7 +6,7 @@ namespace dsp { class generic_window { public: virtual int getTapCount() { return -1; } - virtual void createTaps(float* taps, int tapCount) {} + virtual void createTaps(float* taps, int tapCount, float factor = 1.0f) {} }; class BlackmanWindow : public filter_window::generic_window { @@ -48,7 +48,7 @@ namespace dsp { return _M; } - void createTaps(float* taps, int tapCount) { + void createTaps(float* taps, int tapCount, float factor = 1.0f) { float fc = _cutoff / _sampleRate; if (fc > 1.0f) { fc = 1.0f; @@ -59,10 +59,11 @@ namespace dsp { for (int i = 0; i < tapCount; i++) { val = (sin(2.0f * FL_M_PI * fc * ((float)i - (tc / 2))) / ((float)i - (tc / 2))) * (0.42f - (0.5f * cos(2.0f * FL_M_PI / tc)) + (0.8f * cos(4.0f * FL_M_PI / tc))); - taps[tapCount - i - 1] = val; // tapCount - i - 1 + taps[i] = val; // tapCount - i - 1 sum += val; } for (int i = 0; i < tapCount; i++) { + taps[i] *= factor; taps[i] /= sum; } } diff --git a/recorder/src/main.cpp b/recorder/src/main.cpp index 5936db55..76675b5f 100644 --- a/recorder/src/main.cpp +++ b/recorder/src/main.cpp @@ -179,13 +179,13 @@ private: while (true) { int count = _this->audioStream->read(); if (count < 0) { break; } - for (int i = 0; i < 1024; i++) { + for (int i = 0; i < 240; i++) { sampleBuf[(i * 2) + 0] = _this->audioStream->data[i].l * 0x7FFF; sampleBuf[(i * 2) + 1] = _this->audioStream->data[i].r * 0x7FFF; } _this->audioStream->flush(); - _this->samplesWritten += 1024; - _this->writer->writeSamples(sampleBuf, 2048 * sizeof(int16_t)); + _this->samplesWritten += 240; + _this->writer->writeSamples(sampleBuf, 480 * sizeof(int16_t)); } delete[] sampleBuf; } diff --git a/root_dev/config.json b/root_dev/config.json index 8f687bdc..09598df2 100644 --- a/root_dev/config.json +++ b/root_dev/config.json @@ -1,9 +1,9 @@ { "audio": { "Radio": { - "device": "default", + "device": "Speakers (Realtek High Definiti", "sampleRate": 48000.0, - "volume": 1.0 + "volume": 0.51953125 }, "Radio 1": { "device": "Speakers (Realtek High Definition Audio)", diff --git a/root_dev/module_list.json b/root_dev/module_list.json index 3c037b78..b93a9b45 100644 --- a/root_dev/module_list.json +++ b/root_dev/module_list.json @@ -1,6 +1,6 @@ { - "Radio": "./radio/RelWithDebInfo/radio.dll", - "Recorder": "./recorder/RelWithDebInfo/recorder.dll", - "Soapy": "./soapy/RelWithDebInfo/soapy.dll", - "RTLTCPSource": "./rtl_tcp_source/RelWithDebInfo/rtl_tcp_source.dll" + "Radio": "./radio/Release/radio.dll", + "Recorder": "./recorder/Release/recorder.dll", + "Soapy": "./soapy/Release/soapy.dll", + "RTLTCPSource": "./rtl_tcp_source/Release/rtl_tcp_source.dll" } diff --git a/root_dev/recordings/audio_22-55-07_03-11-2020.wav b/root_dev/recordings/audio_22-55-07_03-11-2020.wav new file mode 100644 index 00000000..c7de3d78 Binary files /dev/null and b/root_dev/recordings/audio_22-55-07_03-11-2020.wav differ diff --git a/root_dev/recordings/audio_23-11-22_03-11-2020.wav b/root_dev/recordings/audio_23-11-22_03-11-2020.wav new file mode 100644 index 00000000..e73b7874 Binary files /dev/null and b/root_dev/recordings/audio_23-11-22_03-11-2020.wav differ diff --git a/root_dev/soapy_source_config.json b/root_dev/soapy_source_config.json index 0dde10e2..9fbc5e6f 100644 --- a/root_dev/soapy_source_config.json +++ b/root_dev/soapy_source_config.json @@ -1,5 +1,5 @@ { - "device": "Generic RTL2832U OEM :: 00000001", + "device": "HackRF One #0 901868dc282c8f8b", "devices": { "AirSpy HF+ [c852435de0224af7]": { "gains": {