#Wakeup by Dale Swanson May 8th 2010 #Gradual volume ramp up script for Foobar2000. Used as my alarm. #Tested on Foobar2000 v1.0 #uses NirCmd to unmute and max system volume, if you don't have it installed you'll just have to do that manually #http://www.nirsoft.net/utils/nircmd.html #!/usr/bin/perl use strict; use warnings; use Cwd; my $foo = "C:\\Program Files\\foobar2000\\"; #file path of foobar2000 my $pause = 3; #time in seconds between volume up steps my $speed=2; #speed of volume ramp up, 0-slow, #1-fast, slow~50mins, fast~4mins (2=enter speed) my $sleep; #time in seconds to sleep for my $endtime; #wakeup time my $time; #current time while ($speed != 0 && $speed != 1) {#main loop, will run until user gives us a 0 or 1 for slow or fast wakeup, also gets time in hours to delay ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); #current time $time = sprintf("%4d-%02d-%02d %02d:%02d:%02d\n", $year+1900, $mon+1, $mday, $hour, $min, $sec); print "\nIt is currently: $time"; print "\nEnter number of hours to wait "; $sleep = ; #time in hours to sleep, we will make it seconds later chomp($sleep); #newlines print "\nIn $sleep hours it will be "; $sleep *= 60*60; #convert from hours to seconds ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time+$sleep); #wakeup time $endtime = sprintf("%4d-%02d-%02d %02d:%02d:%02d\n", $year+1900, $mon+1, $mday, $hour, $min, $sec); print "$endtime"; print "\nChoose slow wakeup - 0, or fast wakeup - 1, or change time - 2 "; $speed = ; chomp ($speed); } system("CLS"); print "Current - $time"; print "Wake up - $endtime"; print "\nGoing to sleep for ", $sleep/3600, " hours, followed by a "; if ($speed==1) {print "fast";} if ($speed==0) {print "slow";} print " wakeup...\n"; #go to sleep sleep ($sleep); #wakeup time print "Wakeup!\n"; chdir "$foo"; #makes our working directory the one with foobar2000 system "foobar2000"; #starts foobar, in case it's not running sleep (5); #wait 5 seconds to give it a chance to actually start before issuing commands system "foobar2000 /stop"; #stop current music system "nircmd mutesysvolume 0"; #unmutes system volume, uses NirCmd system "nircmd setsysvolume 65535"; #maxes system volume, uses NirCmd for ($x=0;$x<110;$x++) {#lower foobar volume, should only need 100 steps, but do 110 for fun system "foobar2000 /command:\"Down\""; print "Step - $x\n"; } system "foobar2000 /play"; #start music, foobar volume is at 0 for ($x=0;$x<30;$x++) {#it takes about 30 steps to be able to start hearing the music at all so just do that fast system "foobar2000 /command:\"Up\""; if (!$speed) {sleep(3);} #if we are in slow mode wait 3 seconds between steps, fast mode no wait } $pause=20;#the begining pause length between steps for ($x=0;$x<110;$x++) {#after 30 steps the music should barely be audible, start slowly steping it up if ($speed==0) {$pause *= 1.02;} #slow speed = larger pauses between steps if ($speed==1) {$pause = $x/10;} #fast speed = shorter pauses between steps system "foobar2000 /command:\"Up\""; print "Step - $x, Pause - $pause\n"; sleep($pause); }