Skip to content

Commit

Permalink
keira: liltracker: fix sine waveform phase shift, increase sample rat…
Browse files Browse the repository at this point in the history
…e to 44100, increase mixer buf size to 512, increase DMA buf count to 4
  • Loading branch information
and3rson committed Apr 15, 2024
1 parent ff664c3 commit aff663f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions firmware/keira/src/apps/liltracker/effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ void effect_vibrato(float time, float relTime, float* frequency, float* amplitud
uint8_t vibratoDepth = param & 0x0F;

// Calculate the depth of vibrato in terms of radians
// TODO: This is not really correct: 1 unit of phase is not 1 semitone, but 1 Hz.
// So we should convert below value to Hz based on the current frequency of the note.
float phaseModulation = vibratoDepth / 15.0f * lilka::fSin360(time * vibratoFrequency * 360);

// Apply the vibrato phase modulation
Expand Down
2 changes: 1 addition & 1 deletion firmware/keira/src/apps/liltracker/mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Mixer::Mixer() :
.communication_format =
(esp_i2s::i2s_comm_format_t)(esp_i2s::I2S_COMM_FORMAT_STAND_I2S | esp_i2s::I2S_COMM_FORMAT_STAND_MSB),
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 3,
.dma_buf_count = 4,
.dma_buf_len = MIXER_BUFFER_SIZE,
.use_apll = false,
.tx_desc_auto_clear = true,
Expand Down
4 changes: 2 additions & 2 deletions firmware/keira/src/apps/liltracker/mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "waveforms.h"
#include "effects.h"

#define MIXER_BUFFER_SIZE 256
#define SAMPLE_RATE 16000
#define MIXER_BUFFER_SIZE 512
#define SAMPLE_RATE 44100
#define MIXER_BUFFER_DURATION_MS (MIXER_BUFFER_SIZE * 1000 / SAMPLE_RATE)
#define SECONDS_PER_SAMPLE (1.0f / SAMPLE_RATE)

Expand Down
2 changes: 1 addition & 1 deletion firmware/keira/src/apps/liltracker/waveforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ float triangle(float time, float frequency, float amplitude, float phase) {
// }

float fast_sine(float time, float frequency, float amplitude, float phase) {
return amplitude * lilka::fSin360(frequency * 360 * time + phase);
return amplitude * lilka::fSin360(frequency * 360 * time + phase * 360);
}

// Square wave function
Expand Down

0 comments on commit aff663f

Please sign in to comment.