RL changes to integrate display

This commit is contained in:
Andrea Martelloni 2025-09-08 12:21:31 +01:00
parent 8d7a2c728d
commit c1ce9f1fc9
3 changed files with 72 additions and 9 deletions

View file

@ -12,8 +12,6 @@
#define APP_SRAM __not_in_flash("app") #define APP_SRAM __not_in_flash("app")
// display APP_SRAM scr;
bool core1_disable_systick = true; bool core1_disable_systick = true;
bool core1_separate_stack = true; bool core1_separate_stack = true;
@ -35,7 +33,8 @@ std::shared_ptr<InterfaceRL> APP_SRAM RLInterface;
std::shared_ptr<MIDIInOut> APP_SRAM midi_interf; std::shared_ptr<MIDIInOut> APP_SRAM midi_interf;
// Statically allocated, properly aligned storage in AUDIO_MEM for objects
alignas(PAFSynthAudioApp) char AUDIO_MEM audio_app_mem[sizeof(PAFSynthAudioApp)];
std::shared_ptr<PAFSynthAudioApp> __scratch_y("audio") audio_app; std::shared_ptr<PAFSynthAudioApp> __scratch_y("audio") audio_app;
// Inter-core communication // Inter-core communication
@ -89,7 +88,7 @@ void setup()
// Setup interface with memory barrier protection // Setup interface with memory barrier protection
WRITE_VOLATILE(interface_ready, true); WRITE_VOLATILE(interface_ready, true);
// Bind interface after ensuring it's fully initialized // Bind interface after ensuring it's fully initialized
// RLInterface->bind_RL_interface(scr); RLInterface->bind_RL_interface();
// Serial.println("Bound RL interface to MEMLNaut."); // Serial.println("Bound RL interface to MEMLNaut.");
midi_interf = std::make_shared<MIDIInOut>(); midi_interf = std::make_shared<MIDIInOut>();
@ -100,7 +99,7 @@ void setup()
midi_interf->SetNoteCallback([RLInterface] (bool noteon, uint8_t note_number, uint8_t vel_value) { midi_interf->SetNoteCallback([RLInterface] (bool noteon, uint8_t note_number, uint8_t vel_value) {
if (noteon) { if (noteon) {
uint8_t midimsg[2] = {note_number, vel_value }; uint8_t midimsg[2] = {note_number, vel_value };
queue_try_add(&audio_app->qMIDINoteOn, &midimsg); queue_try_add(&audio_app->qMIDINoteOn, &midimsg);
} }
Serial.printf("MIDI Note %d: %d\n", note_number, vel_value); Serial.printf("MIDI Note %d: %d\n", note_number, vel_value);
}); });
@ -157,10 +156,13 @@ void setup1()
// Create audio app with memory barrier protection // Create audio app with memory barrier protection
{ {
auto temp_audio_app = std::make_shared<PAFSynthAudioApp>(); PAFSynthAudioApp* audio_raw = new (audio_app_mem) PAFSynthAudioApp();
audio_raw->Setup(AudioDriver::GetSampleRate(), RLInterface);
temp_audio_app->Setup(AudioDriver::GetSampleRate(), RLInterface); // shared_ptr with custom deleter calling only the destructor (control block still allocates)
// temp_audio_app->Setup(AudioDriver::GetSampleRate(), dynamic_cast<std::shared_ptr<InterfaceBase>> (mlMode == IML ? interfaceIML : RLInterface)); auto audio_deleter = [](PAFSynthAudioApp* p) { if (p) p->~PAFSynthAudioApp(); };
std::shared_ptr<PAFSynthAudioApp> temp_audio_app(audio_raw, audio_deleter);
MEMORY_BARRIER(); MEMORY_BARRIER();
audio_app = temp_audio_app; audio_app = temp_audio_app;
MEMORY_BARRIER(); MEMORY_BARRIER();

View file

@ -27,6 +27,67 @@ public:
stereosample_t __force_inline Process(const stereosample_t x) override; stereosample_t __force_inline Process(const stereosample_t x) override;
float __force_inline ProcessLean()
{
float x1[1];
// const float trig = pulse.square(1);
paf0.play(x1, 1, baseFreq, baseFreq + (paf0_cf * baseFreq), paf0_bw * baseFreq, paf0_vib, paf0_vfr, paf0_shift, 0);
float y = x1[0];
const float freq1 = baseFreq * detune;
paf1.play(x1, 1, freq1, freq1 + (paf1_cf * freq1), paf1_bw * freq1, paf1_vib, paf1_vfr, paf1_shift, 1);
y += x1[0];
const float freq2 = freq1 * detune;
paf2.play(x1, 1, freq2, freq2 + (paf2_cf * freq2), paf2_bw * freq2, paf2_vib, paf2_vfr, paf2_shift, 1);
y += x1[0];
#ifdef ARPEGGIATOR
const float ph = phasorOsc.phasor(1);
const bool euclidNewNote = euclidean(ph, 12, euclidN, 0, 0.1f);
if(zxdetect.onZX(euclidNewNote)) {
envamp=0.8f;
freqIndex++;
if(freqIndex >= nFREQs) {
freqIndex = 0;
}
baseFreq = frequencies[freqIndex];
}else{
// constexpr float envdec = 0.2f/9000.f;
envamp -= envdec;
if (envamp < 0.f) {
envamp = 0.f;
}
}
#else
if(newNote) {
newNote = false;
envamp=0.8f;
}else{
// constexpr float envdec = 0.2f/9000.f;
envamp -= envdec;
if (envamp < 0.f) {
envamp = 0.f;
}
}
#endif)
y = y * envamp* envamp;
#ifndef ARPEGGIATOR
y *= noteVel;
#endif
float d1 = (dl1.play(y, 3500, 0.8f) * dl1mix);
// float d2 = (dl2.play(y, 15000, 0.8f) * dl2mix);
y = y + d1;// + d2;
frame++;
return y;
}
void Setup(float sample_rate, std::shared_ptr<InterfaceBase> interface) override; void Setup(float sample_rate, std::shared_ptr<InterfaceBase> interface) override;
void ProcessParams(const std::vector<float>& params) override; void ProcessParams(const std::vector<float>& params) override;

@ -1 +1 @@
Subproject commit 5998f312f887b60d13ce3437c0dca5cbf3df819b Subproject commit a85fab44b44034098cec31285bfd68f4a041b33a