Reorganized file structure to allow building Arduino project
This commit is contained in:
+33
-1
@@ -2,7 +2,33 @@
|
||||
#define SYNTH_ENGINE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
#include <pico/mutex.h>
|
||||
class SynthMutex {
|
||||
public:
|
||||
SynthMutex() { mutex_init(&mtx); }
|
||||
void lock() { mutex_enter_blocking(&mtx); }
|
||||
void unlock() { mutex_exit(&mtx); }
|
||||
private:
|
||||
mutex_t mtx;
|
||||
};
|
||||
template <typename Mutex>
|
||||
class SynthLockGuard {
|
||||
public:
|
||||
explicit SynthLockGuard(Mutex& m) : m_mutex(m) { m_mutex.lock(); }
|
||||
~SynthLockGuard() { m_mutex.unlock(); }
|
||||
SynthLockGuard(const SynthLockGuard&) = delete;
|
||||
SynthLockGuard& operator=(const SynthLockGuard&) = delete;
|
||||
private:
|
||||
Mutex& m_mutex;
|
||||
};
|
||||
#else
|
||||
#include <mutex>
|
||||
using SynthMutex = std::mutex;
|
||||
template <typename Mutex>
|
||||
using SynthLockGuard = std::lock_guard<Mutex>;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @class SynthEngine
|
||||
@@ -85,9 +111,15 @@ public:
|
||||
|
||||
static const int GRID_W = 12;
|
||||
static const int GRID_H = 12;
|
||||
|
||||
static const size_t SERIALIZED_GRID_SIZE = GRID_W * GRID_H * 3;
|
||||
void exportGrid(uint8_t* buffer);
|
||||
void importGrid(const uint8_t* buffer);
|
||||
void loadPreset(int preset);
|
||||
void clearGrid();
|
||||
|
||||
GridCell grid[GRID_W][GRID_H];
|
||||
std::mutex gridMutex;
|
||||
SynthMutex gridMutex;
|
||||
|
||||
// Helper to process one sample step of the grid
|
||||
float processGridStep();
|
||||
|
||||
Reference in New Issue
Block a user