======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 ==== * discussion autour de la généèse du ping et de sonification http://linuxgazette.net/158/misc/lg/2_cent_tip__audio_ping.html * l'article de base http://ftp.arl.mil/~mike/ping.html 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 * pour faire marcher l'option "-a" http://askubuntu.com/questions/15963/why-cant-i-hear-audible-pings soit sous linux * charger le module sudo modprobe pcspkr et tester avec echo -e "\a" * et / ou activer les sons systèmes de son gestionnaire de fenetre 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** * -A pour sortie lisible en ascii * -s 0 Snarf snaplen bytes of data from each packet rather than the default of 65535 bytes (et 0 = default = 65553) * port http filtre et ne garde que le trafic web * -vvv pour +/- de verbosité * -x When parsing and printing, in addition to printing the headers of each packet, print the data of each packet (minus its link level header) in hex. The smaller of the entire packet or snaplen bytes will be printed. Note that this is the entire link-layer packet, so for link layers that pad (e.g. Ethernet), the padding bytes will also be printed when the higher layer packet is shorter than the required padding. * -xx When parsing and printing, in addition to printing the headers of each packet, print the data of each packet, including its link level header, in hex. * -X When parsing and printing, in addition to printing the headers of each packet, print the data of each packet (minus its link level header) in hex and ASCII. This is very handy for analysing new protocols. * -XX When parsing and printing, in addition to printing the headers of each packet, print the data of each packet, including its link level header, in hex and ASCII. * Option filtre tcpdump http://www.axllent.org/docs/networking/tcpdump/ * http://argoat.net/Blog/?tag=tcpdump 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 * Pour régler ecasound : http://nosignal.fi/ecasound-list/2002/11/0032.html * voir également https://ecasound.seul.org/ecasound/Documentation/examples.html * tcdump options https://www.comparitech.com/net-admin/tcpdump-cheat-sheet/ === 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:[ ]       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 * https://github.com/imperva/soti ==== 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 * http://superuser.com/questions/344760/how-to-create-a-dummy-sound-card-device-in-linux-server 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 * http://www.alsa-project.org/main/index.php/Matrix%3aModule-dummy The PD patch : {{ media_02:anarchasonification.pd |}}File: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 {{ media_11: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 ==== * Carnivore, librairie Processing http://r-s-g.org/carnivore/ * Sources : https://github.com/RSG/Carnivore * Fonctionne avec Pocessing 2.1 su linux 64 bits * Pure data : PCAP objet Pd http://musa.poperbu.net/index.php/tecnologia-seccions-30/-puredata-seccions-45/97-pcap-forpd-005-pdpcap-renamed * Objet Pd promiscous de ext13 * Avec FoxDot SuperCollider et Tcpdump https://codercat.tk/wifi-soundscapes/index.html ==== 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 ==== * k20 qui transforme le trafic réseau vu de kismet en paquets OSC http://k2o.znerol.ch/ * En-têtes > midi http://www.smokinggun.com/projects/soundoftraffic/ * Sonodump (pour mac ?) https://github.com/mrkva/Sonodump * Listening back un firefox / chrome plug-in pour écouter / sonifier les cookies déposés sur notre ordinateur par les sites https://addons.mozilla.org/fr/firefox/addon/listening-back/ https://media.ccc.de/v/36c3-10855-listening_back_browser_add-on_tranlates_cookies_into_sound * Python OSC Sonic Pi https://github.com/imperva/soti ===== Sonification wikipedia ===== * WikikIRC en python Raspberry i2c voir [[WikikIRC_Mécanique|version mécanique]] {{vimeo>54803321}} ===== 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 ===== * Guide du bash http://mywiki.wooledge.org/BashGuide * de zolis exemples http://www.infographiste-prod.ch/la_hyene/?p=313 * des exemples http://tldp.org/LDP/abs/html/ * bashing script tuto http://linuxconfig.org/bash-scripting-tutorial * > /dev/null 2>&1 http://lanterne-rouge.over-blog.org/article-que-signifie-dev-null-2-1-70233357.html * Parametres expansion http://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion * Bash redirection et flux https://fr.wikibooks.org/wiki/Programmation_Bash/Flux_et_redirections 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 {{vimeo>563641014?medium}} {{tag>bj logiciels_audio linux bash}}