Audio Sparklines
melatonin.dev
melatonin.dev
[0⎻⎺⎻x—x⎻x—⎼⎽_E_⎽⎼—x⎻⎺‾E‾⎺⎻x_⎽⎼—0(234)]
Inserting bracketed numbers throws the whole sparkline concept out the window.If terminal output is the use case here, why not use color when available? Zero crossings could be highlighted in blue, and out-of-bound clipping could be shown in red. Long sequences of zeroes could just be represented with a red line, or even empty space:
[ ]
[---- ]
Silence should be easy to spot, not crammed behind numbers! [0(512)]
[----0(256)]
Which style would you find easier to understand at a glance?In the audio contexts I'm working in, it is a feature to have the zero crossings and errors jump out. It's less "pretty" but is as data-dense as I could get just with unicode.
> why not use color when available?
You are right, color would increase data density. In both my test context and in my debugger, color is unfortunately unavailable...
> Silence should be easy to spot, not crammed behind numbers!
The condensed 0(256) notation is ugly, it's true. However, you can't miss it, and it's information dense. This was the toughest element to design and I tried a few other styles before this, because yes, it's ugly :)
I'm often working with buffers with 256+ zeros, so zeros had to be condensed to stay legible. Simultaneously, it's often necessary to know the exact number of empty samples (they could occur at the start, middle or end of the block). A dash - for a 0 such as in [----0(256)] might have some ambiguity with a quiet part of a signal (it's important to differentiate true zeros) but your post has me thinking!...
It might work on certain fonts and terminals. It's not a general solution for blogs IMO. Are we better off with terminals with first-class support for sub-cell graphics rather than text, considering people tend to hack in graphics in terminals (the various htop replacements with terminal graphs, and this)?
I felt doomed to Unicode in this case because of the number of places I wanted them to show up (CLion lldb integration, GitHub actions output, terminal). I would have loved to actually render graphics! I actually never thought about how they would render on a blog article, I wouldn't generally wouldn't use them for blogging...
1. https://github.com/sudara/melatonin_audio_sparklines/blob/ma...
It’s so nice to be able to use this sort of thing in tests when the outcomes don’t represent as text naturally. Makes it super easy to eyeball a failing test and intuitively understand what the problem is.
https://github.com/JuliaAudio/SampledSignals.jl#repl-display
I want to hear more about the remote visualizer! I was using Jim Credland's buffer debugger (again, JUCE)[1]. It pops open a window, making it fairly easy to visualize buffers with one caveat: you actually have to tell it about the buffers you care about visualizing and then recompile. This means debugging can't really be on the fly (unless you only always care about the same buffer or two).
The other issue I ran into was viewing audio from my tests. I'd love to hear about the shared memory approach — real waveforms would be ideal!
1. https://github.com/jcredland/juce-toys/blob/master/jcf_debug...
Since this is HN, does anyone know what are the best ways to draw graphics into modern terminals?
https://melatonin.dev/wp-content/uploads/2021/10/image.jpeg
... and I think that is a GUI and not a terminal ... but I'm not sure ?
I think the folder icon in the lower left is good evidence that I am looking at a GUI window but would like you to confirm/deny ...