@@ -55,6 +55,7 @@ <h3><a name="Examples"></a> Examples</h3>
5555 < li > < a href ="#hog_setup "> HOG setup</ a > </ li >
5656 < li > < a href ="#dnn_setup "> DNN setup</ a > </ li >
5757 < li > < a href ="#haar_train "> Haar Model Training</ a > </ li >
58+ < li > < a href ="#sound_sample "> Sound Frequency Sample</ a > </ li >
5859 < p > </ p >
5960 < p > </ p >
6061 </ ul >
@@ -353,6 +354,94 @@ <h3><a name="haar_train"></a>Haar Model Training</h3>
353354
354355 </ ul >
355356
357+ < h3 > < a name ="sound_sample "> </ a > Sound Frequency Sample</ h3 >
358+ < ul >
359+ Since sound frequency processing is new to MotionPlus, the following provides an illustrative sample of setting
360+ up the sound and the associated alerts processing. This example will use ALSA. For PulseAudio, MotionPlus uses
361+ the default audio recording device. Although MotionPlus has parameters for the PulseAudio server and device,
362+ the set up is not straight forward and it is just recommended to change the PulseAudio default.
363+ < br >
364+ < br > Go to the command prompt and use < small > < code > arecord -l</ code > </ small > to get the
365+ device name such as < small > < code > hw:1,0</ code > </ small >
366+ < br > Specify log_level 8 in MotionPlus.conf
367+ < br > Do not specify a log file so that it is console output.
368+ < br > Specify snd_device and snd_show in the sound configuration file such as
369+ < br > < small > < code > snd_device hw:1,0</ code > </ small >
370+ < br > < small > < code > snd_show on</ code > </ small >
371+ < br > Start MotionPlus and make a noise to test the output.
372+ < br > Once MotionPlus responds to sounds, press the test button on the device to be monitored.
373+ < br > Note that while the various devices being monitored may be the same, the detected frequency from
374+ each may be slightly different. Care should be taken to not be too precise in the setting of the alert
375+ range for MotionPlus. For example, the frequency may be reported as 3402.2456 and MotionPlus can be
376+ set up to look for that precise number but devices age and the frequency may change. Also, note that the
377+ frequency resolution of MotionPlus is limited by the sample rate and frames from the audio device.
378+ The maximum resolution is determined by the following formula. Sample Rate / (frames * 2). So with the
379+ default sample rate of 44100hz, and frames of 2048, the maximum resolution is appoximately 10.7666hz. This
380+ means that the frequencies detected around the range reported above would be 3413.0122, 3402.2456
381+ or 3391.4790 and no values between.
382+ < br > Once the frequencies of all the devices have been logged, set up the alerts in the sound configuration
383+ file as well as the on_sound_alert and turn off the showing of frequencies. (The frequencies in this sample
384+ are random)
385+ < small > < code > < ul >
386+ < br > snd_alerts alert_id=01,volume_level=01,volume_count=10,freq_low=2976,freq_high=2977,alert_nm=smokedown1
387+ < br > snd_alerts alert_id=02,volume_level=01,volume_count=10,freq_low=3400,freq_high=3450,alert_nm=smokelr
388+ < br > snd_alerts alert_id=03,volume_level=01,volume_count=10,freq_low=3388,freq_high=3399,alert_nm=smokebr1
389+ < br > snd_alerts alert_id=11,volume_level=01,volume_count=10,freq_low=3378,freq_high=3379,alert_nm=furnace
390+ < br > snd_alerts alert_id=22,volume_level=01,volume_count=10,freq_low=3281,freq_high=3399,alert_nm=waterheater
391+ < br > snd_alerts alert_id=22,volume_level=01,volume_count=10,freq_low=3270,freq_high=3279,alert_nm=kitchBath
392+ < br > snd_show off
393+ < br > on_sound_alert %{trig_nbr} %{trig_nm} %{trig_freq}
394+ < br >
395+ </ ul > </ code > </ small >
396+ Then you can set up a script to send email or text messages using the sendemail
397+ application like below
398+ < small > < small > < code >
399+ < ul >
400+ < br > #!/bin/bash
401+ < br > ALRTNBR=$1
402+ < br > ALRTNM=$2
403+ < br > FREQ=$3
404+ < br > ATCH=$4
405+ < br > MYSTR=""
406+ < br > MYSTR=$MYSTR" -f \"Friendly Name < SendingEmailAddress @gwhatever.com > \" "
407+ < br > MYSTR=$MYSTR" -t \"DestinationEmailAddress@gwhatever.com\" "
408+ < br > MYSTR=$MYSTR" -u \"MotionPlus Notification\" "
409+ < br > MYSTR=$MYSTR" -s \"smtp.gwhatever.com:587\" "
410+ < br > MYSTR=$MYSTR" -xu \"SendingEmailAddress@gwhatever.com\" "
411+ < br > MYSTR=$MYSTR" -xp \"SendingEmailPassword\" "
412+ < br > BODY=""
413+ < br > if [[ "$ALRTNBR" -ge 1 && "$ALRTNBR" -le 9 ]]; then
414+ < br > BODY="So, hey. Sorry to bother you. But thought I'd just let"
415+ < br > BODY=$BODY" you know that your house is burning down. The neighbors"
416+ < br > BODY=$BODY" may get annoyed so you should think about doing something. "
417+ < br > BODY=$BODY" The "$ALRTNM" alert numbered "$ALRTNBR" was triggered with "
418+ < br > BODY=$BODY" frequency "$FREQ
419+ < br > elif [[ "$ALRTNBR" -ge 10 && "$ALRTNBR" -le 19 ]]; then
420+ < br > BODY="Hi. So I noticed that the natural gas leak alarm is going off."
421+ < br > BODY=$BODY" Nothing too urgent or anything but when you get home, you"
422+ < br > BODY=$BODY" may want to hold off making any sparks to avoid blowing yourself up."
423+ < br > BODY=$BODY" The "$ALRTNM" alert numbered "$ALRTNBR" was triggered with "
424+ < br > BODY=$BODY" frequency "$FREQ
425+ < br > elif [[ "$ALRTNBR" -ge 20 && "$ALRTNBR" -le 29 ]]; then
426+ < br > BODY="Ahoy! Your house is going to be next water park attraction in"
427+ < br > BODY=$BODY" the neighborhood!!! The water is filling it up and the"
428+ < br > BODY=$BODY" children will be splashing around in it soon."
429+ < br > BODY=$BODY" The "$ALRTNM" alert numbered "$ALRTNBR" was triggered with "
430+ < br > BODY=$BODY" frequency "$FREQ
431+ < br > fi
432+ < br > if [ "$BODY" != "" ]; then
433+ < br > MYSTR=$MYSTR" -m \""$BODY"\" "
434+ < br > if [ -f "$ATCH" ]; then
435+ < br > MYSTR=$MYSTR" -m \""$ATCH"\" "
436+ < br > fi
437+ < br > sendemail $MYSTR
438+ < br > fi
439+ < br > exit 0
440+ </ ul >
441+ </ code > </ small > </ small >
442+
443+ </ ul >
444+
356445
357446 </ section >
358447 </ body >
0 commit comments