Skip to content

Fix spectrum rendering v0.1.1 - #2

Closed
Muimi272 wants to merge 3 commits into
masterfrom
fix-spectrum-rendering-v0.1.1
Closed

Muimi272 wants to merge 3 commits into
masterfrom
fix-spectrum-rendering-v0.1.1

Conversation

@Muimi272

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI lite review requested due to automatic review settings August 25, 2026 18:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new spectrum bin selection in WaveformView maps the lowest band to DC (bin 0) and hard-codes a 20kHz range, which can produce incorrect rendering behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the audio spectrum pipeline and UI rendering to improve spectrum visualization, and bumps the release/version metadata to v0.1.1.

Changes:

  • Move frequency-band projection responsibility to WaveformView by returning raw positive-frequency FFT bins from the playback engine.
  • Update spectrum drawing to use a dB-based normalization curve (instead of direct linear clamping).
  • Bump project and packaging versions from 0.1.0 → 0.1.1.
File summaries
File Description
src/main/java/club/muimi/kimusic/view/component/WaveformView.java Changes spectrum band mapping (log-frequency style) and renders bars/peaks using dB normalization.
src/main/java/club/muimi/kimusic/service/playback/JavaSoundPlaybackEngine.java Returns raw FFT bins (positive frequencies) instead of pre-aggregated 64-band spectrum.
pom.xml Bumps Maven project version to 0.1.1.
.github/workflows/release.yml Updates packaging artifact names and jpackage --app-version to 0.1.1.
Review details

Suppressed comments (1)

.github/workflows/release.yml:67

  • Same hard-coded version issue in the Linux packaging step: deriving the version from the pushed tag reduces manual updates and keeps artifact names consistent with the release tag.
          cp staging/input/Kimusic.jar release/Kimusic-0.1.1.jar
          jpackage --type deb --name Kimusic --app-version 0.1.1 --input staging/input --main-jar Kimusic.jar --main-class club.muimi.kimusic.Launcher --dest release
          jpackage --type app-image --name Kimusic --app-version 0.1.1 --input staging/input --main-jar Kimusic.jar --main-class club.muimi.kimusic.Launcher --dest staging
  • Files reviewed: 4/4 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));
Comment on lines +323 to 333
// Return the positive-frequency FFT bins. WaveformView owns the only
// frequency-band projection so logarithmic scaling is not applied twice.
int usableBins = fftSize / 2;
for (int band = 0; band < spectrum.length; band++) {
double fromRatio = band / (double) spectrum.length;
double toRatio = (band + 1) / (double) spectrum.length;
int from = Math.max(1, (int) Math.round(Math.pow(fromRatio, 2) * usableBins));
int to = Math.max(from + 1, (int) Math.round(Math.pow(toRatio, 2) * usableBins));
double peak = 0;
for (int bin = from; bin < Math.min(to, usableBins); bin++) {
peak = Math.max(peak, Math.hypot(real[bin], imaginary[bin]));
}
float[] spectrum = new float[usableBins];
for (int bin = 1; bin < usableBins; bin++) {
double magnitude = Math.hypot(real[bin], imaginary[bin]);
// Keep a little over-range so the view can normalize all bands against
// the current maximum instead of flattening clipped peaks.
spectrum[band] = (float) Math.max(0, Math.min(4,
Math.log10(1 + peak * 18) / Math.log10(19)));
spectrum[bin] = (float) Math.max(0, Math.min(4,
Math.log10(1 + magnitude * 18) / Math.log10(19)));
}
Comment on lines +36 to +38
Copy-Item staging/input/Kimusic.jar release/Kimusic-0.1.1.jar
jpackage --type exe --name Kimusic --app-version 0.1.1 --input staging/input --main-jar Kimusic.jar --main-class club.muimi.kimusic.Launcher --icon logo.ico --dest release --win-shortcut --win-menu
jpackage --type msi --name Kimusic --app-version 0.1.1 --input staging/input --main-jar Kimusic.jar --main-class club.muimi.kimusic.Launcher --icon logo.ico --dest release --win-shortcut --win-menu
@Muimi272 Muimi272 closed this Aug 25, 2026
@Muimi272
Muimi272 deleted the fix-spectrum-rendering-v0.1.1 branch August 25, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants