-#linux: CXXFILES += source/serial/src/impl/unix.cc source/serial/src/impl/list_ports/list_ports_unix.cc
-#linux: LDFLAGS = -lSDL2 -lGL -lpthread
-
-#CROSS = x86_64-w64-mingw32-
-#CXX = $(CROSS)g++
+ CXX = g++
+
CXXFILES := \
source/serial/src/serial.cc \
- source/serial/src/impl/unix.cc \
- source/serial/src/impl/list_ports/list_ports_linux.cc \
- source/serial/src/impl/win.cc \
- source/serial/src/impl/list_ports/list_ports_win.cc \
$(wildcard source/imgui/backends/*.cpp) \
$(wildcard source/imgui/*.cpp) \
$(wildcard source/stmdsp/*.cpp) \
$(wildcard source/*.cpp)
--OFILES := $(patsubst %.cc, %.o, $(patsubst %.cpp, %.o, $(CXXFILES)))
-OUTPUT := stmdspgui.exe
-
+ CXXFLAGS := -std=c++20 -O2 \
+ -Isource -Isource/imgui -Isource/stmdsp -Isource/serial/include \
- -Wall -Wextra -pedantic \
- -DSTMDSP_WIN32 -Wa,-mbig-obj -DSTMDSP_DISABLE_FORMULAS
++ -Wall -Wextra -pedantic #-DSTMDSP_DISABLE_FORMULAS
++
++ifeq ($(OS),Windows_NT)
++CXXFILES += source/serial/src/impl/win.cc \
++ source/serial/src/impl/list_ports/list_ports_win.cc
++CXXFLAGS += -DSTMDSP_WIN32 -Wa,-mbig-obj
+ LDFLAGS = -mwindows -lSDL2 -lopengl32 -lsetupapi -lole32
++OUTPUT := stmdspgui.exe
++else
++CXXFILES += source/serial/src/impl/unix.cc \
++ source/serial/src/impl/list_ports/list_ports_unix.cc
++LDFLAGS = -lSDL2 -lGL -lpthread
+OUTPUT := stmdspgui
++endif
+
- #CXXFLAGS := -std=c++20 -O2 \
- # -Isource -Isource/imgui -Isource/stmdsp -Isource/serial/include
- CXXFLAGS := -std=c++20 -ggdb -O0 -g3 \
- -Isource -Isource/imgui -Isource/stmdsp -Isource/serial/include \
- -Wall -Wextra -pedantic
++OFILES := $(patsubst %.cc, %.o, $(patsubst %.cpp, %.o, $(CXXFILES)))
all: $(OUTPUT)
logSamplesFile << s << '\n';
}
} else {
- // Device must be busy, cooldown.
- std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ // Device must be busy, back off for a bit.
+ std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
- if (drawSamplesInput) {
- if (lockDevice.try_lock_for(std::chrono::milliseconds(1))) {
- const auto chunk2 = tryReceiveChunk(device,
- std::mem_fn(&stmdsp::device::continuous_read_input));
- lockDevice.unlock();
-
- addToQueue(drawSamplesInputQueue, chunk2);
- }
- }
-
std::this_thread::sleep_until(next);
}
}
std::size_t pullFromQueue(
std::deque<stmdsp::dacsample_t>& queue,
-- CircularBuffer<std::vector, stmdsp::dacsample_t>& circ,
-- double timeframe)
++ CircularBuffer<std::vector, stmdsp::dacsample_t>& circ)
{
+ // We know how big the circular buffer should be to hold enough samples to
+ // fill the current draw samples view.
+ // If the given buffer does not match this size, notify the caller.
+ // TODO this could be done better... drawSamplesBufferSize should be a GUI-
+ // only thing.
if (circ.size() != drawSamplesBufferSize)
return drawSamplesBufferSize;
return 0;
}
+ /**
+ * Pulls a render frame's worth of samples from the draw samples queue, adding
+ * the samples to the given buffer.
+ */
std::size_t pullFromDrawQueue(
-- CircularBuffer<std::vector, stmdsp::dacsample_t>& circ,
-- double timeframe)
++ CircularBuffer<std::vector, stmdsp::dacsample_t>& circ)
{
-- return pullFromQueue(drawSamplesQueue, circ, timeframe);
++ return pullFromQueue(drawSamplesQueue, circ);
}
std::size_t pullFromInputDrawQueue(
-- CircularBuffer<std::vector, stmdsp::dacsample_t>& circ,
-- double timeframe)
++ CircularBuffer<std::vector, stmdsp::dacsample_t>& circ)
{
-- return pullFromQueue(drawSamplesInputQueue, circ, timeframe);
++ return pullFromQueue(drawSamplesInputQueue, circ);
}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
window = SDL_CreateWindow("stmdsp gui",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
- 550, 700,
- WINDOW_WIDTH, WINDOW_HEIGHT,
- SDL_WINDOW_OPENGL /*| SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI*/);
++ 640, 700,
+ SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE /*| SDL_WINDOW_ALLOW_HIGHDPI*/);
if (window == nullptr) {
puts("Error: Could not create the window!");
void deviceLoadLogFile(const std::string& file);
void deviceSetSampleRate(unsigned int index);
void deviceSetInputDrawing(bool enabled);
-void deviceStart(bool measureCodeTime, bool logResults, bool drawSamples);
+void deviceStart(bool logResults, bool drawSamples);
+void deviceStartMeasurement();
void deviceUpdateDrawBufferSize(double timeframe);
std::size_t pullFromDrawQueue(
-- CircularBuffer<std::vector, stmdsp::dacsample_t>& circ,
-- double timeframe);
++ CircularBuffer<std::vector, stmdsp::dacsample_t>& circ);
std::size_t pullFromInputDrawQueue(
-- CircularBuffer<std::vector, stmdsp::dacsample_t>& circ,
-- double timeframe);
++ CircularBuffer<std::vector, stmdsp::dacsample_t>& circ);
static std::string sampleRatePreview = "?";
static bool measureCodeTime = false;
yMinMax = std::min(4095u, (yMinMax << 1) | 1);
}
-- auto newSize = pullFromDrawQueue(bufferCirc, drawSamplesTimeframe);
++ auto newSize = pullFromDrawQueue(bufferCirc);
if (newSize > 0) {
buffer.resize(newSize);
bufferCirc = CircularBuffer(buffer);
-- pullFromDrawQueue(bufferCirc, drawSamplesTimeframe);
++ pullFromDrawQueue(bufferCirc);
}
if (drawSamplesInput) {
-- auto newSize = pullFromInputDrawQueue(bufferInputCirc, drawSamplesTimeframe);
++ auto newSize = pullFromInputDrawQueue(bufferInputCirc);
if (newSize > 0) {
bufferInput.resize(newSize);
bufferInputCirc = CircularBuffer(bufferInput);
-- pullFromInputDrawQueue(bufferInputCirc, drawSamplesTimeframe);
++ pullFromInputDrawQueue(bufferInputCirc);
}
}
static ImFont *fontSans = nullptr;
static ImFont *fontMono = nullptr;
+template<bool first = false>
static void renderWindow();
- int main(int, char **)
+ int main(int argc, char *argv[])
{
if (!guiInitialize())
return -1;