Skip to content

Commit

Permalink
devsync 5e1e08e
Browse files Browse the repository at this point in the history
  • Loading branch information
eh2k committed Dec 8, 2024
1 parent 4b66d27 commit 6e922fe
Show file tree
Hide file tree
Showing 82 changed files with 4,508 additions and 88 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<summary><b>ChangeLog</b></summary>

````
== 2024-12-07
* Bugfix:
* EnvFollower - IO-page AUX input
* Enhancements:
* EnvFollower - mode Follower, Vactrol (based on MU Streams)
== 2024-11-30
* Bugfix:
* Crash on patch saving/restoring (#97)
Expand Down
Binary file added app/CV/EnvFollower.bin
Binary file not shown.
134 changes: 134 additions & 0 deletions app/CV/EnvFollower.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// Copyright (C)2021 - E.Heidt
//
// Author: E.Heidt ([email protected])
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// See http://creativecommons.org/licenses/MIT/ for more information.
//

#include "../squares-and-circles-api.h"
#include <algorithm>
#include "../../lib/streams/follower.h"
#include "../../lib/streams/vactrol.h"
#include "../../lib/streams/audio_cv_meter.h"

streams::Follower _follower;
streams::Vactrol _vactrol;
streams::AudioCvMeter _meter;

int32_t attack_ = 0;
int32_t decay_ = 0;
int32_t mode_ = 0;

namespace gfx
{
uint8_t i = 0;
int8_t scope[128] = {};
void drawScope(int x0, int y)
{
for (int x = x0; x < 127; x++)
{
if (x % 3 == 0)
gfx::setPixel(x, y);
gfx::drawLine(x, y - scope[(i + x) % 128], x + 1, y - scope[(1 + i + x) % 128]);
}
}

void push_scope(int8_t y)
{
scope[i++ % 128] = y;
if (i > 128)
i = 0;
}
}

const char *mode_names[] = {
"Follower",
"Vactrol",
""};

void engine::setup()
{
engine::addParam("Attack", &attack_, 0, UINT16_MAX);
engine::addParam("MODE", &mode_, 0, 1, mode_names);
engine::addParam("Decay", &decay_, 0, INT16_MAX);
decay_ = INT16_MAX / 2;
engine::setMode(ENGINE_MODE_COMPACT | ENGINE_MODE_CV_OUT);

_meter.Init();
_follower.Init();
_vactrol.Init();
}

void engine::process()
{
auto inputL = engine::inputBuffer<0>();
auto outputL = engine::outputBuffer_i16<0>();

uint16_t gain;
uint16_t freq;

int32_t paramters[3] = {};
int32_t globals[3] = {};
globals[0] = attack_;
globals[2] = decay_;
paramters[1] = 0;

if (mode_ == 0)
{
_follower.Configure(false, paramters, globals);
for (int i = 0; i < FRAME_BUFFER_SIZE; i++)
{
_follower.Process(0, inputL[i] * INT16_MAX, &gain, &freq);
outputL[i] = gain >> 2; //_follower.process(inputL[i]) * 10.f;
}
}
else
{
_vactrol.Configure(false, paramters, globals);
for (int i = 0; i < FRAME_BUFFER_SIZE; i++)
{
_vactrol.Process(0, inputL[i] * INT16_MAX, &gain, &freq);
outputL[i] = gain >> 2; //_follower.process(inputL[i]) * 10.f;
}
}

_meter.Process(inputL[0] * INT16_MAX);

if ((engine::t() % 50) == 0)
{
int8_t v = outputL[0] >> 9;
CONSTRAIN(v, 0, 14);
gfx::push_scope(v);
}
}

void engine::draw()
{
gfx::drawScope(64, 58);
gfx::drawRect(64, 44, 64, 15);
gfx::drawRect(0, 44, 63, 15);
gfx::fillRect(2, 46, (_meter.peak() >> 8), 11);
}

#include "../../lib/streams/svf.cc"
#include "../../lib/streams/follower.cc"
#include "../../lib/streams/vactrol.cc"
#include "../../lib/streams/resources.cc"
Binary file added app/CV/EnvGen.bin
Binary file not shown.
139 changes: 139 additions & 0 deletions app/CV/EnvGen.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// Copyright (C)2021 - E.Heidt
//
// Author: E.Heidt ([email protected])
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// See http://creativecommons.org/licenses/MIT/ for more information.
//

// ENGINE_NAME:CV/EnvGen_AD;CV/EnvGen_ADSR
// build_flags: -fno-inline -mfloat-abi=hard -mfpu=fpv5-d16

#include "../squares-and-circles-api.h"
#include "lib/peaks/modulations/multistage_envelope.h"

#include "lib/peaks/modulations/multistage_envelope.cc"
#include "lib/peaks/resources.cc"

peaks::MultistageEnvelope _processor;

int32_t _attack = 0;
int32_t _decay = UINT16_MAX / 2;
int32_t _sustain = UINT16_MAX / 2;
int32_t _release = UINT16_MAX / 2;

struct
{
int8_t scope[128] = {};
int i = 0;

void draw(int y)
{
for (int x = 0; x < 127; x++)
{
if (x % 3 == 0)
gfx::setPixel(x, y);
gfx::drawLine(x, y - scope[(i + x) % 128], x + 1, y - scope[(1 + i + x) % 128]);
}
}

void push(int y)
{
scope[i++ % 128] = y;
if (i > 127)
i = 0;
}
} _scope;

void engine::setup()
{
_processor.Init();

engine::addParam("Attack", &_attack, 0, UINT16_MAX);
engine::addParam("Decay", &_decay, 0, UINT16_MAX);

if (!strcmp(engine::name(), "CV/EnvGen_ADSR"))
{
engine::addParam("Sustain", &_sustain, 0, UINT16_MAX);
engine::addParam("Release", &_release, 0, UINT16_MAX);
}
else
{
// AD - Mode
_sustain = -1;
_release = -1;
}
engine::setMode(ENGINE_MODE_COMPACT | ENGINE_MODE_CV_OUT);
}

void engine::process()
{
peaks::GateFlags flags[FRAME_BUFFER_SIZE];

uint16_t params[4];
params[0] = _attack;
params[1] = _decay;
if (_sustain >= 0)
{
params[2] = _sustain;
params[3] = _release;
_processor.Configure(params, peaks::CONTROL_MODE_FULL);
}
else
{
// AD - Mode
_processor.Configure(params, peaks::CONTROL_MODE_HALF);
}

if (engine::trig())
{
flags[0] = peaks::GATE_FLAG_RISING;
std::fill(&flags[1], &flags[FRAME_BUFFER_SIZE], peaks::GATE_FLAG_HIGH);
}
else if (engine::gate())
{
std::fill(&flags[0], &flags[FRAME_BUFFER_SIZE], peaks::GATE_FLAG_HIGH);
}
else
{
flags[0] = flags[0] == peaks::GATE_FLAG_HIGH ? peaks::GATE_FLAG_FALLING : peaks::GATE_FLAG_LOW;
std::fill(&flags[1], &flags[FRAME_BUFFER_SIZE], peaks::GATE_FLAG_LOW);
}

int16_t *buffer = engine::outputBuffer_i16<0>();
_processor.Process(flags, buffer, FRAME_BUFFER_SIZE);

static int y = 0;
if ((engine::t() % 50) == 0)
{
_scope.push(y);
y = 0;
}
else
y = std::max<int>(y, buffer[0] / (INT16_MAX / 16));

for (int i = 0; i < FRAME_BUFFER_SIZE; i++)
buffer[i] /= 2;
}

void engine::draw()
{
_scope.draw(56);
}
Binary file modified app/CV/EnvGen_ADSR.bin
Binary file not shown.
Binary file added app/CV/LFO.bin
Binary file not shown.
Loading

0 comments on commit 6e922fe

Please sign in to comment.