Nav links

Wednesday, 24 August 2005

Wake to internet streaming audio

When you've become jaded with the usual morning radio shows, being woken by streaming audio from the internet becomes an enticing option. If you have a laptop, or perhaps a PDA, with WiFi, then it shouldn't be too hard to leave that near your bed at night, and have it wake automatically and play some audio. But what if you only have a PC, and it's quite some distance from your bedroom?



It turns out to be quite straightforward. What you need to happen is:


  1. PC wakes automatically at pre-determined time
  2. PC plays streaming audio
  3. Audio gets transmitted on FM band
  4. Clock-radio turns on, and receives transmitted audio



Let's go through each step in detail.



Steps 1 & 2


The first two steps depend on what operating system you have installed. In Windows XP you can combine the waking up and the playing of audio into one scheduled task. In the control panel, I set up a scheduled task to run every day at 9am. My run command is to open my web browser to play BBC Radio 4 live - "D:\net\Mozilla Firefox\firefox.exe" "http://www.bbc.co.uk/radio/aod/radio4.shtml?listen".



Under 'settings' there's a power management option to 'Wake the computer to run this task'. This uses the wonders of ACPI to make the computer turn on at the right time, even if it's hibernated and turned off.



I had to do one additional thing to get this working. When Windows XP resumes from hibernation, the network is unavailable until some time after the desktop. So when I first tested out this scheduled task, I found that it would fail because the network was not ready in time. To get around this I set up a second scheduled task, simply opening 'notepad.exe', a minute earlier than the first. This meant that the network had time to prepare itself before the request to receive Radio 4 was made.



See footnote [2] for related information.



Step 3


To transmit this audio I used the FM transmitter that I built from a kit a year ago. An easier alternative would be to buy a ready-made transmitter, such as that from C.Crane. The numerous iPod and MP3 FM transmitters now available are only designed to broadcast over a small distance of a few metres, so they probably won't be suitable for this task.



To ensure that I didn't have to leave it transmitting all night, I used a cheap indoor timer, the type that magically keeps burglars from your house when you're on holiday. The clocks on these devices are pretty rough, but it doesn't need to be terribly accurate. It just needs to encompass the possible transmitting time, so a half-hour excess to each side is not a big problem.



Step 4


Finally, you need to set your clock-radio to the frequency that your transmitter is working at. Then you can test the whole system at some decent hour, and look forward to being pleasantly awoken by the sounds of your choice.




Notes


[1] The automatic power-on option in the BIOS of many motherboards will not work when you shut down using an ACPI-aware operating system, such as Windows XP. The OS takes control of the waking up, so you must use the OS to set when and how to wake up, such as using a scheduled task. This is certainly much easier than having to get into the BIOS whenever you need to make a change.



[2] My PC needed the power supply to remain on when hibernating for the wake up to occur. This is in contrast to normal hibernation, which is unaffected by the power being turned off. So, having your PC on an indoor timer will not work, though I'd still recommend that for the transmitter.