Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new frequency and dB mappings appear incompatible with the existing spectrum producers (already banded/log-compressed), likely causing distorted/flattened spectrum display.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the spectrum visualization logic in WaveformView to change how FFT/spectrum bins are mapped across display bands and how amplitudes are normalized for rendering.
Changes:
- Changed band-to-source mapping in
pushSpectrumto a log-frequency-based mapping (20Hz–20kHz) and expanded the input clamp range. - Changed spectrum bar and peak rendering to convert values to dB and then normalize into a 0–1 magnitude range.
File summaries
| File | Description |
|---|---|
| src/main/java/club/muimi/kimusic/view/component/WaveformView.java | Adjusts spectrum bin selection and amplitude normalization used to render the spectrum/peaks. |
Review details
Suppressed comments (1)
src/main/java/club/muimi/kimusic/view/component/WaveformView.java:166
- Same as the main bar: converting
spectrumPeaks[index]to dB again likely distorts peak behavior because peak values are already normalized/log-compressed by the producers. Keeping the previous peak scaling keeps peak decay semantics consistent withspectrumPeaks[index] = ... - 0.018f.
float peakRaw = (float) (spectrumPeaks[index] * displayScale);
double peakDb = 20 * Math.log10(peakRaw + 1e-12);
double peakNormalized = (peakDb + 120) / 120;
double peakMagnitude = Math.max(0.025, Math.min(1.0, peakNormalized));
- Files reviewed: 1/1 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+66
to
+69
| double normalized = (double) index / spectrum.length; | ||
| double freq = 20.0 * Math.pow(20000.0 / 20.0, normalized); | ||
| int source = (int) (freq / (20000.0 / values.length)); | ||
| source = Math.min(values.length - 1, Math.max(0, source)); |
| source = Math.min(values.length - 1, Math.max(0, source)); | ||
| // Preserve headroom so dense peaks can be normalized during drawing. | ||
| float value = Math.max(0, Math.min(4, values[source])); | ||
| float value = Math.max(0, Math.min(20, values[source])); |
Comment on lines
+156
to
+159
| float raw = (float) (spectrum[index] * displayScale); | ||
| double db = 20 * Math.log10(raw + 1e-12); | ||
| double normalized = (db + 120) / 120; | ||
| double magnitude = Math.max(0.025, Math.min(1.0, normalized)); |
This file contains hidden or 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
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.
No description provided.