By wisecracker
Apologies for any typos…
it is another building block along with my other two shell uploads recently to start a semi_serious project of an Terminal_AudioScope…
The fist upload I posted recently was to show how to animate colours, the second was to be able to manipulate a known bainary file to become a timebase and now this simple display…
The next upload will be a simple working unit using “/dev/dsp” for Linux through either the internal micrphone or the external mic input… The limitations of this device is that by default it samples at 8KHz, to 8 bit depth, mono, so don’t expect anything wondrous…
There is a FLAW in this DEMO. It is NOT a bug! What is it? ;o)
You need to know how the console or terminal works to find it…
Be aware of wordwrapping, etc…
# !/bin/sh
#
# AudioScopeDisplay.sh
#
# This method can also be used for a simple kids level Analogue Data_logger/Transient_Recorder
# Cannot use "setterm -cursor off" as Mac OSX 10.7.5 has not got "setterm", thought of another way for the Macbook Pro... ;o)
#
# $VER: AudioScopeDisplay.sh_Version_0.00.01_Public_Domain_B.Walker_G0LCU.
display()
{
clear
graticule="+-------+-------+-------+-------+-------+-------+-------+--------+n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"+-------+-------+-------+-------+-------+-------+-------+--------+n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+--+n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"+-------+-------+-------+-------+-------+-------+-------+--------+n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"| | | | + | | | |n"
graticule=$graticule"+-------+-------+-------+-------+-------+-------+-------+--------+n"
printf "$graticule"
}
while true
do
display
for horiz in {2..65}
do
# Simulate an 8 bit grab and divide by 16 to give 4 bit depth. Add offset of 2 to allow
# for mssing the top graticule line...
vert=$[ ( $RANDOM % ( 256 / 16 ) + 2 ) ]
# There IS a FLAW here at _printf_, NOTE, not a bug! What is it? ;o)
printf "x1B["$vert";"$horiz"fo"
# Slow it down so you can see it working...
sleep 0.05
done
printf "x1B[20;1f"
sleep 1
done
Enjoy finding simple solutions to often very difficult problems… ;o)
Bazza, G0LCU…