spectrogram -X gives a truncated spectrogram #614

Open
opened 2025-09-14 10:42:28 +00:00 by martinwguy · 1 comment
martinwguy commented 2025-09-14 10:42:28 +00:00 (Migrated from codeberg.org)

spectrogram -X sometimes gives a truncated spectrogram

Description

sox_ng -n -n synth 1 sine 1k-10k spectrogram -X4001

gives a spectrogram from time 0 to just under 0.92 seconds
and -X3999 looks the right length but is missing the 1000ms label;
-X4000 works right.

The same thing happens when -d 1 (only show the first second) is also given.

Analysis

The rising curve in the graph ends at about 8250Hz,
so it's not incorrect axis labelling of a correct graph.

sox_ng -V -V output for the above contains:

sox_ng DBUG spectrogram: duration=1 x_size=4001 pixels_per_sec=4001
sox_ng INFO spectrogram: PNG truncated at 0.916896 seconds
sox_ng DBUG input: output buffer still held 1152 samples; dropped.

of which the input: output buffer is OK (-n generates samples forever)
but the -X4000 working example doesn't get the PNG truncated info.

The spectrographic area of the graph is, in fact, 4001 pixels wide,
so there is something screwy about how it determines
where to sample the audio for a particular column,
probably the effect of cumulative truncation error when stepping forwards for successive DFT frames.

May be related to #617

# spectrogram -X sometimes gives a truncated spectrogram ## Description ``` sox_ng -n -n synth 1 sine 1k-10k spectrogram -X4001 ``` gives a spectrogram from time 0 to just under 0.92 seconds and `-X3999` looks the right length but is missing the 1000ms label; `-X4000` works right. The same thing happens when `-d 1` (only show the first second) is also given. ## Analysis The rising curve in the graph ends at about 8250Hz, so it's not incorrect axis labelling of a correct graph. `sox_ng -V -V` output for the above contains: ``` sox_ng DBUG spectrogram: duration=1 x_size=4001 pixels_per_sec=4001 sox_ng INFO spectrogram: PNG truncated at 0.916896 seconds sox_ng DBUG input: output buffer still held 1152 samples; dropped. ``` of which the `input: output buffer` is OK (`-n` generates samples forever) but the `-X4000` working example doesn't get the `PNG truncated` info. The spectrographic area of the graph is, in fact, 4001 pixels wide, so there is something screwy about how it determines where to sample the audio for a particular column, probably the effect of cumulative truncation error when stepping forwards for successive DFT frames. May be related to #617
martinwguy commented 2025-09-14 11:18:41 +00:00 (Migrated from codeberg.org)

Spectrogram of sox_ng -n -n synth 1 sine 1k-10k spectrogram -X4001 output.
The graphic area is 4001 pixels wide but it only goes as far as 0.91X seconds
so its number of pixel columns per second is incorrect.

Spectrogram of `sox_ng -n -n synth 1 sine 1k-10k spectrogram -X4001` output. The graphic area is 4001 pixels wide but it only goes as far as 0.91X seconds so its number of pixel columns per second is incorrect.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
martinwguy/sox_ng#614
No description provided.