Skip to content

Commit

Permalink
Expander Fixups, Clock Fixes (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
isivisi committed Nov 3, 2023
1 parent 63c0560 commit 86c4b47
Show file tree
Hide file tree
Showing 5 changed files with 354 additions and 34 deletions.
214 changes: 214 additions & 0 deletions res/SmallPort.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/smute/smute.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions src/questionableModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <sstream>
#include <array>
#include <vector>
#include <mutex>
#include <queue>

// simple variable that has a dirty state
// designed for native types
Expand Down Expand Up @@ -127,6 +129,35 @@ struct PolyphonicValue {

};

// Threadsafe queue that doesn't lock on read, only write
template <typename T>
struct ThreadQueue {
std::mutex mut;
std::queue<T> queue[2];
bool activeQueue = false;

void push(T& obj) {
std::lock_guard<std::mutex> guard(mut);
queue[!activeQueue] = queue[activeQueue];
queue[!activeQueue].push(obj);
activeQueue = !activeQueue;
}

void pop() {
std::lock_guard<std::mutex> guard(mut);
queue[!activeQueue] = queue[activeQueue];
queue[!activeQueue].pop();
activeQueue = !activeQueue;
}

// limited functionallity
T& front() { return queue[activeQueue].front(); }
T& back() { return queue[activeQueue].back(); }
bool empty() { return queue[activeQueue].empty(); }
size_t size() { return queue[activeQueue].size(); }

};

struct QuestionableModule : Module {
bool supportsSampleRateOverride = false;
bool supportsThemes = true;
Expand Down Expand Up @@ -331,6 +362,11 @@ struct Resizable : T {

bool hasUpdatedBox = false;

Resizable() {
scale = 1.f;
centered = true;
}

Resizable(float scale, bool centered) {
this->scale = scale;
this->centered = centered;
Expand Down

0 comments on commit 86c4b47

Please sign in to comment.