-
Notifications
You must be signed in to change notification settings - Fork 6
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
Log scale Y axis #9
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Updated with linear/sqrt/log scale controlled by define, think sqrt looks quite good - but probably these should be set by config when such a thing exists. |
Sqrt is looking pretty good, really responsive. Actually led me to knock back the fill colour a little bit because it was obscuring the fast transients in the bottom half a little too much. Try: diff --git a/src/btstack_audio_pico.cpp b/src/btstack_audio_pico.cpp
index 6417f3e..8c56728 100644
--- a/src/btstack_audio_pico.cpp
+++ b/src/btstack_audio_pico.cpp
@@ -310,9 +310,9 @@ static void btstack_audio_pico_sink_fill_buffers(void){
maxy = y;
}
} else if (y < maxy) {
- r = (uint16_t)(palette_main[i].r) >> 2;
- g = (uint16_t)(palette_main[i].g) >> 2;
- b = (uint16_t)(palette_main[i].b) >> 2;
+ r = (uint16_t)(palette_main[i].r) >> 3;
+ g = (uint16_t)(palette_main[i].g) >> 3;
+ b = (uint16_t)(palette_main[i].b) >> 3;
}
display.set_pixel(i, display.HEIGHT - 1 - y, r, g, b);
} |
This is fun, too: diff --git a/src/btstack_audio_pico.cpp b/src/btstack_audio_pico.cpp
index 6417f3e..b203f10 100644
--- a/src/btstack_audio_pico.cpp
+++ b/src/btstack_audio_pico.cpp
@@ -142,6 +142,8 @@ FIX_FFT fft;
RGB palette_peak[display.WIDTH];
RGB palette_main[display.WIDTH];
+RGB palette_vert[display.HEIGHT];
+
// client
static void (*playback_callback)(int16_t * buffer, uint16_t num_samples);
@@ -222,6 +224,13 @@ static audio_buffer_pool_t *init_audio(uint32_t sample_frequency, uint8_t channe
palette_main[i] = RGB::from_hsv(h, 1.0f, 0.7f);
}
+ for(auto i = 0u; i < display.HEIGHT; i++) {
+ int n = floor(i / 4) * 4;
+ float h = 0.4 * float(n) / display.HEIGHT;
+ h = 0.333 - h;
+ palette_vert[i] = RGB::from_hsv(h, 1.0f, 1.0f);
+ }
+
return producer_pool;
}
@@ -287,9 +296,9 @@ static void btstack_audio_pico_sink_fill_buffers(void){
uint8_t g = 0;
uint8_t b = 0;
if (sample > int_to_fix15(lower_threshold)) {
- r = (uint16_t)(palette_main[i].r);
- g = (uint16_t)(palette_main[i].g);
- b = (uint16_t)(palette_main[i].b);
+ r = (uint16_t)(palette_vert[y].r);
+ g = (uint16_t)(palette_vert[y].g);
+ b = (uint16_t)(palette_vert[y].b);
#ifdef SCALE_LOGARITHMIC
sample = multiply_fix15_unit(multiple, sample);
#else
@@ -301,23 +310,23 @@ static void btstack_audio_pico_sink_fill_buffers(void){
}
else if (sample > 0) {
uint16_t int_sample = (uint16_t)fix15_to_int(sample);
- r = std::min((uint16_t)(palette_main[i].r), int_sample);
- g = std::min((uint16_t)(palette_main[i].g), int_sample);
- b = std::min((uint16_t)(palette_main[i].b), int_sample);
+ r = std::min((uint16_t)(palette_vert[y].r), int_sample);
+ g = std::min((uint16_t)(palette_vert[y].g), int_sample);
+ b = std::min((uint16_t)(palette_vert[y].b), int_sample);
eq_history[i][history_idx] = y;
sample = 0;
if (maxy < y) {
maxy = y;
}
} else if (y < maxy) {
- r = (uint16_t)(palette_main[i].r) >> 2;
- g = (uint16_t)(palette_main[i].g) >> 2;
- b = (uint16_t)(palette_main[i].b) >> 2;
+ r = (uint16_t)(palette_vert[y].r) >> 3;
+ g = (uint16_t)(palette_vert[y].g) >> 3;
+ b = (uint16_t)(palette_vert[y].b) >> 3;
}
display.set_pixel(i, display.HEIGHT - 1 - y, r, g, b);
}
if (maxy > 0) {
- RGB c = palette_peak[i];
+ RGB c = palette_vert[display.HEIGHT - 1];
display.set_pixel(i, display.HEIGHT - 1 - maxy, c.r, c.g, c.b);
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A bit more action across the spectrum - let me know if it works ok on Cosmic!