Skip to content

Commit

Permalink
keira: liltracker: pack structs, cleanup code, fix UI fonts
Browse files Browse the repository at this point in the history
keira: modplayer: normalize visualizer for nicer display when volume is low
keira: replace double-precision funcs with faster float variants
  • Loading branch information
and3rson committed Apr 17, 2024
1 parent c034f66 commit 4563cc8
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 450 deletions.
2 changes: 2 additions & 0 deletions firmware/keira/src/apps/liltracker/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
#define DEFAULT_BPM 400
#define CHANNEL_SIZE 32
#define MAX_VOLUME 128

#define PACKED __attribute__((packed))
4 changes: 3 additions & 1 deletion firmware/keira/src/apps/liltracker/effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <stdint.h>

#include "config.h"

typedef enum : uint8_t {
EFFECT_TYPE_NONE,
EFFECT_TYPE_ARPEGGIO, // NES: 00xy
Expand Down Expand Up @@ -30,7 +32,7 @@ const char effect_signs[EFFECT_TYPE_COUNT] = {
typedef struct {
effect_type_t type;
uint8_t param;
} effect_t;
} PACKED effect_t;

typedef void (*effect_fn_t)(
const float time, const float relTime, float* frequency, float* amplitude, float* phase, uint8_t param
Expand Down
7 changes: 3 additions & 4 deletions firmware/keira/src/apps/liltracker/liltracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void LilTrackerApp::run() {

int visualizerMode = VISUALIZER_MODE_PER_CHANNEL;

event_t copiedEvent = {N_C0, WAVEFORM_CONT, MAX_VOLUME, EVENT_TYPE_CONT, {EFFECT_TYPE_NONE, 0}};
event_t copiedEvent = {NOTE_ZERO, WAVEFORM_CONT, MAX_VOLUME, EVENT_TYPE_CONT, {EFFECT_TYPE_NONE, 0}};

char str[64];

Expand Down Expand Up @@ -381,7 +381,6 @@ void LilTrackerApp::run() {
int8_t fontShiftY = 0;
if (event.waveform == WAVEFORM_CONT) {
sprintf(str, ".");
canvas->setFont(FONT);
} else {
sprintf(str, "%d", event.waveform - 1);
canvas->setFont(FONT_ICONS);
Expand All @@ -398,7 +397,7 @@ void LilTrackerApp::run() {
eventFocused && currentSegment == SEGMENT_WAVEFORM,
event.waveform == WAVEFORM_CONT ? lilka::colors::Battleship_gray : lilka::colors::Cyan
);
canvas->setFont(FONT);
canvas->setFont(SCORE_FONT);
xOffset += 9;
// Volume
if (event.volume == 0) {
Expand Down Expand Up @@ -610,7 +609,7 @@ void LilTrackerApp::run() {
}
}
if (!found) {
event.note = N_C0;
event.note = NOTE_ZERO;
}
}
if (state.up.justPressed) {
Expand Down
208 changes: 0 additions & 208 deletions firmware/keira/src/apps/liltracker/mixer.cpp

This file was deleted.

60 changes: 0 additions & 60 deletions firmware/keira/src/apps/liltracker/mixer.h

This file was deleted.

2 changes: 1 addition & 1 deletion firmware/keira/src/apps/liltracker/note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const char* note_names[] = {"C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#"

void noteinfo_t::fromFrequency(float frequency) {
// 16.35 Hz is the lowest note, which is C0 (returned as octave 0, index 0)
int absIndex = round(log2(frequency / A4_FREQUENCY) * NOTES_PER_OCTAVE) + 57;
int absIndex = roundf(log2f(frequency / A4_FREQUENCY) * NOTES_PER_OCTAVE) + 57;

if (absIndex < 0) {
absIndex = 0;
Expand Down
Loading

0 comments on commit 4563cc8

Please sign in to comment.