Add gst-spectrascope-test.sh
authorAntonio Ospite <ao2@ao2.it>
Tue, 28 Aug 2018 15:41:20 +0000 (17:41 +0200)
committerAntonio Ospite <ao2@ao2.it>
Tue, 28 Aug 2018 15:41:20 +0000 (17:41 +0200)
Add an example of how to display audio spectrograms.

shell/gst-spectrascope-test.sh [new file with mode: 0755]

diff --git a/shell/gst-spectrascope-test.sh b/shell/gst-spectrascope-test.sh
new file mode 100755 (executable)
index 0000000..a1b6a52
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+set -e
+
+# Monitor the default sink
+DEFAULT_OUTPUT_MONITOR="$(pacmd stat | grep "Default sink" | cut -d ':' -f 2 | tail -c+2).monitor"
+
+# Take the most recent source as the microphone (in my case it's a USB
+# microphone I plugged in after pulseaudio started).
+MICROPHONE=$(pactl list short sources | tail -1 | cut -f 2)
+
+set -x
+gst-launch-1.0 -v -e \
+       compositor name=mix sink_1::xpos=256 sink_2::ypos=256 \
+       ! 'video/x-raw, width=512, height=512, framerate=(fraction)30/1' \
+       ! videoconvert \
+       ! autovideosink \
+       pulsesrc device="$DEFAULT_OUTPUT_MONITOR" \
+       ! deinterleave name=deint \
+          deint. \
+          ! audioconvert \
+          ! spectrascope \
+          ! 'video/x-raw, width=256, height=256, framerate=(fraction)30/1' \
+          ! textoverlay valignment=center font-desc='Sans, 50' text='Left speaker' \
+          ! queue \
+          ! mix. \
+          deint. \
+          ! audioconvert \
+          ! spectrascope \
+          ! 'video/x-raw, width=256, height=256, framerate=(fraction)30/1' \
+          ! textoverlay valignment=center font-desc='Sans, 50' text='Right speaker' \
+          ! queue \
+          ! mix. \
+       pulsesrc device="$MICROPHONE" \
+          ! audioconvert \
+          ! spectrascope \
+          ! 'video/x-raw, width=512, height=256, framerate=(fraction)30/1' \
+          ! textoverlay valignment=center font-desc='Sans, 50' text='Microphone' \
+          ! queue \
+          ! mix.