Skip to content

perf: calculate voice waveform peaks without slice allocations - #1428

Open
MrPunyapal wants to merge 1 commit into
dev-null-sh:productionfrom
MrPunyapal:perf/avoid-voice-waveform-slice-allocations
Open

MrPunyapal wants to merge 1 commit into
dev-null-sh:productionfrom
MrPunyapal:perf/avoid-voice-waveform-slice-allocations

Conversation

@MrPunyapal

@MrPunyapal MrPunyapal commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Change

Calculates voice waveform peaks directly from each range instead of allocating sliced arrays. Peak values and boundaries are preserved, including empty input.

Validation

The full JavaScript unit suite passed (225 tests). A synthetic Node benchmark showed about a 3x reduction for 1,200 samples across 10,000 calls, but the application calculates a waveform once per recording, so the real user impact is small and has not been measured in a target browser. This remains a draft pending confirmation that the added complexity is worthwhile.

Summary by CodeRabbit

  • Bug Fixes
    • Improved voice-note audio visualizations for long recordings, preserving prominent peaks without losing detail.
    • Empty audio data is now handled gracefully when generating visualizations.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 547e1b55-c680-4b58-8324-53e49487a193
Commits

Reviewing files that changed from the base of the PR and between fc0f56a and c1640d0.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

barsOf now returns zero for empty input and finds each bar’s peak by iterating over its source range. Tests cover long sequences, negative values, NaN, and sparse-array holes.

Changes: Voice note bar calculation

Layer / File(s) Summary
Bar calculation and validation
resources/js/lib/voice-notes.ts, tests/Unit/VoiceNotes.test.ts
barsOf returns zero bars for empty input and finds peaks by iterating over each bar’s range. Tests verify peak retention in a long sequence and behavior for negative values, NaN, and sparse-array holes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: nunomaduro

Merge Risk: Minimal · previous review fc0f5

The waveform calculation change preserves existing behavior while removing slice allocations; no merge-blocking risk was identified.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: calculating voice waveform peaks without slice allocations. It matches the implementation and PR objective.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: af7987fa-d448-4b55-acfb-2785b14da705
Commits

Reviewing files that changed from the base of the PR and between c934501 and fc0f56a.

Files selected for processing: 2
  • resources/js/lib/voice-notes.ts
  • tests/Unit/VoiceNotes.test.ts

Limit details: You’ve used all 10 included reviews currently available.

@MrPunyapal
MrPunyapal force-pushed the perf/avoid-voice-waveform-slice-allocations branch from 0bcc647 to fc0f56a Compare November 3, 2026 05:55
@MrPunyapal
MrPunyapal marked this pull request as ready for review November 3, 2026 06:02
@MrPunyapal
MrPunyapal force-pushed the perf/avoid-voice-waveform-slice-allocations branch from fc0f56a to c1640d0 Compare November 3, 2026 21:02
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.

1 participant