From 297616c4ff4bbc7aa53c48eceeb5fa73deb0707f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Bourdeauducq?= Date: Fri, 27 Dec 2024 16:31:44 +0800 Subject: [PATCH] make more generic, independent modulation channels --- sndlock.cpp | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/sndlock.cpp b/sndlock.cpp index 27db760..162762b 100644 --- a/sndlock.cpp +++ b/sndlock.cpp @@ -11,16 +11,14 @@ #include "imgui_impl_glfw.h" #include "imgui_impl_opengl3.h" -static std::atomic shutdown_threads; -static std::atomic frequency = 440.0f; - -#define SND_SIG 1 #define SND_BITS 16 #define SND_PCHAN 2 -#define SND_RCHAN 1 #define SND_RATE 44100 #define SND_BUFLEN 4096 +static std::atomic shutdown_threads; +static std::atomic frequency[SND_PCHAN]; + static void dsp_thread() { struct sio_hdl *hdl; @@ -32,10 +30,10 @@ static void dsp_thread() return; } sio_initpar(&par); - par.sig = SND_SIG; + par.sig = 1; par.bits = SND_BITS; par.pchan = SND_PCHAN; - par.pchan = SND_RCHAN; + par.rchan = 1; par.rate = SND_RATE; par.le = SIO_LE_NATIVE; par.xrun = SIO_ERROR; @@ -56,7 +54,7 @@ static void dsp_thread() return; } - uint32_t phase = 0; + uint32_t phase_out[SND_PCHAN] = { 0 }; int16_t buf_out[SND_BUFLEN*SND_PCHAN]; size_t buf_out_idx = SND_BUFLEN*SND_PCHAN; @@ -68,13 +66,18 @@ static void dsp_thread() poll(pfd, nfds, INFTIM); int revents = sio_revents(hdl, pfd); + uint32_t ftw[SND_PCHAN]; + for(int i=0;i