mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-26 20:37:50 +02:00
added a recorder module
This commit is contained in:
@ -108,14 +108,24 @@ namespace audio {
|
||||
bstr.sampleRateChangeHandler = sampleRateChangeHandler;
|
||||
if (astr->type == STREAM_TYPE_MONO) {
|
||||
bstr.monoStream = new dsp::stream<float>(astr->blockSize * 2);
|
||||
astr->monoDynSplit->stop();
|
||||
astr->monoDynSplit->bind(bstr.monoStream);
|
||||
if (astr->running) {
|
||||
astr->monoDynSplit->start();
|
||||
}
|
||||
astr->boundStreams.push_back(bstr);
|
||||
return bstr.monoStream;
|
||||
}
|
||||
bstr.stereoStream = new dsp::stream<dsp::StereoFloat_t>(astr->blockSize * 2);
|
||||
bstr.s2m = new dsp::StereoToMono(bstr.stereoStream, astr->blockSize * 2);
|
||||
bstr.monoStream = &bstr.s2m->output;
|
||||
astr->stereoDynSplit->stop();
|
||||
astr->stereoDynSplit->bind(bstr.stereoStream);
|
||||
if (astr->running) {
|
||||
astr->stereoDynSplit->start();
|
||||
}
|
||||
bstr.s2m->start();
|
||||
astr->boundStreams.push_back(bstr);
|
||||
return bstr.monoStream;
|
||||
}
|
||||
|
||||
@ -128,14 +138,24 @@ namespace audio {
|
||||
bstr.sampleRateChangeHandler = sampleRateChangeHandler;
|
||||
if (astr->type == STREAM_TYPE_STEREO) {
|
||||
bstr.stereoStream = new dsp::stream<dsp::StereoFloat_t>(astr->blockSize * 2);
|
||||
astr->stereoDynSplit->stop();
|
||||
astr->stereoDynSplit->bind(bstr.stereoStream);
|
||||
if (astr->running) {
|
||||
astr->stereoDynSplit->start();
|
||||
}
|
||||
astr->boundStreams.push_back(bstr);
|
||||
return bstr.stereoStream;
|
||||
}
|
||||
bstr.monoStream = new dsp::stream<float>(astr->blockSize * 2);
|
||||
bstr.m2s = new dsp::MonoToStereo(bstr.monoStream, astr->blockSize * 2);
|
||||
bstr.stereoStream = &bstr.m2s->output;
|
||||
astr->monoDynSplit->stop();
|
||||
astr->monoDynSplit->bind(bstr.monoStream);
|
||||
if (astr->running) {
|
||||
astr->monoDynSplit->start();
|
||||
}
|
||||
bstr.m2s->start();
|
||||
astr->boundStreams.push_back(bstr);
|
||||
return bstr.stereoStream;
|
||||
}
|
||||
|
||||
@ -179,8 +199,19 @@ namespace audio {
|
||||
continue;
|
||||
}
|
||||
if (astr->type == STREAM_TYPE_STEREO) {
|
||||
astr->stereoDynSplit->stop();
|
||||
astr->stereoDynSplit->unbind(bstr.stereoStream);
|
||||
if (astr->running) {
|
||||
astr->stereoDynSplit->start();
|
||||
}
|
||||
bstr.s2m->stop();
|
||||
delete bstr.s2m;
|
||||
return;
|
||||
}
|
||||
astr->monoDynSplit->stop();
|
||||
astr->monoDynSplit->unbind(bstr.monoStream);
|
||||
if (astr->running) {
|
||||
astr->monoDynSplit->start();
|
||||
}
|
||||
delete stream;
|
||||
return;
|
||||
@ -195,8 +226,19 @@ namespace audio {
|
||||
continue;
|
||||
}
|
||||
if (astr->type == STREAM_TYPE_MONO) {
|
||||
bstr.s2m->stop();
|
||||
astr->monoDynSplit->stop();
|
||||
astr->monoDynSplit->unbind(bstr.monoStream);
|
||||
if (astr->running) {
|
||||
astr->monoDynSplit->start();
|
||||
}
|
||||
bstr.m2s->stop();
|
||||
delete bstr.m2s;
|
||||
return;
|
||||
}
|
||||
astr->stereoDynSplit->stop();
|
||||
astr->stereoDynSplit->unbind(bstr.stereoStream);
|
||||
if (astr->running) {
|
||||
astr->stereoDynSplit->start();
|
||||
}
|
||||
delete stream;
|
||||
return;
|
||||
@ -259,5 +301,13 @@ namespace audio {
|
||||
astr->audio->setDevice(deviceId);
|
||||
setSampleRate(name, sampleRate);
|
||||
}
|
||||
|
||||
std::vector<std::string> getStreamNameList() {
|
||||
std::vector<std::string> list;
|
||||
for (auto [name, stream] : streams) {
|
||||
list.push_back(name);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -59,5 +59,6 @@ namespace audio {
|
||||
std::string getNameFromVFO(std::string vfoName);
|
||||
void setSampleRate(std::string name, float sampleRate);
|
||||
void setAudioDevice(std::string name, int deviceId, float sampleRate);
|
||||
std::vector<std::string> getStreamNameList();
|
||||
};
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <dsp/stream.h>
|
||||
#include <dsp/types.h>
|
||||
#include <vector>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
namespace dsp {
|
||||
class Splitter {
|
||||
@ -144,7 +145,7 @@ namespace dsp {
|
||||
for (int i = 0; i < outputCount; i++) {
|
||||
if (outputs[i] == stream) {
|
||||
outputs.erase(outputs.begin() + i);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -179,11 +180,13 @@ namespace dsp {
|
||||
MonoToStereo(stream<float>* input, int bufferSize) {
|
||||
_in = input;
|
||||
_bufferSize = bufferSize;
|
||||
output.init(bufferSize * 2);
|
||||
}
|
||||
|
||||
void init(stream<float>* input, int bufferSize) {
|
||||
_in = input;
|
||||
_bufferSize = bufferSize;
|
||||
output.init(bufferSize * 2);
|
||||
}
|
||||
|
||||
void start() {
|
||||
|
@ -123,6 +123,9 @@ int main() {
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
|
||||
|
||||
|
||||
int wwidth, wheight;
|
||||
glfwGetWindowSize(window, &wwidth, &wheight);
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 0));
|
||||
|
@ -204,10 +204,10 @@ void windowInit() {
|
||||
// DSB / CW and RAW modes;
|
||||
// Write a recorder
|
||||
// Adjustable "snap to grid" for each VFO
|
||||
// Bring VFO to a visible plane when changing sample rate if it's smaller
|
||||
// Fix invalid values on the min/max sliders
|
||||
// Bring VFO to a visible place when changing sample rate if it's smaller
|
||||
// Possibility to resize waterfall and menu
|
||||
// Have a proper root directory
|
||||
// Switch to double for all frequecies and bandwidth
|
||||
|
||||
// Update UI settings
|
||||
fftMin = config::config["min"];
|
||||
@ -672,10 +672,6 @@ void drawWindow() {
|
||||
ImGui::Spacing();
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Recording")) {
|
||||
ImGui::Spacing();
|
||||
}
|
||||
|
||||
if(ImGui::CollapsingHeader("Debug")) {
|
||||
ImGui::Text("Frame time: %.3f ms/frame", 1000.0f / ImGui::GetIO().Framerate);
|
||||
ImGui::Text("Framerate: %.1f FPS", ImGui::GetIO().Framerate);
|
||||
|
@ -42,6 +42,7 @@ namespace mod {
|
||||
API.setBlockSize = audio::setBlockSize;
|
||||
API.unbindFromStreamMono = audio::unbindFromStreamMono;
|
||||
API.unbindFromStreamStereo = audio::unbindFromStreamStereo;
|
||||
API.getStreamNameList = audio::getStreamNameList;
|
||||
}
|
||||
|
||||
void loadModule(std::string path, std::string name) {
|
||||
|
@ -44,6 +44,7 @@ namespace mod {
|
||||
void (*setBlockSize)(std::string name, int blockSize);
|
||||
void (*unbindFromStreamMono)(std::string name, dsp::stream<float>* stream);
|
||||
void (*unbindFromStreamStereo)(std::string name, dsp::stream<dsp::StereoFloat_t>* stream);
|
||||
std::vector<std::string> (*getStreamNameList)(void);
|
||||
|
||||
enum {
|
||||
REF_LOWER,
|
||||
|
Reference in New Issue
Block a user