From dd78891783bd42727a3612dd66c93ea7f8d38594 Mon Sep 17 00:00:00 2001 From: chriskiefer Date: Sun, 22 Feb 2026 11:39:27 +0000 Subject: [PATCH] start of break|| --- MEMLNaut-NISPS.ino | 4 +- modes/AudioApps/BreakOrAudioApp.hpp | 97 ++++++++++++++++++++++++ modes/MEMLNautModeBreakOr.hpp | 111 ++++++++++++++++++++++++++++ modes/MEMLNautModeChannelStrip.hpp | 11 --- modes/MEMLNautModePAFSynth.hpp | 11 --- src/memllib | 2 +- src/memlp | 2 +- 7 files changed, 213 insertions(+), 25 deletions(-) create mode 100644 modes/AudioApps/BreakOrAudioApp.hpp create mode 100644 modes/MEMLNautModeBreakOr.hpp diff --git a/MEMLNaut-NISPS.ino b/MEMLNaut-NISPS.ino index ffe01f8..d6460cd 100644 --- a/MEMLNaut-NISPS.ino +++ b/MEMLNaut-NISPS.ino @@ -23,11 +23,13 @@ #include "modes/MEMLNautModeChannelStrip.hpp" #include "modes/MEMLNautModeSoundAnalysisMIDI.hpp" #include "modes/MEMLNautModeXIASRI.hpp" +#include "modes/MEMLNautModeBreakOr.hpp" //hook up the memlnaut mode // #define MEMLNAUT_MODE_TYPE MEMLNautModeSoundAnalysisMIDI -#define MEMLNAUT_MODE_TYPE MEMLNautModeXIASRI +// #define MEMLNAUT_MODE_TYPE MEMLNautModeXIASRI +#define MEMLNAUT_MODE_TYPE MEMLNautModeBreakOr // #define MEMLNAUT_MODE_TYPE MEMLNautModeChannelStrip // #define MEMLNAUT_MODE_TYPE MEMLNautModePAFSynth diff --git a/modes/AudioApps/BreakOrAudioApp.hpp b/modes/AudioApps/BreakOrAudioApp.hpp new file mode 100644 index 0000000..726158c --- /dev/null +++ b/modes/AudioApps/BreakOrAudioApp.hpp @@ -0,0 +1,97 @@ +#ifndef __BREAKOR_AUDIO_APP_HPP__ +#define __BREAKOR_AUDIO_APP_HPP__ + +#include "../../src/memllib/audio/AudioAppBase.hpp" +#include "../../src/memllib/synth/maximilian.h" + +#include +#include +#include // Added for std::shared_ptr + +#include "../../src/memllib/interface/InterfaceBase.hpp" // Added missing include + +#include + +#include "../../voicespaces/VoiceSpaces.hpp" + + + +template + +class BreakOrAudioApp : public AudioAppBase +{ +public: + static constexpr size_t kN_Params = NPARAMS; + static constexpr size_t nVoiceSpaces=0; + + std::array, nVoiceSpaces> voiceSpaces; + + VoiceSpaceFn currentVoiceSpace; + + std::array getVoiceSpaceNames() { + std::array names; + for(size_t i=0; i < voiceSpaces.size(); i++) { + names[i] = voiceSpaces[i].name; + } + return names; + } + + void setVoiceSpace(size_t i) { + if (i < voiceSpaces.size()) { + currentVoiceSpace = voiceSpaces[i].mappingFunction; + } + } + + BreakOrAudioApp() : AudioAppBase() { + // currentVoiceSpace = voiceSpaces[0].mappingFunction; + + }; + + bool __force_inline euclidean(float phase, const size_t n, const size_t k, const size_t offset, const float pulseWidth) + { + // Euclidean function + const float fi = phase * n; + int i = static_cast(fi); + const float rem = fi - i; + if (i == n) + { + i--; + } + const int idx = ((i + n - offset) * k) % n; + return (idx < k && rem < pulseWidth) ? 1 : 0; + } + + stereosample_t __force_inline Process(const stereosample_t x) override + { + stereosample_t ret { 0.f,0.f }; + return ret; + } + + void Setup(float sample_rate, std::shared_ptr interface) override + { + AudioAppBase::Setup(sample_rate, interface); + maxiSettings::sampleRate = sample_rate; + sampleRatef = static_cast(sample_rate); + } + + + void loop() override { + AudioAppBase::loop(); + } + + void ProcessParams(const std::array& params) + { + firstParamsReceived = true; + // currentVoiceSpace(params); + } + + + +protected: + + float sampleRatef; + bool firstParamsReceived = false; +}; + +#endif // __BREAKOR_AUDIO_APP_HPP__ + diff --git a/modes/MEMLNautModeBreakOr.hpp b/modes/MEMLNautModeBreakOr.hpp new file mode 100644 index 0000000..f79c701 --- /dev/null +++ b/modes/MEMLNautModeBreakOr.hpp @@ -0,0 +1,111 @@ +#ifndef MEMLNAUT_MODE_RHYTHM_BOX_HPP +#define MEMLNAUT_MODE_RHYTHM_BOX_HPP + +//Break|| + +#include "../src/memllib/interface/MIDIInOut.hpp" +#include "../src/memllib/hardware/memlnaut/MEMLNaut.hpp" +#include "AudioApps/BreakOrAudioApp.hpp" +#include "../src/memllib/examples/InterfaceRL.hpp" +#include "../src/memllib/PicoDefs.hpp" +#include "MEMLNautMode.hpp" +#include +#include + +class MEMLNautModeBreakOr { +public: + constexpr static size_t kN_InputParams = 4; // joystick x, y, rotate + + inline static BreakOrAudioApp<> audioAppBreakOr; + std::array::nVoiceSpaces> voiceSpaceList; + + InterfaceRL interface; + std::shared_ptr interfacePtr; + + void setupInterface() { + interface.setup(kN_InputParams, BreakOrAudioApp<>::kN_Params); + interface.bindInterface(InterfaceRL::INPUT_MODES::JOYSTICK, true); + interfacePtr = make_non_owning(interface); + } + + String getHelpTitle() { + return "Break||"; + } + + __force_inline stereosample_t process(stereosample_t x) { + return audioAppBreakOr.Process(x); + } + + void setupAudio(float sample_rate) { + audioAppBreakOr.Setup(sample_rate, interfacePtr); + voiceSpaceList = audioAppBreakOr.getVoiceSpaceNames(); + } + + __force_inline void loop() { + audioAppBreakOr.loop(); + } + + std::shared_ptr midi_interf; + + void setupMIDI(std::shared_ptr new_midi_interf) { + midi_interf = new_midi_interf; + midi_interf->Setup(16); + midi_interf->SetMIDISendChannel(1); + interface.bindMIDI(midi_interf); + } + + void addViews() { + // std::shared_ptr voiceSpaceSelectView; + // voiceSpaceSelectView = std::make_shared("Voice Spaces"); + + // MEMLNaut::Instance()->disp->InsertViewAfter(interface.rlStatsView, voiceSpaceSelectView); + // voiceSpaceSelectView->setOptions(voiceSpaceList); //set by core 1 on startup + // voiceSpaceSelectView->setNewVoiceCallback( + // [this](size_t idx) { + // audioAppPAFSynth.setVoiceSpace(idx); + // }); + + + }; + + inline void processAnalysisParams() {} + + void analyse(stereosample_t) {} + +}; + + +/* + // BODY + Value result = Value::nil(); + + auto ratios = args[0].as_sequential(); + const auto pulseWidth = args[1].as_float(); + const auto phase = args[2].as_float(); + + double trig = 0; + double ratioSum = 0; + for (Value v : ratios) + { + ratioSum += v.as_float(); + } + double phaseAdj = ratioSum * phase; + double accumulatedSum = 0; + double lastAccumulatedSum = 0; + for (Value v : ratios) + { + accumulatedSum += v.as_float(); + if (phaseAdj <= accumulatedSum) + { + // check pulse width + double beatPhase = (phaseAdj - lastAccumulatedSum) / + (accumulatedSum - lastAccumulatedSum); + trig = beatPhase <= pulseWidth; + break; + } + lastAccumulatedSum = accumulatedSum; + } + result = Value(trig); +*/ + +#endif // MEMLNAUT_MODE_RHYTHM_BOX_HPP \ No newline at end of file diff --git a/modes/MEMLNautModeChannelStrip.hpp b/modes/MEMLNautModeChannelStrip.hpp index da9caeb..e9eefe4 100644 --- a/modes/MEMLNautModeChannelStrip.hpp +++ b/modes/MEMLNautModeChannelStrip.hpp @@ -26,17 +26,6 @@ public: String getHelpTitle() { return "Channel Strip Mode"; } - // size_t getNParams() { - // return ChannelStripAudioApp<>::kN_Params; - // } - - // void setVoiceSpace(size_t i) { - // audioAppChannelStrip.setVoiceSpace(i); - // } - - // std::span getVoiceSpaceList() { - // return voiceSpaceList; - // } __force_inline stereosample_t process(stereosample_t x) { return audioAppChannelStrip.Process(x); diff --git a/modes/MEMLNautModePAFSynth.hpp b/modes/MEMLNautModePAFSynth.hpp index 5235538..9249943 100644 --- a/modes/MEMLNautModePAFSynth.hpp +++ b/modes/MEMLNautModePAFSynth.hpp @@ -29,17 +29,6 @@ public: String getHelpTitle() { return "PAF Synth Mode"; } - // size_t getNParams() { - // return PAFSynthAudioApp<>::kN_Params; - // } - - // void setVoiceSpace(size_t i) { - // audioAppPAFSynth.setVoiceSpace(i); - // } - - // std::span getVoiceSpaceList() { - // return voiceSpaceList; - // } __force_inline stereosample_t process(stereosample_t x) { return audioAppPAFSynth.Process(x); diff --git a/src/memllib b/src/memllib index 42a937b..5bae63d 160000 --- a/src/memllib +++ b/src/memllib @@ -1 +1 @@ -Subproject commit 42a937b24d79ec962acf03b55090b022d47176df +Subproject commit 5bae63daa89332f333ace163818b23308cdf3518 diff --git a/src/memlp b/src/memlp index bf52e8e..5d2935d 160000 --- a/src/memlp +++ b/src/memlp @@ -1 +1 @@ -Subproject commit bf52e8e279343312348a7056b538861cc81ef462 +Subproject commit 5d2935d6420f5e6ab0ad8321bab5125cce2fb500