Shared Link: https://github.com/takao-t/piradio
Turn Raspberry Pi into a radio (Radiko, Rajiru Rajiru, SDR compatible)

What you need:
Use the following, which are also found in every home
- Raspberri Pi 3 or 4 or Zero W
- 5 switches to connect to GPIO (PUSH ON)
5 pull-up resistors (*)
The basic number is 5, but you can operate with at least 2.
- LCD that can be used as a frame buffer (/ dev / fbX) (320x240 is
assumed in this script)
I'm using Adafruit's Pi TFT mini (2.8 "), but it doesn't support touch
because it's not compatible with the touch panel. It's just a switch
operation.
Even the cheap SPI TFT sold in that area can be used if it can be
operated as / dev / fbX.
- Suitable TTF font for Japanese display
- Please install ffmpeg separately. Use ffplay.
*: When connecting a switch to GPIO, pull it up and connect the switch between the pin and GND.
Normal (piradio.py) version
Since pygame is used for the screen, a frame buffer that can be used with pygame is required.
For now for Python 2.7
Pirate Audio (piradio_pirate.py) (
The screen is written in PIL. Pirate Audio does not work as a
framebuffer, but it requires the SPI LCD Python library. See
Pirate_README.txt.
There are many Radiko playback scripts here and there, but since the
source is not clear, I wrote a new one and implemented it in radiko.py.
It also supports Radiko Premium. If you want to use area free, you can
use it by registering for premium and setting your e-mail address and
password. In order to avoid frequent logins when using Premium, cookie
information is stored in the current directory, so start it in a
directory where scripts can be written.
Modify the script if you want to save the cookie elsewhere.
Even if there is no frame buffer, it will be a radio for API
operation. If you start it with -nogui, it will work only with API.
However, the volume at the initial startup is too low, so adjust vol_val
and start it.
Please refer to the Wiki for detailed explanation and usage.
The chassis data is here https://www.thingiverse.com/thing:4417542
Update information and detailed usage etc. can be found on the Wiki https://github.com/takao-t/piradio/wiki
Let's make a radio

A project to make a radio because radio is more interesting
However, since it is the 21st century, we will use Radiko instead of 6-stone supermarkets.
Currently, it supports Radiko, Rajiru Rajiru, FM reception by SDR, and stream playback.
There is also a Pimoroni Pirate Audio compatible version
I don't have anything
I bought a Raspberry Pi. A PC + audio interface will do the trick, though.
Basically, it works if you can handle audio devices in an environment where Python works.
I only have a Raspberry Pi
If you start it with python piradio.py -nogui, it will start without
GUI. Since there is an API, it is an ant if you want to make a radio
controlled by a browser.
In this case, you cannot control the volume (the API has no volume), so
pay attention to the initial value of the volume.
When controlling from a browser, you can see it by looking at
index_sample.php under the attached webui, but if there is a directory
called stations / under this PHP, and there is a station list and icon
file called station_list, it will look like A crappy page is displayed.
In short, it's easy to make a symbolic link from the stations /
directory of piradio.
Whether it's API or webui, it's super messy, so please use it only in a
LAN environment.
I have a Raspberry Pi and an LCD
In this case, you can use the GUI, but you need 5 pushbutton switches
for operation. Connect the switch between a free GPIO and GND. It's
safe to do a pull-up, but depending on the pin, the Raspberry Pi pull-up
alone is fine.
I'm not sure how to set up the LCD because I don't know what the LCD
you have, but basically it should work if it's a framebuffer that can be
used with Pygame. The expected resolution is 320x240 dots, and I used
Adafruit's Pi TFT mini (2.8 ") at the time of development.
It can also be used with SPI TFT LCDs, which are sold at a bargain
price. However, you need something that is supported by fbtft and is
recognized as a framebuffer. If you try it and you know how to use it
even if it is sold at a bargain price such as amazon (2.4 "is cheap), it
will work without much trouble. Since you know how to use it, you will
not have any trouble. but.
Anyway, the display used by the regular version of piradio.py is the
framebuffer used by Pygame. X does not need to work, but it should be
recognized and work as / dev / fbX.
I want to be cool
If you are good at woodworking, it is cool to make a cabinet.
For those who have a 3D printer, we publish the 3D data of the cabinet.
https://www.thingiverse.com/thing:4417542
This cabinet has a 5cm speaker underneath, so it's easy to buy a
USB-connected speaker that uses a 5cm unit, disassemble it, and push it
in. You may have a little trouble fixing the speaker, but please screw
it or stick it with double-sided tape.
When using Pi2 / Pi3, please use a case with holes. USB and LAN come
out next to it, so it's a bit clunky, but you can also make it a wired
type. When using a USB speaker, pull out the cable from the gap and
insert it. It would be nice if the Pi had a USB header on the board, but
unfortunately it doesn't.
I want to buy something
For those who don't have anything but want to buy something, the
Raspberry Pi Zero WH and Pimoroni Pirate Audio are recommended.
https://github.com/takao-t/piradio/wiki/Pimoroni-Pirate-Audio%E3%82%92%E3%83%A9%E3%82%B8%E3%82%AA%E3%81%
AB% E3% 81% 97% E3% 82% 88% E3% 81% 86
There are three types of Pirate Audio, and I'm wondering which one to
buy, but the only difference is the audio output method, so I choose
what I want to connect to. With Pirate Audio with speakers, it's the
smallest radio.
We also have a frame that can be printed in 3D.
https://www.thingiverse.com/thing:4420857
Application
In short, I'm just writing a front end for playing Radiko, so if you apply it, you can use it for other things as well.
As you can see from the inside, since I am writing a program to kick
with the playback method and its method, it is easy to apply by touching
the source.
If you look at start.php etc., you can see how to kick with API, so you can prepare it with cron and wake up.
It is easy to support if the station supports stream (simul) even in
community FM. If you know the stream URL, you can play it, so you can
use it because it can be incorporated into the station list.
Tag: #GiammaIoT @GiammaIoT @GiammaIoT2 #SoftwareDefinedRadio #SoftwareDefinedRadios #Standalone #Raspberry