Projet: Mettre Réaliser des watterfall à balayage lent éventuellement pour la QRSS.
Il faudra améliorer la commande SOX pour caler en fréquence et en définissions.
Version 2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
#!/bin/bash #####Adjust variables###### soundcarddevice=dsnoop:lloop2,1 band=2200m totaldurationmin=60 refreshintervalmin=2 withp=1000 heightp=400 debug=true shmdir=/dev/shm #####Adjust variables end###### #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$shmdir/QRSS/$band" finaldestinationfile="$shmdir/QRSS/stats" largeurbyimag=$(($withp / $(($totaldurationmin / $refreshintervalmin)))) ps aux | grep -v grep | grep -ie arecord | grep $soundcarddevice | awk '{print $2}' | xargs kill -9 mkdir -p $DIR/wav mkdir -p $DIR/png mkdir -p $finaldestinationfile if $debug; then echo "wait for 0s to start"; fi while [[ $(date +%S) -ne 0 ]] ; do if $debug; then echo -n "."; fi sleep 1 done if $debug; then echo -e "\nStart to record"; fi rm $DIR/wav/* 2>/dev/null #rm $DIR/png/* 2>/dev/null arecord -c 2 --device=$soundcarddevice --file-type=wav --format=S16_LE --rate=48000 --max-file-time $(($refreshintervalmin * 60)) $DIR/wav/$band.wav > /dev/null 2>&1 & while true ;do for x in $(ls -tr $DIR/wav/$band-*.wav 2>/dev/null | head -n -1 2>/dev/null | xargs -n 1 basename 2>/dev/null); do if [ -z "$x" ]; then break fi atdate=$(stat -c %Y $DIR/wav/$x ) atime=$(date -d "1970-01-01 $atdate sec UTC" +%H:%M:%S) atdate=$(date -d "1970-01-01 $atdate sec UTC" +%Y%m%d_%H%M%S) sox $DIR/wav/$x -r 6000 $DIR/wav/m$x remix 1-2 gain +10 rm $DIR/wav/$x sox $DIR/wav/m$x -n spectrogram -x 960 -y 480 -r -o $DIR/png/A$atdate.png convert $DIR/png/A$atdate.png -brightness-contrast 30x70 $DIR/png/A$atdate.png convert $DIR/png/A$atdate.png -resize $largeurbyimag"x"$heightp\! $DIR/png/B$atdate.png convert $DIR/png/B$atdate.png -set option:my:left_edge '0,%[fx:h*0.92]' \ \( -background none label:"$atime" \ +distort SRT '%[fx:w/2],%h 1 90 %[my:left_edge]' \ \) -flatten $DIR/png/C$atdate.png rm $DIR/png/B$atdate.png rm $DIR/wav/m$x if $debug; then echo "$x to $DIR/png/$atdate.png done"; fi done if ! [ -z "$(ls -t $DIR/png/C*.png 2>/dev/null)" ]; then images="" lastdate=$(ls -t $DIR/png/C*.png 2>/dev/null | head -n +1 2>/dev/null) lastdate=$(stat -c %Y $lastdate) lastdate=$(date -d "1970-01-01 $lastdate sec UTC" "+%H:%M:%S %d/%m/%Y") for x in $(ls -t $DIR/png/C*.png 2>/dev/null | head -n +30 2>/dev/null); do images="$x $images" done convert $images +append -resize $withp"x"$heightp\! -gravity north -stroke "#000C" -strokewidth 2 -annotate 0 "F4KJI update at $lastdate" -stroke none -fill white -annotate 0 "F4KJI update at $lastdate" $DIR/temp$band.png for x in $(ls -tr $DIR/png/C*.png 2>/dev/null| head -n -30); do rm $x done for x in $(ls -tr $DIR/png/A*.png 2>/dev/null| head -n -30); do rm $x done i=0 for x in $(ls -t $DIR/png/C*.png 2>/dev/null | head -n +30 2>/dev/null); do if $debug; then echo "copy "$x" to "$finaldestinationfile"/"$band"_"$i"_s.png"; fi cp --force "$x" $finaldestinationfile"/"$band"_"$i"_s.png" i=$(($i + 1)) done i=0 for x in $(ls -t $DIR/png/A*.png 2>/dev/null | head -n +30 2>/dev/null); do if $debug; then echo "copy "$x" to "$finaldestinationfile"/"$band"_"$i"_L.png"; fi cp --force "$x" $finaldestinationfile"/"$band"_"$i"_L.png" i=$(($i + 1)) done if $debug; then echo "copy $DIR/temp$band.png to $finaldestinationfile/$band.png"; fi cp --force $DIR/temp$band.png $finaldestinationfile/$band.png fi if $debug; then echo "wait for next"; fi sleep $(( $(($refreshintervalmin / 2)) * 60 )) done trap "ps aux | grep -v grep | grep -ie arecord | grep $soundcarddevice | awk '{print $2}' | xargs kill -9" EXIT #sox command #-x num X#-axis size in pixels; default derived or 800 #-X num X#-axis pixels/second; default derived or 100 #-y num Y#-axis size in pixels (per channel); slow if not 1 + 2^n #-Y num Y#-height total (i.e. not per channel); default 550 #-z num Z#-axis range in dB; default 120 #-Z num Z#-axis maximum in dBFS; default 0 #-q num Z#-axis quantisation (0 #- 249); default 249 #-w name Window: Hann (default), Hamming, Bartlett, Rectangular, Kaiser #-W num Window adjust parameter (#-10 #- 10); applies only to Kaiser #-s Slack overlap of windows #-a Suppress axis lines #-r Raw spectrogram; no axes or legends #-l Light background #-m Monochrome #-h High colour #-p num Permute colours (1 #- 6); default 1 #-A Alternative, inferior, fixed colour#-set (for compatibility only) #-t text Title text #-c text Comment text #-o text Output file name; default `spectrogram.png' #-d time Audio duration to fit to X#-axis; e.g. 1:00, 48 #-S time Start the spectrogram at the given time through the input |
Version 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
#!/bin/bash #####Adjust variables###### soundcarddevice=dsnoop:lloop3,1 band=630m totaldurationmin=60 refreshintervalmin=2 withp=1000 heightp=400 finaldestinationfile=/home/opf4kji/F4KJIPRODUCTION/websdr/pub/QRSS/$band.png debug=true shmdir=/dev/shm #####Adjust variables end###### #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$shmdir/QRSS/$band" largeurbyimag=$(($withp / $(($totaldurationmin / $refreshintervalmin)))) ps aux | grep -v grep | grep -ie arecord | grep $soundcarddevice | awk '{print $2}' | xargs kill -9 mkdir -p $DIR/wav mkdir -p $DIR/png if $debug; then echo "wait for 0s to start"; fi while [[ $(date +%S) -ne 0 ]] ; do if $debug; then echo -n "."; fi sleep 1 done if $debug; then echo -e "\nStart to record"; fi rm $DIR/wav/* 2>/dev/null #rm $DIR/png/* 2>/dev/null arecord -c 2 --device=$soundcarddevice --file-type=wav --format=S16_LE --rate=48000 --max-file-time $(($refreshintervalmin * 60)) $DIR/wav/$band.wav > /dev/null 2>&1 & while true ;do for x in $(ls -tr $DIR/wav/$band-*.wav 2>/dev/null | head -n -1 2>/dev/null | xargs -n 1 basename 2>/dev/null); do if [ -z "$x" ]; then break fi atdate=$(stat -c %Y $DIR/wav/$x ) atime=$(date -d "1970-01-01 $atdate sec UTC" +%H:%M:%S) atdate=$(date -d "1970-01-01 $atdate sec UTC" +%Y%m%d_%H%M%S) sox $DIR/wav/$x -r 6000 $DIR/wav/m$x remix 1-2 rm $DIR/wav/$x sox $DIR/wav/m$x -n spectrogram -x 480 -y 240 -r -o $DIR/png/f$atdate.png convert $DIR/png/f$atdate.png -resize $largeurbyimag"x"$heightp\! $DIR/png/ff$atdate.png rm $DIR/png/f$atdate.png convert $DIR/png/ff$atdate.png -set option:my:left_edge '0,%[fx:h*0.92]' \ \( -background none label:"$atime" \ +distort SRT '%[fx:w/2],%h 1 90 %[my:left_edge]' \ \) -flatten $DIR/png/f$atdate.png rm $DIR/png/ff$atdate.png rm $DIR/wav/m$x if $debug; then echo "$x to $DIR/png/$atdate.png done"; fi done if ! [ -z "$(ls -t $DIR/png/*.png 2>/dev/null)" ]; then images="" lastdate=$(ls -t $DIR/png/*.png 2>/dev/null | head -n +1 2>/dev/null) lastdate=$(stat -c %Y $lastdate) lastdate=$(date -d "1970-01-01 $lastdate sec UTC" "+%H:%M:%S %d/%m/%Y") for x in $(ls -t $DIR/png/*.png 2>/dev/null | head -n +30 2>/dev/null); do images="$x $images" done convert $images +append -resize $withp"x"$heightp\! -gravity north -stroke '#000C' -strokewidth 2 -annotate 0 "F4KJI update at $lastdate" -stroke none -fill white -annotate 0 "F4KJI update at $lastdate" $DIR/temp$band.png for x in $(ls -tr $DIR/png/*.png 2>/dev/null| head -n -30); do rm $x done if $debug; then echo "copy $DIR/temp$band.png to $finaldestinationfile"; fi cp --force $DIR/temp$band.png $finaldestinationfile fi if $debug; then echo "wait for next"; fi sleep $(( $(($refreshintervalmin / 2)) * 60 )) done trap "ps aux | grep -v grep | grep -ie arecord | grep $soundcarddevice | awk '{print $2}' | xargs kill -9" EXIT #sox command #-x num X#-axis size in pixels; default derived or 800 #-X num X#-axis pixels/second; default derived or 100 #-y num Y#-axis size in pixels (per channel); slow if not 1 + 2^n #-Y num Y#-height total (i.e. not per channel); default 550 #-z num Z#-axis range in dB; default 120 #-Z num Z#-axis maximum in dBFS; default 0 #-q num Z#-axis quantisation (0 #- 249); default 249 #-w name Window: Hann (default), Hamming, Bartlett, Rectangular, Kaiser #-W num Window adjust parameter (#-10 #- 10); applies only to Kaiser #-s Slack overlap of windows #-a Suppress axis lines #-r Raw spectrogram; no axes or legends #-l Light background #-m Monochrome #-h High colour #-p num Permute colours (1 #- 6); default 1 #-A Alternative, inferior, fixed colour#-set (for compatibility only) #-t text Title text #-c text Comment text #-o text Output file name; default `spectrogram.png' #-d time Audio duration to fit to X#-axis; e.g. 1:00, 48 #-S time Start the spectrogram at the given time through the input |