soundofdata

command module
v0.0.0-...-fb4dd32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2022 License: MIT Imports: 11 Imported by: 0

README

A little Go program that listens for data on stdin, forwards that data via a Web socket, and serves up a little HTML page that uses the Web Audio API for rendering the data as sound.

Usage

Pipe data with lines of the form seriesid frequency duration value. Seriesid is an opaque string, which can't contain a space, to identify a time series. Frequency is in Hertz, duration is in seconds (a float). Value is an optional float that will be displayed in a graph on the HTML page.

When a line arrives at listeners' Web pages, the series frequency is set to frequency for duration seconds. If a value is given, it'll be displayed on the series graph. Otherwise the frequency is added to the graph.

Then look at http://localhost:9080/.

Example

See demo.sh.

make # (or go generate && go build)
(while true; do 
	FREQ="$((80 + RANDOM % 400))"
	echo a $FREQ 3
	sleep 2
	FREQ="$((200 + RANDOM % 300))"
	echo b $FREQ 0.5
	sleep 0.5
	FREQ="$((180 + RANDOM % 400))"
	Y="$((FREQ/10))"
	echo a $FREQ 1 $Y
	sleep $(echo "scale=3;1 + $((RANDOM % 4000))/1000.0" | bc -l)
done) | ./soundofdata
# http://localhost:9080/

Notes

  1. With Firefox, the audio pops some. Doesn't on Chrome. I don't know what's going on.
  2. Named pipes make good input rendezvous points.
  3. Watch out for stdio buffering with your pipes.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL