New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horizontal comb of shadows in what should be smooth spectrogram output #39

Closed
martinwguy opened this Issue Feb 27, 2016 · 7 comments

Comments

Projects
None yet
2 participants
@martinwguy
Contributor

martinwguy commented Feb 27, 2016

sndfile-generate-chirp -from 0 -to 500 1000 1 chirp1000.wav
sndfile-spectrogram --no-border chirp1000.wav 640 501 chirp501.png

generates the following figure. There seem to be single-pixel dark lines and patterns in the borders of the main white/yellow area centre-right and centre-top.

The effect is much the same with linear and logarithmic frequency axes. This is the linear one:
chirp501

@martinwguy

This comment has been minimized.

Show comment
Hide comment
@martinwguy

martinwguy Feb 28, 2016

Contributor

Hypothesis: It's an artifact of the window function.
Experiment: try different window functions.

Hypothesis: It's caused by interference effects due to the temporal inaccuracy (noise) caused by a window that should be at, say, 1234.5 samples getting the sound at 1234.0 samples.
Experiment: Make the time sampling exact by interpolating between the two samples between which the desired sample value falls and see if this makes any difference.

Contributor

martinwguy commented Feb 28, 2016

Hypothesis: It's an artifact of the window function.
Experiment: try different window functions.

Hypothesis: It's caused by interference effects due to the temporal inaccuracy (noise) caused by a window that should be at, say, 1234.5 samples getting the sound at 1234.0 samples.
Experiment: Make the time sampling exact by interpolating between the two samples between which the desired sample value falls and see if this makes any difference.

@martinwguy

This comment has been minimized.

Show comment
Hide comment
@martinwguy

martinwguy Feb 28, 2016

Contributor

Experiment: try different window functions. The original uses the default kaiser window.

Rectangular:
bin/sndfile-spectrogram --no-border --rectangular --dyn-range=90 chirp1000.wav 640 501 chirp501-rect.png
chirp501-rect
Nuttall:
chirp501-nuttall
Hann:
chirp501-hann

Observation: They all have more of less similar artifacts.
Conclusion: Either it's not the window function's fault, or all the window functions give artifacts.

Contributor

martinwguy commented Feb 28, 2016

Experiment: try different window functions. The original uses the default kaiser window.

Rectangular:
bin/sndfile-spectrogram --no-border --rectangular --dyn-range=90 chirp1000.wav 640 501 chirp501-rect.png
chirp501-rect
Nuttall:
chirp501-nuttall
Hann:
chirp501-hann

Observation: They all have more of less similar artifacts.
Conclusion: Either it's not the window function's fault, or all the window functions give artifacts.

@martinwguy

This comment has been minimized.

Show comment
Hide comment
@martinwguy

martinwguy Feb 28, 2016

Contributor

Experiment: Make the time sampling exact by interpolating between the two samples between which the desired sample value falls and see if this makes any difference.
Code: http://martinwguy.co.uk/test/sndfile-spectrogram-exact-timing.patch

Results:
Default(kaiser):
chirp501-kaiser

Nuttall:
chirp501-nuttall

Hann:
chirp501-hann

Rectangular
chirp501-rect

Results: This introduces extra artifacts in the time dimension.

Contributor

martinwguy commented Feb 28, 2016

Experiment: Make the time sampling exact by interpolating between the two samples between which the desired sample value falls and see if this makes any difference.
Code: http://martinwguy.co.uk/test/sndfile-spectrogram-exact-timing.patch

Results:
Default(kaiser):
chirp501-kaiser

Nuttall:
chirp501-nuttall

Hann:
chirp501-hann

Rectangular
chirp501-rect

Results: This introduces extra artifacts in the time dimension.

@martinwguy

This comment has been minimized.

Show comment
Hide comment
@martinwguy

martinwguy Feb 28, 2016

Contributor

Hypothesis: The artifacts are caused by the extreme nature of the example (a full-amplitude 0 to 500Hz tone sweep at 1000Hz sample rate
Experiment: Try the same analysis at a sensible sampling rate

sndfile-generate-chirp  -from 0 -to 24000 48000 1 chirp48k.wav

Results:
Kaiser window:
chirp48k-kaiser

Nuttall:
chirp48k-nuttall

Hann:
chirp48k-hann

Rectangular:
chirp48k-rectangular

Conclusion: The artifacts are caused by a crazy test piece. Graphs with non-extreme data are OK.

Contributor

martinwguy commented Feb 28, 2016

Hypothesis: The artifacts are caused by the extreme nature of the example (a full-amplitude 0 to 500Hz tone sweep at 1000Hz sample rate
Experiment: Try the same analysis at a sensible sampling rate

sndfile-generate-chirp  -from 0 -to 24000 48000 1 chirp48k.wav

Results:
Kaiser window:
chirp48k-kaiser

Nuttall:
chirp48k-nuttall

Hann:
chirp48k-hann

Rectangular:
chirp48k-rectangular

Conclusion: The artifacts are caused by a crazy test piece. Graphs with non-extreme data are OK.

@martinwguy martinwguy closed this Feb 28, 2016

@erikd

This comment has been minimized.

Show comment
Hide comment
@erikd

erikd Feb 28, 2016

Owner

Cool, thanks for exploring this!

Owner

erikd commented Feb 28, 2016

Cool, thanks for exploring this!

@martinwguy

This comment has been minimized.

Show comment
Hide comment
@martinwguy

martinwguy Feb 29, 2016

Contributor

Glad you enjoyed it! Me too!

There was an ancillary fix in the patch, which separated out the allocation of the 4 big arrays, instead of allocating (2 + 2 + 2 + 1) * speclen and then calculating offsets into that. It didn't seem to break anything :) Shall I separate that out or u can pick it out of
http://martinwguy.co.uk/test/sndfile-spectrogram-exact-timing.patch

Contributor

martinwguy commented Feb 29, 2016

Glad you enjoyed it! Me too!

There was an ancillary fix in the patch, which separated out the allocation of the 4 big arrays, instead of allocating (2 + 2 + 2 + 1) * speclen and then calculating offsets into that. It didn't seem to break anything :) Shall I separate that out or u can pick it out of
http://martinwguy.co.uk/test/sndfile-spectrogram-exact-timing.patch

@erikd

This comment has been minimized.

Show comment
Hide comment
@erikd

erikd Feb 29, 2016

Owner

Yeah, I pulled the allocation stuff out of that patch and then added the corresponding free()s, mainly so that tools like Valgrind and ASAN don't complain.

Owner

erikd commented Feb 29, 2016

Yeah, I pulled the allocation stuff out of that patch and then added the corresponding free()s, mainly so that tools like Valgrind and ASAN don't complain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment