fix: correct backwards time axis on spectrogram and long levels - #455
Open
yottanami wants to merge 1 commit into
Open
fix: correct backwards time axis on spectrogram and long levels#455yottanami wants to merge 1 commit into
yottanami wants to merge 1 commit into
Conversation
CoordinateTransform.setRange(coord_min, coord_max) maps coord_min to the left screen edge and coord_max to the right edge. Both the spectrogram (imageplot.py) and long-term levels widget (longlevels.py) called setRange(0, T), labeling the left edge "0" and the right edge "T". Tracing the actual rendering shows the opposite is true: the spectrogram's ring-buffer pixmap draws its most recently written column at the right edge (CanvasScaledSpectrogram.addData/getpixmap offset math), and the long levels curve plots RingBuffer.data(), whose last sample (index -1, "now") is also the newest, at x=1 (right edge). So both widgets show "now" (time 0) on the right and the oldest history on the left, opposite to what the axis labeled. Swap the setRange arguments to setRange(T, 0) in both widgets so the labels match what's actually drawn. Closes tlecomte#434
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.
What
Swaps the
horizontal_axis.setRange(...)arguments infriture/imageplot.py(spectrogram, both__init__andsettimerange) andfriture/longlevels.py(setduration) so the axis labels match what's actually drawn.Why
As reported in #434, both the spectrogram and the long-term levels display label "now" (time 0) on the left and the full time range on the right — backwards from the actual scrolling direction.
I traced the rendering to confirm this rather than just taking the report at face value:
CoordinateTransform.toScreen()mapscoord_minto the left edge (startBorder) andcoord_maxto the right edge, sosetRange(a, b)labels left=a, right=b.CanvasScaledSpectrogram.addData()writes each new column atwrite_offsetand advances it;pixmap_source_rect()reads a window starting near the currentwrite_offset, which (given the ring-buffer wraparound) puts the most-recently-written column at the right edge of what's drawn, and the oldest retained column at the left.setduration()buildsscaled_tfromRingBuffer.data(), whose last sample (index -1) is the newest ("now"). Index -1 corresponds toscaled_t≈1, drawn at the right edge; index 0 (oldest) atscaled_t=0, drawn at the left edge.Both widgets draw "now" on the right, oldest history on the left — so the fix is to label them that way:
setRange(T, 0)instead ofsetRange(0, T).How this was tested
I don't have a working PyQt6/audio environment in my sandbox to run the app visually, so I couldn't confirm this by eye. I verified it by reading
coordinateTransform.py,spectrogram_image.py,spectrogram_item_data.py, andringbuffer.pyend to end and tracing the data flow by hand (see above);python3 -m py_compilepasses on both changed files. Given this is a visual/UX bug, it'd be good for a maintainer or another contributor to confirm on a running build before merging.Closes #434
AI disclosure: This PR (diff, commit message, and this description) was authored by an AI coding agent (Claude). The root-cause analysis and fix direction were derived by reading the source (not just the issue report), but are unverified against a running instance of the app.