-
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
3eb2a2b
commit c6ec779
Showing
4 changed files
with
60 additions
and
10 deletions.
There are no files selected for viewing
Submodule cortex
updated
from 88f3dd to e4fc16
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 = Oscillator | ||
|
||
# Source Files | ||
CPP_SOURCES = oscillator.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,39 @@ | ||
#include "daisy_patch_sm.h" | ||
#include "cortex.h" | ||
|
||
using namespace daisy; | ||
using namespace patch_sm; | ||
|
||
DaisyPatchSM hardware; | ||
cortex::Oscillator oscillator(cortex::DEFAULT_CONTEXT, 220.0f); | ||
|
||
void AudioCallback(AudioHandle::InterleavingInputBuffer in, | ||
AudioHandle::InterleavingOutputBuffer out, | ||
size_t size) | ||
{ | ||
hardware.ProcessAllControls(); | ||
|
||
float coarse_knob = hardware.GetAdcValue(CV_1); | ||
float coarse = cortex::map(coarse_knob, 36.f, 96.f); | ||
|
||
float voct_cv = hardware.GetAdcValue(CV_5); | ||
float voct = cortex::map(voct_cv, 0.f, 60.f); | ||
|
||
float midi_nn = cortex::clamp(coarse + voct, 0.f, 127.f); | ||
float freq = cortex::midi_to_frequency(midi_nn); | ||
|
||
oscillator.SetFrequency(freq); | ||
|
||
for (size_t idx = 0; idx < size; idx += 2) { | ||
auto sample = (float) oscillator.Generate(); | ||
out[idx] = sample; | ||
out[idx + 1] = sample; | ||
} | ||
} | ||
|
||
int main(void) { | ||
hardware.Init(); | ||
hardware.StartAudio(AudioCallback); | ||
|
||
while(1) {} | ||
} |
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