Skip to content

Commit

Permalink
Add fix header path
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwellmattryan committed Oct 20, 2024
1 parent e03f98e commit 1f3ae27
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cortex
18 changes: 18 additions & 0 deletions patches/init/lotus/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Project Name
TARGET = Lotus

# Source Files
CPP_SOURCES = lotus.cpp

# Library Directories
LIBDAISY_DIR = ../../../vendor/libDaisy
LIBCORTEX_DIR = ../../../lib/cortex

# Include Cortex library
C_INCLUDES += -I$(LIBCORTEX_DIR)/src
LIBS += -lcortex
LIBDIR += -L$(LIBCORTEX_DIR)/target/release

# Include Daisy library Makefile
SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core
include $(SYSTEM_FILES_DIR)/Makefile
18 changes: 18 additions & 0 deletions patches/init/lotus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Lotus

> Emitting a harmonic meditation 🪷
_Lotus_ is a rich binaural oscillator patch, named after the Lotus flower which symbolizes spiritual
awakening and harmony. It's connection to meditative practices can loosely be connected to the dual-frequency
harmony of binaural beats.

## Controls

| Control | Name | Description |
|----------|-----------|---------------------------------------------------------------------------------------------------------|
| **CV_1** | Tune | The leader oscillator's running frequency (100-400Hz) |
| **CV_2** | Detune | The speed of the binaural beat, detuning the follower oscillator within 20Hz from the leader oscillator |
| **CV_3** | LFO Rate | The speed at which the follower oscillator changes frequency |
| **CV_4** | LFO Depth | The amount in which the LFO rate affects the follower oscillator's frequency |
| **B8** | Sync | Syncs the two oscillators together when turned on |

64 changes: 64 additions & 0 deletions patches/init/lotus/lotus.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "cortex.h"
#include "daisy_patch_sm.h"

using namespace daisy;
using namespace patch_sm;

DaisyPatchSM hardware;
Switch toggle;

cortex::Oscillator leader;
cortex::Oscillator follower;
cortex::Oscillator lfo;

const float MAX_DETUNE_AMOUNT = 20.0f;

void AudioCallback(AudioHandle::InterleavingInputBuffer in, AudioHandle::InterleavingOutputBuffer out, size_t size)
{
hardware.ProcessAllControls();
toggle.Debounce();

float tuneKnob = hardware.GetAdcValue(CV_1);
float detuneKnob = hardware.GetAdcValue(CV_2);
float lfoRateKnob = hardware.GetAdcValue(CV_3);
float lfoDepthKnob = hardware.GetAdcValue(CV_4);

bool isSyncOn = toggle.Pressed();
if (isSyncOn) {
leader.AttachFollower(&follower);
} else {
leader.DetachFollower();
}

float leaderFrequency = cortex::map(tuneKnob, 65.406f, 261.626f, cortex::Mapping::LOG);
leader.SetFrequency(leaderFrequency);

float followerDetune = MAX_DETUNE_AMOUNT * ((detuneKnob * 2.0f) - 1.0f);
follower.SetFrequency(leaderFrequency - followerDetune);

float lfoRate = (lfoRateKnob * 1000.0f) + 0.1f;
lfo.SetFrequency(lfoRate);

for (size_t idx = 0; idx < size; idx += 2) {
float leaderSample = leader.Generate();
float followerSample = follower.Generate();

float lfoMod = lfoDepthKnob * lfo.Generate();
float modulatedLeaderFrequency = leaderFrequency + (MAX_DETUNE_AMOUNT * lfoMod);
leader.SetFrequency(modulatedLeaderFrequency + (MAX_DETUNE_AMOUNT * lfoMod));
follower.SetFrequency(modulatedLeaderFrequency - followerDetune);

out[idx] = leaderSample;
out[idx + 1] = followerSample;
}

hardware.WriteCvOut(2, 5.0f * out[0]);
}

int main(void)
{
hardware.Init();
toggle.Init(hardware.B8);
hardware.StartAudio(AudioCallback);
while (1) { }
}

0 comments on commit 1f3ae27

Please sign in to comment.