8000 LilTracker by and3rson · Pull Request #95 · and3rson/lilka · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

LilTracker #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9ffc938
keira: nanotracker WIP
and3rson Apr 4, 2024
5077be9
keira: cleanup nanotracker file layout
and3rson Apr 4, 2024
fa3c271
keira: add pattern & mixer
and3rson Apr 4, 2024
a19f896
keira: add editing to nanotracker, add better mixing, add mutexes
and3rson Apr 5, 2024
d87ea02
keira: fix nanotracker note conversion, fix colors
and3rson Apr 5, 2024
3aa376f
keira: nanotracker: add arpeggio effect
and3rson Apr 5, 2024
6f24e99
keira: nanotracker: replace note floats with structs
and3rson Apr 5, 2024
44a67f0
keira: nanotracker: rename to liltracker
and3rson Apr 5, 2024
c51478e
keira: liltracker: update effects to more tracker-ish hex-oriented co…
and3rson Apr 5, 2024
11b0303
keira: liltracker: add tremolo & vibrato effects
and3rson Apr 5, 2024
84b78c6
keira: liltracker: implement proper effect/volume propagation, replac…
and3rson Apr 6, 2024
5ba97b8
keira: liltracker: finally - vibrato and header row
and3rson Apr 6, 2024
3217b25
keira: allow app to set its core affinity
and3rson Apr 6, 2024
db10dc5
keira: liltracker: revamp UI
and3rson Apr 6, 2024
48d4533
sdk: add Canvas::drawTextAligned
and3rson Apr 6, 2024
00a8035
sdk: I2S asshattery.
and3rson Apr 6, 2024
f13ae1f
sdk: fix initial display width/height due to rotation being applied t…
and3rson Apr 7, 2024
ee30567
keira: liltracker: add waveform visualizations, improve sound preview
and3rson Apr 7, 2024
d448a48
keira: liltracker: add basic track support
and3rson Apr 7, 2024
120de65
keira: replace mutexes with binary semaphores
and3rson Apr 7, 2024
bac8716
keira: fix memory corruption due to usage of WiFi methods after deall…
and3rson Apr 8, 2024
41a8acb
keira: add mutex to servicemanager, start debugging network disabling
and3rson Apr 8, 2024
2d03b66
keira: liltracker: basic features ready
and3rson Apr 8, 2024
dfc6f53
keira: liltracker: fix visualization not showing in preview mode, inc…
and3rson Apr 8, 2024
b72a443
keira: liltracker: improve UI, add page/BPM/length selectors, add no-…
and3rson Apr 8, 2024
f9b42aa
Merge branch 'main' into ad/nanotracker
and3rson Apr 9, 2024
5fcc536
Merge branch 'main' into ad/nanotracker
and3rson Apr 9, 2024
e88b33a
keira: liltracker: explicit floats
and3rson Apr 10, 2024
f7d667c
keira: liltracker: replace sinf/powf with lookup tables
and3rson Apr 11, 2024
2a3ebe6
Merge branch 'main' into ad/nanotracker
and3rson Apr 11, 2024
08fb679
keira: liltracker: fix vertically inverted waveform visualizer, use A…
and3rson Apr 11, 2024
1cd8778
keira: liltracker: add pitched PRNG noise, add volume slide effect, u…
and3rson Apr 12, 2024
4a60aed
keira: liltracker: add reserved bytes, change signature to LILT
and3rson Apr 12, 2024
ba7d7c0
keira: liltracker: implement reset button, set default waveforms to n…
and3rson Apr 12, 2024
b443aee
keira: lilplayer: wip file loading/saving
and3rson Apr 12, 2024
3594e54
keira: liltracker: implement track loading/saving
and3rson Apr 12, 2024
95c9c7a
keira: liltracker: allow running LilTracker files from SD card
and3rson Apr 12, 2024
19b8322
keira: liltracker: remove unused trailing patterns on save
and3rson Apr 12, 2024
c907b77
keira: liltracker: fix file saving
and3rson Apr 12, 2024
f578d4c
keira: liltracker: auto-resize pattern count, make it easier to set n…
and3rson Apr 12, 2024
1ad8b86
keira: liltracker: replace instance vectors with pointer vectors in t…
and3rson Apr 12, 2024
80c3468
keira: liltracker: improve UI, fix reset crash
and3rson Apr 13, 2024
dd90b7d
keira: liltracker: add copy-pasting in normal mode
and3rson Apr 13, 2024
20e5867
keira: liltracker: improve colors
and3rson Apr 13, 2024
e7ce67e
sdk: eliminate duplication in Display and Canvas classes by moving sh…
and3rson Apr 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/about/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
По проєкт
===========
Про проєкт
==========

.. include:: what_is_lilka.rst

Expand Down
3 changes: 3 additions & 0 deletions docs/library/display.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
.. doxygenclass:: lilka::Canvas
:members:

.. doxygenclass:: lilka::GFX
:members:

.. doxygenclass:: lilka::Image
:members:

Expand Down
4 changes: 4 additions & 0 deletions firmware/keira/src/apps/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "nes/nesapp.h"
#include "ftp/ftp_server.h"
#include "weather/weather.h"
#include "liltracker/liltracker.h"

#include "icons/demos.h"
#include "icons/sdcard.h"
Expand Down Expand Up @@ -66,6 +67,7 @@ ITEM_LIST app_items = {
ITEM_APP("I2C-сканер", ScanI2CApp),
ITEM_APP("GPIO-мененджер", GPIOManagerApp)},
),
ITEM_APP("ЛілТрекер", LilTrackerApp),
ITEM_APP("Летріс", LetrisApp),
ITEM_APP("Тамагочі", TamagotchiApp),
ITEM_APP("Погода", WeatherApp),
Expand Down Expand Up @@ -267,6 +269,8 @@ void LauncherApp::selectFile(String path) {
AppManager::getInstance()->runApp(new LuaFileRunnerApp(path));
} else if (lowerCasedPath.endsWith(".js")) {
AppManager::getInstance()->runApp(new MJSApp(path));
} else if (lowerCasedPath.endsWith(".lt")) {
AppManager::getInstance()->runApp(new LilTrackerApp(path));
} else {
// Get file size
// lilka::serial_log(path.c_str());
Expand Down
6 changes: 6 additions & 0 deletions firmware/keira/src/apps/liltracker/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#define CHANNEL_COUNT 3
#define DEFAULT_BPM 400
#define CHANNEL_SIZE 32
#define MAX_VOLUME 128
111 changes: 111 additions & 0 deletions firmware/keira/src/apps/liltracker/effects.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#include <math.h>
#include <lilka/fmath.h>

#include "effects.h"
#include "note.h"

void effect_none(float time, float relTime, float* frequency, float* amplitude, float* phase, uint8_t param) {
(void)time;
(void)relTime;
(void)frequency;
(void)amplitude;
(void)phase;
(void)param;
}

void effect_arpeggio(float time, float relTime, float* frequency, float* amplitude, float* phase, uint8_t param) {
// This effect arpeggiates the note by changing the frequency of the note at a fixed interval.
// It mimics NES arpeggio that consists of up to 3 notes.

(void)relTime;
(void)amplitude;
(void)param;

constexpr int8_t count = 3; // 3 notes

uint8_t note2offset = (param & 0xF0) >> 4;
uint8_t note3offset = (param & 0x0F);

// duration of each note in milliseconds is 1/60 of a second
float stepDurationMs = 1000.0f / 60.0f;

// Calculate current arpeggio step
int8_t step = ((int64_t)(time / (stepDurationMs / 1000.0f))) % count;

if (step == 0) {
// No change
} else if (step == 1) {
// Use the second note
*frequency = modulate_frequency(*frequency, note2offset);
} else if (step == 2) {
// Use the third note
*frequency = modulate_frequency(*frequency, note3offset);
}
}

void effect_vibrato(float time, float relTime, float* frequency, float* amplitude, float* phase, uint8_t param) {
// This effect modulates the frequency of the note with a sine wave.
// Upper nibble of the parameter is the speed of the vibrato (in Hz)
// Lower nibble of the parameter is the depth of the vibrato (0 to 15, 0 = no vibrato, 15 = one full semitone vibrato)

(void)relTime;
(void)frequency;
(void)amplitude;

uint8_t vibratoFrequency = (param & 0xF0) >> 4;
uint8_t vibratoDepth = param & 0x0F;

// Calculate the depth of vibrato in terms of radians
float phaseModulation = vibratoDepth / 15.0f * lilka::fSin360(time * vibratoFrequency * 360);

// Apply the vibrato phase modulation
*phase += phaseModulation;
}

void effect_tremolo(float time, float relTime, float* frequency, float* amplitude, float* phase, uint8_t param) {
// This effect modulates the amplitude of the note with a sine wave.
// Upper nibble of the parameter is the speed of the tremolo (in Hz)
// Lower nibble of the parameter is the depth of the tremolo (0 to 15, 0 = no tremolo, 15 = max tremolo)

(void)time;
(void)relTime;
(void)frequency;
(void)phase;

uint8_t tremoloFrequency = (param & 0xF0) >> 4;
uint8_t tremoloDepth = (param & 0x0F);

// Calculate the tremolo into a range of 0.0 to 1.0
float tremolo = (lilka::fSin360(time * tremoloFrequency * 360) + 1.0f) / 2.0f;

// Apply the tremolo
*amplitude = *amplitude * (1.0f - tremolo * tremoloDepth / 15.0f);
}

void effect_volume_slide(float time, float relTime, float* frequency, float* amplitude, float* phase, uint8_t param) {
// This effect slides the volume of the note.
// If upper nibble is 0 F438 , lower nibble is slide down speed (1s / value)
// If lower nibble is 0, upper nibble is slide up speed (1s / value)
// relTime is the relative time of when the effect started

(void)time;
(void)frequency;
(void)phase;

uint8_t slideUpSpeed = (param & 0xF0) >> 4;
uint8_t slideDownSpeed = param & 0x0F;

float newAmplitude = *amplitude;

if (slideUpSpeed == 0) {
// Slide down
newAmplitude = 1.0f - (relTime / (1.0f / slideDownSpeed));
} else if (slideDownSpeed == 0) {
// Slide up
newAmplitude = relTime / (1.0f / slideUpSpeed);
}

// Clamp the amplitude
// TODO: We should probably override the amplitude, and disable this effect if event volume is set in tracker?
*amplitude *= fminf(fmaxf(newAmplitude, 0.0f), 1.0f);
}
61 changes: 61 additions & 0 deletions firmware/keira/src/apps/liltracker/effects.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#pragma once

#include <stdint.h>

typedef enum {
EFFECT_TYPE_NONE,
EFFECT_TYPE_ARPEGGIO, // NES: 00xy
EFFECT_TYPE_VIBRATO, // NES: 04xy
EFFECT_TYPE_TREMOLO, // NES: 07xy
EFFECT_TYPE_VOLUME_SLIDE, // NES: 0Axy
EFFECT_TYPE_COUNT,
} effect_type_t;

const effect_type_t effects[EFFECT_TYPE_COUNT] = {
EFFECT_TYPE_NONE,
EFFECT_TYPE_ARPEGGIO,
EFFECT_TYPE_VIBRATO,
EFFECT_TYPE_TREMOLO,
EFFECT_TYPE_VOLUME_SLIDE,
};

const char effect_signs[EFFECT_TYPE_COUNT] = {
'.',
'A',
'V',
'T',
'S',
};

typedef struct {
effect_type_t type;
uint8_t param;
} effect_t;

typedef void (*effect_fn_t)(
const float time, const float relTime, float* frequency, float* amplitude, float* phase, uint8_t param
);

void effect_none(
const float time, const float relTime, float* frequency, float* amplitude, float* phase, uint8_t param
);
void effect_arpeggio(
const float time, const float relTime, float* frequency, float* amplitude, float* phase, uint8_t param
);
void effect_vibrato(
const float time, const float relTime, float* frequency, float* amplitude, float* phase, uint8_t param
);
void effect_tremolo(
const float time, const float relTime, float* frequency, float* amplitude, float* phase, uint8_t param
);
void effect_volume_slide(
const float time, const float relTime, float* frequency, float* amplitude, float* phase, uint8_t param
);

const effect_fn_t effect_functions[EFFECT_TYPE_COUNT] = {
effect_none,
effect_arpeggio,
effect_vibrato,
effect_tremolo,
effect_volume_slide,
};
Loading
Loading
0