-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e03f98e
commit 1f3ae27
Showing
4 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
Submodule cortex
updated
from 60878f to e74396
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { } | ||
} |