Showing posts with label pyfmradio. Show all posts
Showing posts with label pyfmradio. Show all posts

Sunday, December 9, 2007

MediaBox gets FM radio

I have been busy getting FM radio in the MediaBox media center ready for release. So if you have a N800 (the only Nokia internet tablet with built-in FM tuner chip so far), you will get the radio button at the bottom.

FM radio in action

But the new release will also bring some improvements to N810 users (sorry, no FM radio on the N810...). Kinetic scrolling is now smoother without the occasional "hiccups" while playing an audio file. Some bugs have been squashed as well.

Oh, and since MediaBox uses pyFMRadio for the FM radio, I made a new release of this as well. The new version has improved signal scanning for automatic station detection.

Monday, November 19, 2007

N800's FM radio now works in Japan

My kernel patch for FM band selection on the N800 was confirmed to work in Japan. Now I'm going to clean it up a little and improve support for it in pyFMRadio. Thanks to Kenroy Harrison for testing it!

Sunday, November 18, 2007

Enabling FM band selection on the N800

The Nokia N800 has a built-in FM radio which can't currently be used in Japan since Japan uses a different FM band (76 MHz to 90 MHz) than Europe and the US (87.5 MHz to 108 MHz).
Thanks to Kenroy Harrison for pointing this out.

The TEA5761 FM chip on the N800 supports the Japanese band by setting the BLIM bit but this is not supported by Nokia's driver code (Nokia doesn't sell the N800 in Japan anyway). So I have built a patched kernel enabling setting the BLIM bit.
The new release of pyFMRadio adds support for this kernel and allows switching the FM band.


If you have a N800 and are currently in Japan, please test this Python code and report if it's actually working:


from FMRadio import FMRadio
import time

r = FMRadio()
r.set_fm_band(r.FM_BAND_JPN)
for freq in r.scan():
r.set_frequency(freq)
r.set_volume(50)
time.sleep(3)
r.close()

Monday, November 12, 2007

pyFMRadio and auto-scanning

PyFMRadio, the N800 FM radio module for Python now supports automatic scanning for radio stations in the new release 0.20. The new version now also powers down the radio chip on close(), so it won't drain battery when the radio is not used.

Here's some example code for callback-based station scanning:


# import radio stuff
from FMRadio import FMRadio, FMRadioUnavailableError


stations = []


def scan_cb(freq, is_station):
"""
Callback for scanning for stations. This callback is called for every
frequency and tells you if a radio station was found.
"""

print "scanning @ %0.2f MHz" % (freq / 1000.0),
if (is_station):
print "STATION FOUND"
stations.append(freq)
else:
print ""



# open the radio
try:
radio = FMRadio()
except FMRadioUnavailableError:
# radio not available
print "Your device doesn't seem to have a FM radio..."
import sys; sys.exit(1)

# get frequency range; currently only the US/Europe frequency band is supported
# by the driver
low, high = radio.get_frequency_range()
print "Frequency range: %0.2f - %0.2f MHz" % (low / 1000.0, high / 1000.0)

# scan for radio stations
radio.scan(scan_cb)

# if we have found some stations, start playing
if (stations):
radio.set_volume(50)

print "Now listen to the radio."
for freq in stations:
print "Tuning in %0.2f MHz." % (freq / 1000.0)
radio.set_frequency(freq)
import time; time.sleep(3)

else:
print "No radio stations found. The signal is too weak."

# don't forget to shutdown the radio; this will also power down the radio chip
print "Switching off the radio."
radio.close()