Table des matières

Scripts bash linux audiovisuel

Manipulation bash multimedia glitch

Lire au format brut

arecord -D pulse

Jouer un fichier brut

aplay Sammy_Video-ABC/a.artiste.mp4
aplay -t raw -f S16_LE -c 2 -r 44100 --buffer-size=64 -i files/ube_web.pdf
aplay -t raw -c 2 -r 44100 --buffer-size=64 -i files/ube_web.pdf (8bit style)

equivalent sox aplay

play -t raw --ignore-length -r 44100 -e signed-integer -b 8 -c 1 files/ube_web.pdf
play  -t raw --ignore-length -r 5512 -e signed-integer -b 8 -c 1 ube_web.pdf
Pd
[read iDoc.pdf 0 0 1 2(
|
[readsf~]
echo "text to be synthesized" | text2wave -f 44100 -scale 1 -o /home/username/file/output.wav

Tout envoyer dans la carte son

ALSA systems:

./program | aplay

PulseAudio systems:

./program | pacat --format u8 --rate 8000

Jack again (voir claudius)

cat /dev/sda 

crappy bash script circa 2005

if test -e /dev/dsp ; then (cat /dev/mem > /dev/dsp)& (sleep 6.66 && kill `pidof cat /dev/mem`)& fi

Network sonification

ping

une commande historique :

ping goodhost | sed -e 's/.*/ping/' | vocoder

l'option -a pour Audible ping :

ping -a x.org
ping -a -i 0,3 labomedia.org

soit sous linux

sudo modprobe pcspkr

et tester avec

echo -e "\a"
sudo ping -a -A x.org
sudo ping -a -A www.mitsubishi.jp

le -A suit le rythme de retour de ping, sudo nécessaire si ping < 200 ms

ping et espeak

ping dev.lobotomie.org | sed -e 's/.*/ping/' | espeak --stdin

il faut kill le ping pour que espeak se déclenche ….

ping labomedia.org | festival --tts

marche mais ne peut pas suivre le rythme

nmap

Here's a quick non-stealthy-yet-harmless command that'll reveal the IPs of all clients on the LAN. It'll work on any GNU/Linux system with nmap installed.

 sudo nmap -sP $(route | grep "*" | awk '{ print $1 }' | sed 's/0/*/') | grep report 

tcpdump

tcpdump -i wlan0 -s 0 -w - > /dev/dsp
sudo tcpdump -U -s 65535 -i wlan0 -w /dev/dsp
sudo tcpdump port http -A -vvv -i wlan0 > /dev/audio

sudo tcpdump -A -s 1500 -vvv -i wlan0 > /dev/audio

Ne capturer que le contenu des packets en mode ascii via ip (ou fddi, tr, wlan, ip, ip6, arp, rarp, decnet, tcp and udp)

sudo tcpdump -A -i wlan0 ip | awk -F'!' '{print $NF}

* https://askubuntu.com/questions/438041/display-only-the-data-section-of-the-packet

Pour renvoyer le tout sur jack

mkfifo bridge.fifo
sudo cat /dev/mem >> bridge.fifo &
ecasound -f:s16_le,1,44100 -i:resample-hq,8000,sndfile,bridge.fifo,.raw -o:jack,system
ecasound -f:s16_le,1,44100 -i:resample-hq,16000,sndfile,bridge2.fifo,.raw -o:alsahw,0,0
mkfifo bridge.fifo
sudo tcpdump -A -s 1500 -vvv -i wlan0 >> bridge.fifo &
ecasound -f:s16_le,1,44100 -i:resample-hq,16000,sndfile,bridge.fifo,.raw -o:jack,system
mkfifo bridge2.fifo
sudo tcpdump -A -s 0 -vvv -i wlan0 >> bridge2.fifo &
ecasound -f:s16_le,1,44100 -i:resample-hq,16000,sndfile,bridge2.fifo,.raw -o:jack,system

Streamer le tout : simple efficace

sox -t raw --ignore-length -r 44100 -e signed-integer -b 16  -c 2 bridge.fifo -t ogg -C 5 - | oggfwd labomedia.org 8000 rclabo01 /streamtest.ogg

-C est le facteur de qualité : 10 top gros, 0 light cardo, 3 défault 112kbps

Compliqué et lourd

ecasound  -f:s16_le,2,44100 -i:resample-hq,44100,sndfile,bridge.fifo,.raw  -o:stdout | sox -t raw --ignore-length -r 44100 -e signed-integer -b 16  -c 2 - -t wav - | avconv -i pipe: -aq 6 -f ogg - | oggfwd labomedia.org 8000 ***pwd*** /streamtest.ogg
sudo tcpdump -xx -vvv -s 0 -i eth0 | ecasound -f:s16_le,2,44100 -i:resample-hq,8000,sndfile,-,.raw -o:- | sox -t raw --ignore-length -r 8000 -e signed-integer -b 8  -c 2 - -t ogg -C 5 - | oggfwd stream.p-node.org 80 ****** /astreamtest.ogg
sudo tcpdump -xx -vvv -s 0 -i eth0 | ecasound -f:s16_le,2,8000 -i:resample-hq,8000,sndfile,-,.raw  -z:db,64 -o:- | sox -t raw --ignore-length -r 8000 -e signed-integer -b 8  -c 2 - -t ogg -C 5 - | oggfwd stream.p-node.org 80 **** /astreamtest.ogg

du core vers alsa

sudo tcpdump -A -vvv -s 1500 -i mon0 | aplay -i - -t raw --buffer-size=64 ultra core qd buffer empli
sudo tcpdump -xx -vvv -s 0 -i mon0 | aplay -i - -t raw --buffer-size=256
sudo tcpdump -xx -vvv -s 0 -i mon0 | aplay -i - -t raw --buffer-size=64 réactif !
 sudo tcpdump -x -s 64 -i mon0 | aplay -i - -t raw --buffer-size=64 core
sudo tcpdump -A -vvv -s 1500 -i wlan0 | aplay -D pcm.jack -i - -t raw --buffer-size=64

pour envoyer vers jack en ayant ajouté préalablement au .asoundrc

pcm.rawjack {
    type jack
    playback_ports {
        0 system:playback_1
        1 system:playback_2
    }
   capture_ports {
       0 system:capture_1
       1 system:capture_2
   }
}


pcm.jack {
    type plug
    slave { pcm "rawjack" }
    hint {
   description "JACK Audio Connection Kit"
    }
}

Pour envoyer vers jack :

aplay -i Bureau/exportRGB-84pitch.wav -v -D rawjack

mettre le nom du device dans .asoundrc rawjack

du core vers jack !

sudo tcpdump -A -vvv -s 1500 -i mon0 | aplay -i - -t raw --buffer-size=64 -r 48000 -c 2 -f  FLOAT_LE -v -D rawjack
sudo tcpdump -xx -vvv -s 0 -i mon0 | aplay -i - -t raw --buffer-size=64 -c 2 -f FLOAT_LE -v -D rawjack

mais son continu ?!

pas encore ça:

 sudo tcpdump -x -s 1500 -i wlan0 | avconv -acodec raw -ar 44100 -i - -v debug -b 768k tcpBB.wav
 sudo tcpdump -x -s 1500 -i wlan0 | avconv -acodec raw -ar 44100 -i - -v debug -id3v2_version 3 -write_id3v1 1 -b 768k tcpBB.wav

avconv pipe

      UNIX pipe access protocol.
      Allow to read and write from UNIX pipes.
      The accepted syntax is:
              pipe:[<html><number></html>  ]
      number is the number corresponding to the file descriptor of the pipe (e.g. 0 for stdin, 1 for stdout, 2
      for stderr).  If number is not specified, by default the stdout file descriptor will be used for writing,
      stdin for reading.
      For example to read from stdin with avconv:
              cat test.wav | avconv -i pipe:0
              # ...this is the same as...
              cat test.wav | avconv -i pipe:
      For writing to stdout with avconv:
              avconv -i test.wav -f avi pipe:1 | cat > test.avi
              # ...this is the same as...
              avconv -i test.wav -f avi pipe: | cat > test.avi
      Note that some formats (typically MOV), require the output protocol to be seekable, so they will fail with
      the pipe output protocol.

Packetpunk

https://github.com/znerol/packetpunk

sudo apt-get install libpcap0.8-dev

lancer jack en root sur carte son intel :

sudo /usr/bin/jackd -dalsa -r44100 -p512 -n8 -D -Chw:0 -Phw:0 -i2 -o2 -I2

lancer packetpunk

sudo ./packetpunk -s 1500 -i wlan0

lister les E/S de jack

jack_lsp

Connecter packetpung à jack

jack_connect "packetpunk:output" "system:playback_1" jack_connect "packetpunk:output" "system:playback_2"

Interface de jack

sudo qjackctl

Python OSC Sonic Pi

Sonification of netflow traffic - a netflow collector that processes and sends flows to be played by sonic-pi via the OSC protocol

Sonification serveur

Utilisation de promiscuous~ de Pure Data / ext13 et réalisation d'un stream > serveur icecast 2

apt-get install puredata pd-pdogg pd-ext13 icecast2

Pour v2, ajouter

apt install pd-ggee pd-zexy pd-iemlib

Création d'une carte son virtuelle :

modprobe snd-dummy

Pour rendre la création de la carte son virtuelle permanente :

nano /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.
snd-dummy

Pour debian jessie :

sudo nano /etc/modprobe.d/alsa.conf
# ALSA portion
alias char-major-116 snd
alias snd-card-0 snd-dummy
# module options should go here
 
# OSS/Free portion
alias char-major-14 soundcore
alias sound-slot-0 snd-card-0
 
# card #1
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss

The PD patch : anarchasonification.pdFile:anarchasonification.pd and to check the audio device :

puredata -nogui -listdev
audio input devices:
1. HDA Intel PCH (hardware)
2. HDA Intel PCH (plug-in)
3. Dummy (hardware)
4. Dummy (plug-in)
audio output devices:
1. HDA Intel PCH (hardware)
2. HDA Intel PCH (plug-in)
3. Dummy (hardware)
4. Dummy (plug-in)
API number 1

Not sure this step is necessary at the end …

To launch the patch :

puredata -nogui anarchasonification.pd

Labomedia's icecast server is configured in the patch for the moment … it should produce a devsonification.ogg on http://labomedia.org:8000

Variante Rasberry Pi avec Pick up

sudo apt install puredata pd-pdogg pd-ext13 pd-zexy pd-iemlib pd-ggee
sudo pd -nogui -listdev
sudo pd -nogui -audiodev 3 pnodelocalenetsonification-withoutpwd.pd

Le patch v2 pnodelocalenetsonification-withoutpwd.pd

To launch the patch at the server start-up with systemctl

nano /lib/systemd/system/omnioussonification.service

y mettre :

[Unit]
Description=Omnious Sonification Service

[Service]
ExecStart=/home/b01/omnioussonification.sh
StandardOutput=null

ExecStop=/bin/sh -c "killall pd"

[Install]
WantedBy=multi-user.target
Alias=omnioussonification.service

Créer un script dans par exemple /home/b01/omnioussonification.sh

#!/bin/bash
sudo puredata -nogui /home/b01/omnioussonification.pd
exit 0

Une variante sans script :

[Unit]
Description=Server Sonification net activity

[Service]
Type=simple
ExecStart=/usr/bin/pd -nogui -noaudio /data/pnode/algo/pnodelocalenetsonification.pd
StandardOutput=null
Restart=on-failure

# Configures the time to wait before service is stopped forcefully.
TimeoutStopSec=30

[Install]
WantedBy=multi-user.target
Alias=serversonification.service

commande magique pour prise en compte des modifs a posteriori dans le .service ?

sudo systemctl daemon-reload

lancer le service

sudo systemctl start omnioussonification.service

activer le service au démarrage du serveur

sudo systemctl enable omnioussonification.service

Sonification to PiFM

Doesn't work :

avconv -loglevel quiet -i [[http://radio.calafou:8000/omniussonification.ogg|  http://radio.calafou:8000/omniussonification.ogg]]   -ac 1 -ar 44100 -f s16le -|./pi_fm_rds -freq 88 -audio -

Sonification Wifi

Sonification réseau Pd Python

objet promiscous de ext13 dans pure data

sudo cat /dev/input/by-id/usb-Logitech_Logitech_USB_Optical_Mouse-event-mouse > /dev/dsp sudo cat /dev/video0 > /dev/dsp | affichage xterm info coreutils ’mknod invocation’ /sys/devices/virtual/net/lo/subsystem/wlan0

Un exemple : mknod /dev/null c 1 3 (c=character, 1=majeur, 3=mineur). La liste des numéros majeurs et mineurs se trouve dans /usr/src/linux/Documentation/devices.txt. Normalement, les kernels de la série 2.4 peuvent créer lors du besoin les descripteurs de périphériques s'ils utilisent devfs.

python sniff.py -i eth0 > /dev/dsp

voir http://www.binarytides.com/python-packet-sniffer-code-linux/

Autres logiciels de sonification du réseau

Sonification wikipedia

Sonification de diverses sources de données

Un joli exemple à partir de /dev/urandom d'après http://blog.robertelder.org/bash-one-liner-compose-music/

cat /dev/urandom | hexdump -v -e '/1 "%u\n"' | awk '{ split("0,2,4,5,7,9,11,12",a,","); for (i = 0; i < 1; i+= 0.0001) printf("%08X\n", 100*sin(1382*exp((a[$1 % 8]/12)*log(2))*i)) }' | xxd -r -p | aplay -c 2 -f S32_LE -r 16000

From Martin : As one of the (ir)responsible carvers (the other being Danja Vassiliev), the full command which danja used on the show was:

dd if=/dev/sdb | gst-launch-0.10 filesrc location=/dev/stdin ! queue ! tee name=v ! queue ! videoparse framerate=1 ! videoscale ! video/x-raw-yuv, width=40, height=30 ! videorate ! audioparse ! audiorate ! alsasink v. ! queue leaky=2 ! videoparse width=640 height=480 ! videoscale ! videorate ! xvimagesink sync=false

which also routes the HD data flow to the screen for unbroadcast visual feedback/fun!

Of course, as suggested a straight:

dd if=/dev/sdb of=/dev/dsp

would do the trcik albeit at a lower bitrate (and in both examples with /dev/sdb representing th USB-attached hard drive).

a test + jack

mplayer -demuxer rawaudio /dev/sdb -ao jack

might work (with more options to demuxer also).

Another option is:

cat /dev/sdb | ecasound -i stdin -o jack
arecord
arecord -D pulse

A test claude assuming jack is running at 48000 and want to resample from 8000

ecasound -f:s16_le,1,48000 -i:resample-hq,8000,sndfile,/usr/bin/mplayer,.raw -o:jack,system

is there something like a bridge, so i can route the audio signal to say supercollider 3 for further real time manipulations etc.anyone?

Marche !

mkfifo bridge.fifo
sudo cat /dev/mem >> bridge.fifo &
ecasound -f:s16_le,1,48000 -i:resample-hq,8000,sndfile,bridge.fifo,.raw -o:jack,system

Commands

find . -name '*.exe' -exec cat {} > /dev/audio \;
type cat /dev/fb > /dev/dsp type cat /dev/core > /dev/dsp type cat /dev/sr0 > /dev/dsp type cat /dev/sda > /dev/dsp type cat /dev/mem > /dev/dsp type curl [[http://en.wikipedia.org/wiki/Music|  http://en.wikipedia.org/wiki/Music]]   > /dev/dsp

make some noise !!!! Merci www.commandlinefu.com pour l'idée de base

sudo cat /dev/urandom | aplay aplay interprète le code brut
sudo cat /dev/urandom | hexdump converti les caratères en hexa
sudo tcpdump -i -vv wlan0
mplayer -vo aa:width=250:height=80 theoriedescordes.flv mplayer -vo caca -framedrop goodeveningDVgood.avi

adds a header to a raw audio file

sox -r 8000 -u -1 -c 1 voice-memo.raw voice-memo.wav

concatenates two audio files, and

sox -m music.mp3 voice.wav mixed.flac

We can also use sox to convert a raw file to another format. In this case, we have to supply some information about the raw file:

sox -r 441000 -s -w foo.raw foo.wav

Lanceur Pure Data

#!/bin/bash
 
qjackctl  &
#xterm -e "sleep 5;pdextended -rt -jack -nosleep -open /media/Data/INTEGRATIONS/PATCHES/INTEGSON.pd" &
xterm -e "sleep 4;pdextended -rt -jack -nosleep -open /media/Data/INTEGRATIONS/PATCHES/INTEGTLIMAGE.pd " &
# {qjackctl & ; pdextended -rt -jack -channels 12 12 -stderr -nosleep -open /media/Data/INTEGRATIONS/PATCHES/INTEGRATIONS.pd & ; pdextended -nodac -noadc -stderr -open /media/Data/INTEGRATIONS/PATCHES/INTEGRATIONS.pd & ; }

Ressources complémentaires

Récup nom de fichier, extension en commençant par éliminer le chemin avec basename

filename=$(basename "$fullfile")
extension="${filename##*.}"
filename="${filename%.*}"

Pour finir, une sonification de données opérée par Brian Eno sur un projet de Forensic Architecture à propos de NSO Group et Pegasus