Skip to content

Instantly share code, notes, and snippets.

@deanturpin
Created June 17, 2019 10:29
Show Gist options
  • Save deanturpin/31ccefe764c06dfff60e25299fcf4230 to your computer and use it in GitHub Desktop.
Save deanturpin/31ccefe764c06dfff60e25299fcf4230 to your computer and use it in GitHub Desktop.
Extracting and plotting a WAV in bash
#!/bin/bash
[[ $# == 1 ]] && count=$1 || count=750
# Fetch some samples
nibbles=8
readarray samples < <(xxd -cols $nibbles -plain -s 42 -len $(( nibbles * count )))
# Loop through samples
i=0
for s in ${samples[*]}; do
# Extract left channel only
s=${s:0:4}
# Shift so all values are positive
echo -e $i\\t$(( 16#$s + 16#ffff ))
(( ++i ))
done | graph -T png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment