Skip to content

Commit

Permalink
devsync 09ba082
Browse files Browse the repository at this point in the history
  • Loading branch information
eh2k committed Nov 2, 2024
1 parent 432cb0f commit 39a9940
Show file tree
Hide file tree
Showing 8 changed files with 308 additions and 65 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,22 @@
<summary><b>ChangeLog</b></summary>

````
== 2024-11-02
* Enhancement:
* SEC/EuclidArp
- fixed: note order (starting with root note)
- quantized output
- slide modes: OFF, ON, RND25, RND50, RND75
* Mod/TM
- reset #100
- shift_reg & seed - added to patch state
* GND/Scope
- x-scale added #73
== 2024-10-29
* Enhancement:
* TR707 - dynamic level/pan params in io-page/mixer section #29
* Bugfix:
* setPixel missing (scope app not working) #99
* setPixel missing (scope app not working)
== 2024-10-28
* Enhancement:
* Mod/SEQ - 4-step sequencer modulation #91
Expand Down
Binary file modified app/GND/Scope.bin
Binary file not shown.
108 changes: 94 additions & 14 deletions app/GND/Scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,35 @@
//

#include "../squares-and-circles-api.h"
#include <algorithm>

static float apmlitude = 1.f;
static int32_t x_scale = 32;
static float offset = 0.f;
static float input = 0.f;
static float output = 0.f;

uint32_t i = 0;
static int8_t scope[128] = {};
static int scope_n = 0;
static float scope_max = -1000.f;
static float scope_min = +1000.f;
static uint32_t scope_pos = 0;
static std::pair<float, float> scope[128 * 4] = {};

void engine::setup()
{
apmlitude = 1.f;
engine::addParam("_Scale", &apmlitude, 0.f, 2.f);
engine::addParam("_Y-Scale", &apmlitude, 0.f, 2.f);
engine::addParam("_Offset", &offset, -1.f, 1.f);
engine::addParam("_X-Scale", &x_scale, 0, 63);
engine::setMode(ENGINE_MODE_COMPACT);
}

void push_scope(int8_t scope[128], int8_t y)
void draw_scope(int y);
void push_scope(float y, float ymax)
{
scope[i++ % 128] = y;
if (i > 128)
i = 0;
scope[scope_pos++ % LEN_OF(scope)] = std::make_pair(y * 20, ymax * 20);
if (scope_pos >= ((x_scale > FRAME_BUFFER_SIZE) ? 128 : LEN_OF(scope)))
scope_pos = 0;
}

void set(float *target, const float *src, float amp, float offset)
Expand All @@ -63,18 +70,91 @@ void engine::process()
set(outputL, inputL, apmlitude, offset);
output = outputL[0];

if ((engine::t() % 50) == 0)
push_scope(scope, outputL[0] * 20);
int n = x_scale;
if (x_scale > FRAME_BUFFER_SIZE)
{
n = (x_scale - FRAME_BUFFER_SIZE) * FRAME_BUFFER_SIZE;
}

for (size_t j = 0; j < FRAME_BUFFER_SIZE; j++)
{
scope_max = fmax(scope_max, outputL[j]);
scope_min = fmin(scope_min, outputL[j]);

if (++scope_n > n)
{
push_scope(scope_min, scope_max);
scope_n = 0;
scope_max = -1000;
scope_min = +1000;
}
}
}

void engine::draw()
{
int y = 38;
for (int x = 0; x < 127; x++)
draw_scope(38);
}

void engine::screensaver()
{
gfx::clearRect(0, 0, 128, 64);
draw_scope(32);
}

void draw_scope(int y)
{
if (x_scale < FRAME_BUFFER_SIZE)
{
if (x % 3 == 0)
gfx::setPixel(x, y);
gfx::drawLine(x, y - scope[(i + x) % 128], x + 1, y - scope[(1 + i + x) % 128]);
int start = -1;
int end = -1;

for (int x = 0; x < LEN_OF(scope) - 1; x++)
{
if (
(scope[(scope_pos + x) % LEN_OF(scope)].first > 0 && scope[(scope_pos + x + 1) % LEN_OF(scope)].first <= 0))
if (start < 0)
start = (scope_pos + x);
else if (end < 0)
{
end = (scope_pos + x);
break;
}
}

if (start < 0)
start = scope_pos;

if (end < 0)
end = start + LEN_OF(scope);

for (int x = 0; x < 127; x++)
{
if (x % 3 == 0)
gfx::setPixel(x, y);

gfx::drawLine(
x, y + scope[(start + x) % LEN_OF(scope)].first,
x + 1, y + scope[(start + x + 1) % LEN_OF(scope)].first);

// if (scope[(start + i) % LEN_OF(scope)] > 0 && scope[(start + i + 1) % LEN_OF(scope)] <= 0)
// gfx::drawLine(x, y - 20, x, y + 20);
}
}
else
{
for (int x = 0; x < 127; x++)
{
if (x % 3 == 0)
gfx::setPixel(x, y);

gfx::drawLine(
x, y + scope[(scope_pos + x) % 128].first,
x, y + scope[(scope_pos + x) % 128].second);

// if (scope[(start + i) % LEN_OF(scope)] > 0 && scope[(start + i + 1) % LEN_OF(scope)] <= 0)
// gfx::drawLine(x, y - 20, x, y + 20);
}
}

char tmp[64];
Expand Down
Binary file modified app/SEQ/EuclidArp.bin
Binary file not shown.
Loading

0 comments on commit 39a9940

Please sign in to comment.