initial commit
[ETG_Helmet] / SOFTWARE / OMEGA2 / transmitter.sh
1 #/bin/bash
2
3 if [ "$TMPFS" == "" ]; then 
4         . "common.sh"
5 fi
6
7 $$ > $PID/$0
8
9 # echo $TMPFS, $MAX_REC_TIME, 
10
11 setMicVolume $REC_MIC_VOL
12
13 while [ 1 ]; do
14
15         if [ -s $recStart ]; then # if recording was initiated
16
17                 echo 'RECMIC' >> $TMPFS/$message        # it is necessary to put message to iniciate wait loop
18                         
19                 sleep 1
20
21                 setMicVolume $REC_MIC_VOL
22                 beep
23
24 #               sleep 1
25
26                 # recording TODO: fork and kill when button released
27
28                 echo "rec start..." | myLog
29
30                 {
31                         sleep 1 # wait for arecord started
32                         cntK=0
33                         while [ 1 ]; do
34                                 cntK=$(( $cntK + 1 ))
35                                 sleep 1
36                                 if [ "$cntK" -gt "$(($MAX_REC_TIME + 2))" ]; then 
37                                         kill -15 $(cat /tmp/rec.pid)
38                                         echo killed | myLog
39                                         break
40                                 fi
41                         done
42                 } &
43
44 #               rec -c 1 "$RECTMP" gain -25 bass +60 highpass 10 trim 1 $MAX_REC_TIME
45 #               rec -b 16 -c 1 -e gsm-full-rate "$RECTMP" highpass 10 trim 1 $MAX_REC_TIME
46 #               rec -b 16 -c 1 "$RECTMPRAW" trim 1 $MAX_REC_TIME
47 #               arecord -N --fatal-errors -r 48000 -f S16 "$RECTMPRAW" | myLog
48 #               arecord -N -d $MAX_REC_TIME -r 48000 -f S16 "$RECTMPRAW" 2>&1 1>/dev/null
49                 arecord -N -M -d $MAX_REC_TIME --process-id-file /tmp/rec.pid -r 48000 -f S16 "$RECTMPRAW" 2>&1 1>/dev/null
50
51 #               sleep 1
52
53                 if [ ! -s "$NOISEPROFILE" ]; then 
54                         beep
55                         echo "noiseprof..." | myLog
56                         sox "$RECTMPRAW" -n trim 0 1 noiseprof "$NOISEPROFILE"
57                         playRoboMessage "Noise profile created. Now you can send audio messages to another devices."
58
59                         : > $recStart
60 #                       echo $DEV_JINGLE_OUT >> $TMPFS/$message
61                 else 
62
63                         # filtering 
64                         echo "filtering..." | myLog
65                         playRoboMessage "Sound filtering"
66
67                         : > $recStart
68 #                       echo $DEV_JINGLE_OUT >> $TMPFS/$message
69
70                         sox "$RECTMPRAW" "$RECTMP" noisered "$NOISEPROFILE" 0.5 lowpass 1000 norm $REC_ADD_PROCESSING
71
72                         # sending 
73                         echo "transmition..." | myLog
74 ##                      beep
75
76                         cat /proc/net/arp | grep $BASE_IP_MASK | awk '{print $1}' | while read -r IP ; do
77         #               echo 20.0.0.126 | while read -r IP ; do
78         #                       cat "$RECTMP" | netcat $IP 1234
79                                 echo "cat "$RECTMP" | socat - TCP:$IP:1234" | myLog
80                                 cat "$RECTMP" | socat - TCP:$IP:1234
81                         done
82
83                         # echo complete...
84                         echo "transmition complete" | myLog
85 ##                      beep
86                 fi
87
88 #               setVolume $cVolume
89
90                 # finishing
91 ##              : > $recStart
92 ##              echo $DEV_JINGLE_OUT >> $TMPFS/$message
93         fi 
94
95         sleep 1
96 done
Contact me: dev (at) shalnoff (dot) com
PGP fingerprint: A6B8 3B23 6013 F18A 0C71 198B 83D8 C64D 917A 5717