ezuk
Joined: 04 Jun 2005 Posts: 122
|
Posted: Sun Apr 20, 2008 8:45 am Post subject: Wakeup alarm for Vista with gradual volume up |
|
|
This is an alarm clock for Windows Vista. I kept it simple on purpose.
It has a GUI which lets you set the starting volume, peak volume, and how long it will take to fade in. When the time to wake up comes, it starts a pre-set playlist (not configurable in the GUI) and then fades in over time.
You can also set a time to mute all audio (several hours before the alarm, typically) so that incoming emails won't wake you up in the middle of the night.
It is not date-dependent -- it's for people who want to wake up at the same time every day.
Note: You need Lexiko's Vista Audio Control Functions (va.ahk) and Sean's COM Standard Library (COM.ahk) to make it work.
Screenshot:
| Code: |
Playlist = Wakeup.m3u
#Persistent
#Include COM.ahk
#Include VA.ahk
COM_Init()
Gui, Add, Text, x10 y5, Mute at:
Gui, Add, Text, x95 y5, Wake at:
Gui, Add, DateTime, w80 x10 y20 ChooseNone 1 vMuteHour, HH:mm
Gui, Add, DateTime, w80 x95 y20 1 vStartHour, HH:mm
Gui, Add, Text, x10 y48, Starting volume:
Gui, Add, Slider, x90 y45 w90 gDingLow vStart_Vol noticks center tooltip
Gui, Add, Text, x10 y75, Peak volume:
Gui, Add, Slider, x90 y70 w90 gDingHigh vPeak_Vol noticks center tooltip,100
Gui, Add, Text, x10 y102, Fade duration (min):
Gui, Add, Edit, x105 y100 h20 w69
Gui, Add, UpDown, vFade_Duration Range1-90, 20
Gui, Add, Button, x10 y130 w180 gSave, &Save settings
Gui -resize -minimizebox toolwindow
Gui, show
; Menu, Tray,Icon, clock.ico ;That's the icon I use.
Menu,Tray,add,Set New Time,Show
Menu,Tray,default,Set New Time
Return
Show:
GuiControl,,MuteHour,%MuteHour%
GuiControl,,StartHour,%StartHour%
GuiControl,,Start_Vol,%Start_Vol%
GuiControl,,Peak_Vol,%Peak_Vol%
GuiControl,,Fade_Duration,%Fade_Duration%
Gui,show
Return
DingLow:
CurrentVolume :=VA_GetMasterVolume()
VA_SetMasterVolume(Start_Vol)
SoundPlay *-1
sleep,1000
Va_SetMasterVolume(CurrentVolume)
Return
DingHigh:
CurrentVolume :=VA_GetMasterVolume()
VA_SetMasterVolume(Peak_Vol)
SoundPlay *-1
sleep,1000
Va_SetMasterVolume(CurrentVolume)
Return
Save:
Gui,submit
If (Start_Vol > Peak_Vol) {
MsgBox,16, Oops, Starting volume is greater than peak volume. Please correct.
Gosub, show
}
VolIncrement := (Peak_Vol-Start_Vol)/(Fade_Duration*600)
StartHour := SubStr(StartHour,9,4)
MuteHour := SubStr(MuteHour,9,4)
Menu,Tray,tip,Alarm set to %StartHour%
Gosub,CheckTime
SetTimer,CheckTime,58000
Return
CheckTime: ; runs every 58 seconds to see if the sound should be muted or the alarm should be triggered.
ShortNow := SubStr(A_Now,9,4)
;Do this if it's time to mute:
If (ShortNow = MuteHour) {
VA_SetMasterMute(True)
}
;Do this if it's time to fade in:
If (ShortNow = StartHour) {
Run,%Playlist%
SetTimer,CheckTime,On
VA_SetMasterMute(False)
VA_SetMasterVolume(Start_Vol)
SetTimer,FadeIn,100
}
Return
FadeIn: ;this function runs every 100ms seconds when the alarm is triggered.
VA_SetMasterVolume(Start_Vol)
Start_Vol:=Start_Vol+VolIncrement
Volume:=VA_GetMasterVolume()
If (Volume >= Peak_Vol) {
SetTimer,FadeIn,Off
}
Return
|
|
|