making an alarm clock with Sonic-Pi [raspberrypi]

create the alarm.wav file:
—————————

start Sonic-Pi:
menu->programming->Sonic-Pi

copy this code and paste it into Sonic-Pi:
86.times do
use_synth :pulse
play 90, release: 0.13
sleep 0.12
play 90, release: 0.13
sleep 1.28
end
#0.12+1.28=1.4 sec each sample
#->120/1.4 ~86 ->you have to repeat it 86 times for a 2 minute beep

test the alarm clock sound:
press once the "Run" button in Sonic-Pi
(the song will play once ~120 sec)
if it works fine press the "Stop" button

record the song:
press once the "Rec" button
press once the "Run" button
(when the song is over)
press again the "Rec" button
save the file on your desktop named "alarm.wav"

using crontab to play the file at a special time everyday:
———————————————————-

requires a mpd installation:
https://fredfire1.wordpress.com/2013/08/16/install-mpd-raspberry-pi/

move the file to the mpd music library:
mv /home/pi/Desktop/alarm.wav /var/lib/mpd/music/alarm.wav

update the mpd library:
mpc update

edit the crontab with running in terminal:
crontab -e

then add at the end the following line:
30 6 * * * mpc playlist>tempplaylist && mpc del $(grep -n alarm.wav tempplaylist | cut -d : -f 1) && mpc add alarm.wav && mpc volume 100 && mpc play $(mpc playlist | wc -l) && mpc repeat off
#now your alarm will ring everyday at 6:30

exit and safe the crontab:
press "ctrl+x" ->"y" ->"enter"

you can stop the alarm with the mpdroid app:
https://play.google.com/store/apps/details?id=com.namelessdev.mpdroid

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s