Skip to content

Fix waveform visualization for high-frequency oscillators and overlapping labels#11

Merged
joelmartinez merged 2 commits into
mainfrom
copilot/fix-10
Aug 14, 2025
Merged

Fix waveform visualization for high-frequency oscillators and overlapping labels#11
joelmartinez merged 2 commits into
mainfrom
copilot/fix-10

Conversation

Copilot AI commented Aug 14, 2025

Copy link
Copy Markdown
Contributor

The waveform visualizer was showing dense, unreadable visualizations for high-frequency oscillators and had overlapping labels in the title area. The issue was particularly problematic for the 440Hz basic sine wave, which displayed 440 complete cycles in one second, creating a solid blue block that made individual cycles indistinguishable.

Changes Made

Smart Duration Calculation

  • Modified GenerateWaveformData to automatically detect high-frequency oscillators (>50Hz)
  • High-frequency signals now show exactly 3 cycles instead of the full 1-second duration
  • Added frequency metadata to WaveformData model for cycle detection
  • Adaptive sample rate ensures adequate resolution for visualization (minimum 100 samples per cycle)

Visual Cycle Indicators

  • Added drawCycleIndicators method to highlight one complete cycle in the middle of the waveform
  • Middle cycle is highlighted with a light yellow background
  • Orange dashed lines mark cycle boundaries with "1 Cycle" label
  • Only displays for short-duration waveforms (<0.5s) where cycles are meaningful

Fixed Overlapping Labels

  • Improved label positioning logic in drawLabels method
  • Title and description are now intelligently positioned to prevent overlap
  • Description moves below title when combined text width would cause overlap

Results

Before: 440Hz sine wave showed 440 dense cycles making individual waveforms indistinguishable
After: Shows exactly 3 clear cycles with visual cycle indicator highlighting one complete cycle

The visualization now works optimally for:

  • High-frequency oscillators (sine, square waves): Show 3 cycles with cycle indicators
  • Low-frequency oscillators (LFO): Maintain longer durations to show multiple cycles
  • Complex waveforms (analog square, vibrato): Display underlying patterns clearly with proper transitions visible

All existing functionality is preserved while significantly improving readability for high-frequency signals.

Fixes #10.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: joelmartinez <90380+joelmartinez@users.noreply.github.com>
Copilot AI changed the title [WIP] Adjust Waveform sample data generation and rendering Fix waveform visualization for high-frequency oscillators and overlapping labels Aug 14, 2025
Copilot AI requested a review from joelmartinez August 14, 2025 14:10
@joelmartinez joelmartinez marked this pull request as ready for review August 14, 2025 14:14
@joelmartinez joelmartinez merged commit e93435b into main Aug 14, 2025
2 checks passed
@joelmartinez joelmartinez deleted the copilot/fix-10 branch August 14, 2025 14:14
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.

Adjust Waveform sample data generation and rendering

2 participants