{"id":13433,"date":"2016-10-24T10:11:44","date_gmt":"2016-10-24T14:11:44","guid":{"rendered":"http:\/\/scruss.com\/blog\/?p=13433"},"modified":"2024-06-16T21:07:53","modified_gmt":"2024-06-17T01:07:53","slug":"making-an-hourly-chime-with-cron","status":"publish","type":"post","link":"https:\/\/scruss.com\/blog\/2016\/10\/24\/making-an-hourly-chime-with-cron\/","title":{"rendered":"making an hourly chime with cron"},"content":{"rendered":"<p><strong>Update<\/strong>: <span style=\"color: #ff0000;\">this is old and, like most good things in X, likely has been broken by Wayland<\/span>.<\/p>\n<p>I wanted to have a \u201c<em>Hey, be here now!\u201d<\/em>\u009d ping throughout the working day. Something loud enough to hear, but not irritating.<\/p>\n<p>Doing this with cron was harder than you might expect. It seems that sound is typically part of the X11 display infrastructure, so you need to give the command permission to make a noise on this particular machine&#8217;s display. Here&#8217;s the crontab line I came up with:<\/p>\n<pre># m h\u00a0   dom mon dow \u00a0 command\n  0 9-17 *   *   1-5   export DISPLAY=:0 &amp;&amp; \/usr\/bin\/play -q \/home\/scruss\/sounds\/ting\/ting.wav<\/pre>\n<p>That translates as: at 0 minutes past the hours of 09:00 to 17:00 on any weekday (day of week = 1-5, and we don&#8217;t care about day of month or which month it is), execute the command <strong>play<\/strong> (part of the <em>sox<\/em> package) with no text output (-q). cron needs environment variables like <strong>DISPLAY<\/strong> set, and prefers full command paths. It may trigger a second or so after the turn of the hour; this is good enough for me.<\/p>\n<p>As for the alert, I wanted something distinctive \u2014 percussive, short, bright \u2014 but with a tiny bit of modulation to stop it sounding like a bland computer-generated sine wave. This is what I made; click on the image and the sound <em>should<\/em> play or download:<\/p>\n<p><a href=\"http:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2016\/10\/ting.wav\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-13435\" src=\"http:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2016\/10\/ting-audacity.png\" alt=\"ting-audacity\" width=\"887\" height=\"343\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2016\/10\/ting-audacity.png 887w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2016\/10\/ting-audacity-160x62.png 160w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2016\/10\/ting-audacity-320x124.png 320w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2016\/10\/ting-audacity-768x297.png 768w\" sizes=\"auto, (max-width: 887px) 100vw, 887px\" \/><\/a>It&#8217;s essentially a 2093 Hz (C\u2087) sine wave, mixed with itself frequency-modulated at 7 Hz. Why 7 Hz? Apart from sounding about right, 2093 is exactly divisible by 7, 13 &amp; 23, so I used a factor for neatness.<\/p>\n<p>There was some later messing about in Audacity (mostly fades and length edits; I forget exactly what). The two components were generated using sox:<\/p>\n<pre>sox -n ting-plain.wav synth 1 sine C7 fade l 0 1 1\n sox -n ting-vibrato.wav synth 1 sin C7 synth 1 sine fmod 7 fade l 0 1 1<\/pre>\n<p>Yes, sox does have pretty horrible syntax, doesn&#8217;t it?<\/p>\n<p>The frequency-modulated one seems to be pretty close to the final result. It would be less time spent trying to save time \u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update: this is old and, like most good things in X, likely has been broken by Wayland. I wanted to have a \u201cHey, be here now!\u201d\u009d ping throughout the working day. Something loud enough to hear, but not irritating. Doing this with cron was harder than you might expect. It seems that sound is typically [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7],"tags":[1102,1466,270,2510,1487],"class_list":["post-13433","post","type-post","status-publish","format-standard","hentry","category-computers-suck","tag-audacity","tag-cron","tag-linux","tag-raspberrypi","tag-sox"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pQNZZ-3uF","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/13433","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/comments?post=13433"}],"version-history":[{"count":5,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/13433\/revisions"}],"predecessor-version":[{"id":17575,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/13433\/revisions\/17575"}],"wp:attachment":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/media?parent=13433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/categories?post=13433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/tags?post=13433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}