From da171fad17e220e36f7fd9f1e68f36eaeb219ea6 Mon Sep 17 00:00:00 2001 From: Tobias Hienzsch Date: Thu, 18 May 2023 20:39:30 +0200 Subject: [PATCH] [kyma] Add second osc --- src/kyma/main.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/kyma/main.cpp b/src/kyma/main.cpp index ed35f13..54fd1fb 100644 --- a/src/kyma/main.cpp +++ b/src/kyma/main.cpp @@ -5,12 +5,13 @@ #include "daisy_patch_sm.h" -static constexpr auto BLOCK_SIZE = 4U; +static constexpr auto BLOCK_SIZE = 16U; static constexpr auto SAMPLE_RATE = 96'000.0F; -auto adsr = mc::ADSR{}; -auto oscillator = mc::Oscillator{}; -auto patch = daisy::patch_sm::DaisyPatchSM{}; +auto adsr = mc::ADSR{}; +auto oscA = mc::Oscillator{}; +auto oscB = mc::Oscillator{}; +auto patch = daisy::patch_sm::DaisyPatchSM{}; auto audioCallback(daisy::AudioHandle::InputBuffer /*in*/, daisy::AudioHandle::OutputBuffer out, size_t size) -> void { @@ -25,25 +26,26 @@ auto audioCallback(daisy::AudioHandle::InputBuffer /*in*/, daisy::AudioHandle::O auto const noteNumber = mc::clamp(coarse + voct, 0.0F, 127.0F); auto const freq = mc::noteToFrequency(noteNumber); - oscillator.setFrequency(freq); + oscA.setFrequency(freq); + oscB.setFrequency(220.0F); + adsr.setAttack(0.025F * SAMPLE_RATE); adsr.setRelease(1.5F * SAMPLE_RATE); for (size_t i = 0; i < size; ++i) { - auto* const leftOut = out[0]; - auto* const rightOut = out[1]; - - auto const sample = oscillator(); - leftOut[i] = sample; - rightOut[i] = sample; + OUT_L[i] = oscA(); + OUT_R[i] = oscB(); } } auto main() -> int { - oscillator.setShape(mc::OscillatorShape::Sine); - oscillator.setSampleRate(SAMPLE_RATE); + oscA.setShape(mc::OscillatorShape::Sine); + oscA.setSampleRate(SAMPLE_RATE); + + oscB.setShape(mc::OscillatorShape::Square); + oscB.setSampleRate(SAMPLE_RATE); patch.Init(); patch.SetAudioSampleRate(SAMPLE_RATE);