|
|
@ -17,6 +17,7 @@
|
|
|
|
#include "stmdsp.hpp"
|
|
|
|
#include "stmdsp.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
#include "imgui.h"
|
|
|
|
#include "imgui.h"
|
|
|
|
|
|
|
|
#include "imgui_internal.h"
|
|
|
|
#include "ImGuiFileDialog.h"
|
|
|
|
#include "ImGuiFileDialog.h"
|
|
|
|
#include "wav.hpp"
|
|
|
|
#include "wav.hpp"
|
|
|
|
|
|
|
|
|
|
|
@ -106,7 +107,7 @@ static void drawSamplesTask(std::shared_ptr<stmdsp::device> device)
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<stmdsp::dacsample_t> chunk;
|
|
|
|
std::vector<stmdsp::dacsample_t> chunk;
|
|
|
|
|
|
|
|
|
|
|
|
if (lockDevice.try_lock_until(next)) {
|
|
|
|
if (lockDevice.try_lock_until(next)) {
|
|
|
|
chunk = m_device->continuous_read();
|
|
|
|
chunk = m_device->continuous_read();
|
|
|
|
int tries = -1;
|
|
|
|
int tries = -1;
|
|
|
|
while (chunk.empty() && m_device->is_running()) {
|
|
|
|
while (chunk.empty() && m_device->is_running()) {
|
|
|
@ -115,16 +116,16 @@ static void drawSamplesTask(std::shared_ptr<stmdsp::device> device)
|
|
|
|
std::this_thread::sleep_for(std::chrono::microseconds(20));
|
|
|
|
std::this_thread::sleep_for(std::chrono::microseconds(20));
|
|
|
|
chunk = m_device->continuous_read();
|
|
|
|
chunk = m_device->continuous_read();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lockDevice.unlock();
|
|
|
|
lockDevice.unlock();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Cooldown.
|
|
|
|
// Cooldown.
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (drawSamplesInput && popupRequestDraw) {
|
|
|
|
if (drawSamplesInput && popupRequestDraw) {
|
|
|
|
std::vector<stmdsp::dacsample_t> chunk2;
|
|
|
|
std::vector<stmdsp::dacsample_t> chunk2;
|
|
|
|
|
|
|
|
|
|
|
|
if (lockDevice.try_lock_for(std::chrono::milliseconds(1))) {
|
|
|
|
if (lockDevice.try_lock_for(std::chrono::milliseconds(1))) {
|
|
|
|
chunk2 = m_device->continuous_read_input();
|
|
|
|
chunk2 = m_device->continuous_read_input();
|
|
|
|
int tries = -1;
|
|
|
|
int tries = -1;
|
|
|
|
while (chunk2.empty() && m_device->is_running()) {
|
|
|
|
while (chunk2.empty() && m_device->is_running()) {
|
|
|
@ -133,28 +134,28 @@ static void drawSamplesTask(std::shared_ptr<stmdsp::device> device)
|
|
|
|
std::this_thread::sleep_for(std::chrono::microseconds(20));
|
|
|
|
std::this_thread::sleep_for(std::chrono::microseconds(20));
|
|
|
|
chunk2 = m_device->continuous_read_input();
|
|
|
|
chunk2 = m_device->continuous_read_input();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lockDevice.unlock();
|
|
|
|
lockDevice.unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lockDraw.lock();
|
|
|
|
lockDraw.lock();
|
|
|
|
auto i = chunk2.cbegin();
|
|
|
|
auto i = chunk2.cbegin();
|
|
|
|
for (const auto& s : chunk) {
|
|
|
|
for (const auto& s : chunk) {
|
|
|
|
drawSamplesQueue.push_back(s);
|
|
|
|
drawSamplesQueue.push_back(s);
|
|
|
|
drawSamplesInputQueue.push_back(*i++);
|
|
|
|
drawSamplesInputQueue.push_back(*i++);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lockDraw.unlock();
|
|
|
|
lockDraw.unlock();
|
|
|
|
} else if (!doLogger) {
|
|
|
|
} else if (!doLogger) {
|
|
|
|
lockDraw.lock();
|
|
|
|
lockDraw.lock();
|
|
|
|
for (const auto& s : chunk)
|
|
|
|
for (const auto& s : chunk)
|
|
|
|
drawSamplesQueue.push_back(s);
|
|
|
|
drawSamplesQueue.push_back(s);
|
|
|
|
lockDraw.unlock();
|
|
|
|
lockDraw.unlock();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
lockDraw.lock();
|
|
|
|
lockDraw.lock();
|
|
|
|
for (const auto& s : chunk) {
|
|
|
|
for (const auto& s : chunk) {
|
|
|
|
drawSamplesQueue.push_back(s);
|
|
|
|
drawSamplesQueue.push_back(s);
|
|
|
|
logSamplesFile << s << '\n';
|
|
|
|
logSamplesFile << s << '\n';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lockDraw.unlock();
|
|
|
|
lockDraw.unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::this_thread::sleep_until(next);
|
|
|
|
std::this_thread::sleep_until(next);
|
|
|
@ -193,7 +194,7 @@ static void feedSigGenTask(std::shared_ptr<stmdsp::device> device)
|
|
|
|
|
|
|
|
|
|
|
|
if (lockDevice.try_lock_until(next)) {
|
|
|
|
if (lockDevice.try_lock_until(next)) {
|
|
|
|
m_device->siggen_upload(wavBuf.data(), wavBuf.size());
|
|
|
|
m_device->siggen_upload(wavBuf.data(), wavBuf.size());
|
|
|
|
lockDevice.unlock();
|
|
|
|
lockDevice.unlock();
|
|
|
|
std::this_thread::sleep_until(next);
|
|
|
|
std::this_thread::sleep_until(next);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -485,29 +486,24 @@ void deviceRenderMenu()
|
|
|
|
deviceAlgorithmUpload();
|
|
|
|
deviceAlgorithmUpload();
|
|
|
|
if (ImGui::MenuItem("Unload algorithm", nullptr, false, isConnected && !isRunning))
|
|
|
|
if (ImGui::MenuItem("Unload algorithm", nullptr, false, isConnected && !isRunning))
|
|
|
|
deviceAlgorithmUnload();
|
|
|
|
deviceAlgorithmUnload();
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::Separator();
|
|
|
|
ImGui::Separator();
|
|
|
|
if (ImGui::Checkbox("Measure Code Time", &measureCodeTime)) {
|
|
|
|
if (!isConnected || isRunning)
|
|
|
|
if (!isConnected)
|
|
|
|
ImGui::PushDisabled();
|
|
|
|
measureCodeTime = false;
|
|
|
|
ImGui::Checkbox("Measure Code Time", &measureCodeTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ImGui::Checkbox("Draw samples", &drawSamples)) {
|
|
|
|
if (ImGui::Checkbox("Draw samples", &drawSamples)) {
|
|
|
|
if (isConnected) {
|
|
|
|
if (drawSamples)
|
|
|
|
if (drawSamples)
|
|
|
|
popupRequestDraw = true;
|
|
|
|
popupRequestDraw = true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
drawSamples = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ImGui::Checkbox("Log results...", &logResults)) {
|
|
|
|
if (ImGui::Checkbox("Log results...", &logResults)) {
|
|
|
|
if (isConnected) {
|
|
|
|
if (logResults)
|
|
|
|
if (logResults)
|
|
|
|
popupRequestLog = true;
|
|
|
|
popupRequestLog = true;
|
|
|
|
else if (logSamplesFile.is_open())
|
|
|
|
else if (logSamplesFile.is_open())
|
|
|
|
logSamplesFile.close();
|
|
|
|
logSamplesFile.close();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
logResults = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isConnected || isRunning)
|
|
|
|
|
|
|
|
ImGui::PopDisabled();
|
|
|
|
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Set buffer size...", nullptr, false, isConnected && !isRunning)) {
|
|
|
|
if (ImGui::MenuItem("Set buffer size...", nullptr, false, isConnected && !isRunning)) {
|
|
|
|
popupRequestBuffer = true;
|
|
|
|
popupRequestBuffer = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -575,7 +571,7 @@ void deviceConnect()
|
|
|
|
m_device.reset(new stmdsp::device(devices.front()));
|
|
|
|
m_device.reset(new stmdsp::device(devices.front()));
|
|
|
|
} catch (...) {
|
|
|
|
} catch (...) {
|
|
|
|
log("Failed to connect (check permissions?).");
|
|
|
|
log("Failed to connect (check permissions?).");
|
|
|
|
m_device.reset();
|
|
|
|
m_device.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_device) {
|
|
|
|
if (m_device) {
|
|
|
|