Страница в процессе наполнения
На этот раз в качестве корпуса для интернет радиоприемника я использовал корпус от американского лампового радиоприемника Zenith Deluxe K518 (Сова) 1952 года выпуска. Это прекрасный образец дизайна Атомной эры (40е-60е годы прошлого века). Приемник попал ко мне в сильно нерабочем состоянии, что хорошо, потому, что распотрошить рабочий аппарат у меня бы не поднялась рука.
Имитация работы радиоприемника реализована при помощи микрокомпьютера Raspberry который спрятан под радиолампами. Программный код написан на языке Python. Управляется радиоприемник двумя ручками – громкость и настройка радиостанции. Никаких Bluetooht, сопряжений со смартфоном, пультов ДУ и прочих современных штук. Радиостанции тоже подобраны в ретро стиле без надоедливой рекламы.
Для проекта понадобится:
- Корпус от старого радиоприемника 100-300$
- Raspberry Pi3b – 35$
- USB Звуковая карта– 2$
- Аналогово-цифровой преобразователь для RPi – 3$
- Переменный зезистор с линейной шкалой 1K – 0.1$
- Усилитель мощности с регулятором громкости и выключателем питания – 0.7$
- Источник питания 5V 3A – 4$
- Прочая мелочевка, etc. – 3$
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
#pip3 install adafruit-circuitpython-ads1x15 # Simple demo of reading each analog input from the ADS1x15 and printing it to # the screen. # Author: Tony DiCola # License: Public Domain # Import the ADS1x15 module. import Adafruit_ADS1x15 import os, subprocess import signal import time import random import RPi.GPIO as GPIO GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(12, GPIO.OUT, initial=GPIO.HIGH) GPIO.setup(16, GPIO.IN) #http://server.audiopedia.su:8000/ices128 # старое радио # http://bookradio.hostingradio.ru:8069/fm # Книги казань # http://gimadut.ddns.net:8000/book # еще книги #http://146.71.124.10:8100 radio_stations={ 1:'http://server.audiopedia.su:8000/ices128', 2:'http://icecast.vgtrk.cdnvideo.ru/mayakfm_mp3_192kbps', 3:"http://icecast.vgtrk.cdnvideo.ru/kulturafm_mp3_192kbps", 4:"https://radiorecord.hostingradio.ru/naft96.aacp", 5:"http://server.audiopedia.su:8000/ices128", 6:"https://retro70.hostingradio.ru:8025/retro80-128.mp3", 7:"http://bookradio.hostingradio.ru:8069/fm", 8:"https://retro70.hostingradio.ru:8025/retro70-128.mp3", 9:"http://solid41.streamupsolutions.com:10099/stream", 10:"http://ice64.securenetsystems.net:80/BILTMORE" } #"http://solid41.streamupsolutions.com:10099/stream", #Классное ретро #http://solid41.streamupsolutions.com:10099/stream #http://fallout.fm:8000/falloutfm8.ogg #print(radio_stations[1][1]) #1:('http://146.71.124.10:8100',(-100,165)), # Create an ADS1115 ADC (16-bit) instance. adc = Adafruit_ADS1x15.ADS1115() pid = False GAIN = 1 while True: # Read all the ADC channel values in a list. #values = [0] values = adc.read_adc(0, gain=GAIN) #print(values) if values in range(-100,2240): if pid: os.killpg(pid1,signal.SIGTERM) pid =False if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[1]+'\n': cmd = f'sudo killall -v mpv ; mpv {radio_stations[1]} &' #print(cmd) subprocess.Popen(cmd, shell = True) if values in range(2241,4186): #Маяк if pid: os.killpg(pid1,signal.SIGTERM) pid =False if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[2]+'\n': cmd = f'sudo killall -v mpv ; mpv {radio_stations[2]} &' #print(cmd) subprocess.Popen(cmd, shell = True) if values in range(4187,6372):# Культура if pid: os.killpg(pid1,signal.SIGTERM) pid =False if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[3]+'\n': cmd = f'sudo killall -v mpv ; mpv {radio_stations[3]} &' subprocess.Popen(cmd, shell = True) if values in range(6373,8036): if pid: os.killpg(pid1,signal.SIGTERM) pid =False if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[4]+'\n': cmd = f'sudo killall -v mpv ; mpv {radio_stations[4]} &' subprocess.Popen(cmd, shell = True) if values in range(8037,9645): if pid: os.killpg(pid1,signal.SIGTERM) pid =False if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[5]+'\n': cmd = f'sudo killall -v mpv ; mpv {radio_stations[5]} &' subprocess.Popen(cmd, shell = True) if values in range(9646,11259): if pid: os.killpg(pid1,signal.SIGTERM) pid =False if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[6]+'\n': cmd = f'sudo killall -v mpv ; mpv {radio_stations[6]} &' subprocess.Popen(cmd, shell = True) if values in range(11260,13365): if pid: os.killpg(pid1,signal.SIGTERM) pid =False if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[7]+'\n': cmd = f'sudo killall -v mpv ; mpv {radio_stations[7]} &' subprocess.Popen(cmd, shell = True) if values in range(13366,15795): if pid: os.killpg(pid1,signal.SIGTERM) pid =False if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[8]+'\n': cmd = f'sudo killall -v mpv ; mpv {radio_stations[8]} &' subprocess.Popen(cmd, shell = True) if values in range(15796,30000): if pid: os.killpg(pid1,signal.SIGTERM) pid =False if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[9]+'\n': cmd = f'sudo killall -v mpv ; mpv {radio_stations[9]} &' subprocess.Popen(cmd, shell = True) time.sleep(0.3) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import Adafruit_ADS1x15 import os, subprocess, time, pygame adc = Adafruit_ADS1x15.ADS1115() GAIN = 1 pygame.mixer.init() pygame.mixer.music.load("radio.mp3") pygame.mixer.music.play(-1) mplayer_run = True this_value = adc.read_adc(0, gain=GAIN) while True: prev_value = this_value this_value = adc.read_adc(0, gain=GAIN) change = (this_value-prev_value)/prev_value #print(change) if abs(change)>0.0009: if mplayer_run == True: cmd = 'sudo killall -v mplayer &' subprocess.Popen(cmd, shell = True) mplayer_run = False #print('kill') pygame.mixer.music.unpause() else: mplayer_run = True time.sleep(0.5) pygame.mixer.music.pause() #print('pause') time.sleep(0.1) |
Еще вариант кода с проигрыванием радиостанций с диска
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# Simple demo of reading each analog input from the ADS1x15 and printing it to # the screen. # Author: Tony DiCola # License: Public Domain import time # Import the ADS1x15 module. import Adafruit_ADS1x15 import os, subprocess import signal import time import random import RPi.GPIO as GPIO GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(12, GPIO.OUT, initial=GPIO.HIGH) GPIO.setup(16, GPIO.IN) #http://server.audiopedia.su:8000/ices128 # старое радио # http://bookradio.hostingradio.ru:8069/fm # Книги казань # http://gimadut.ddns.net:8000/book # еще книги #http://146.71.124.10:8100 #http://77.68.84.201/stream/3/ Хороший джаз radio_stations={ 11:'http://server.audiopedia.su:8000/ices128', 1:'http://77.68.84.201/stream/3/', 2:'http://icecast.vgtrk.cdnvideo.ru/mayakfm_mp3_192kbps', 3:"http://listen1.myradio24.com:9000/6262", 4:"https://radiorecord.hostingradio.ru/naft96.aacp", 5:"http://server.audiopedia.su:8000/ices128", 6:"https://retro70.hostingradio.ru:8025/retro80-128.mp3", 7:"http://bookradio.hostingradio.ru:8069/fm", 8:"https://retro70.hostingradio.ru:8025/retro70-128.mp3", 9:"http://solid41.streamupsolutions.com:10099/stream", 10:"http://ice64.securenetsystems.net:80/BILTMORE" } #http://listen1.myradio24.com:9000/6262 Спокойное радио. #"http://solid41.streamupsolutions.com:10099/stream", #Классное ретро #http://solid41.streamupsolutions.com:10099/stream #http://fallout.fm:8000/falloutfm8.ogg #print(radio_stations[1][1]) #1:('http://146.71.124.10:8100',(-100,165)), #http://icecast.vgtrk.cdnvideo.ru/kulturafm_mp3_192kbps # Create an ADS1115 ADC (16-bit) instance. adc = Adafruit_ADS1x15.ADS1115() pid = False GAIN = 1 while True: # Read all the ADC channel values in a list. #values = [0] values = adc.read_adc(0, gain=GAIN) #print(values) if values in range(-100,2240): #5 if pid: os.killpg(pid1,signal.SIGTERM) pid =False if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[1]+'\n': cmd = f'sudo killall -v mpv ; mpv {radio_stations[1]} &' #print(cmd) subprocess.Popen(cmd, shell = True) if values in range(2241,4186): #Маяк #6 if pid: os.killpg(pid1,signal.SIGTERM) pid =False if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[2]+'\n': cmd = f'sudo killall -v mpv ; mpv {radio_stations[2]} &' #print(cmd) subprocess.Popen(cmd, shell = True) if values in range(4187,6372):# Культура #7 if pid: os.killpg(pid1,signal.SIGTERM) pid =False if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[3]+'\n': cmd = f'sudo killall -v mpv ; mpv {radio_stations[3]} &' subprocess.Popen(cmd, shell = True) #8 if values in range(6373,8036): if pid: os.killpg(pid1,signal.SIGTERM) pid =False ######### voice = os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*\///"').read() #print(voice) #us_radio = os.listdir('/mnt/music/us_radio') #if not voice.rstrip() in us_radio: if not 'us_radio' in voice: random.seed() rand = random.randint(0, 30) cmd = f'sudo killall -v mpv ; mpv --audio-display=no --shuffle /mnt/music/us_radio &' subprocess.Popen(cmd, shell = True) ########## #if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[4]+'\n': #cmd = f'sudo killall -v mpv ; mpv {radio_stations[4]} &' #subprocess.Popen(cmd, shell = True) #9 if values in range(8037,9645): #print(values) if pid: os.killpg(pid1,signal.SIGTERM) pid =False ############################ voice1 = os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*\///"').read() #print(voice1) #us_radio = os.listdir('/mnt/music/relaxfm') #if not voice.rstrip() in us_radio: if not 'relaxfm' in voice1: random.seed() rand = random.randint(0, 30) cmd = f'sudo killall -v mpv ; mpv --audio-display=no --shuffle /mnt/music/relaxfm &' subprocess.Popen(cmd, shell = True) ############################ #10 if values in range(9646,11259): #10 soviet radio if pid: os.killpg(pid1,signal.SIGTERM) pid =False voice = os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*\///"').read() #print(voice) us_radio = os.listdir('/mnt/music/su_radio') #if not voice.rstrip() in us_radio: if not 'su_radio' in voice: random.seed() rand = random.randint(0, 30) cmd = f'sudo killall -v mpv ; mpv --audio-display=no --shuffle /mnt/music/su_radio &' subprocess.Popen(cmd, shell = True) #12 if values in range(11260,13365): if pid: os.killpg(pid1,signal.SIGTERM) pid =False if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[7]+'\n': cmd = f'sudo killall -v mpv ; mpv {radio_stations[7]} &' subprocess.Popen(cmd, shell = True) #14 if values in range(13366,15795): if pid: os.killpg(pid1,signal.SIGTERM) pid =False if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[8]+'\n': cmd = f'sudo killall -v mpv ; mpv {radio_stations[8]} &' subprocess.Popen(cmd, shell = True) #16 if values in range(15796,30000): #16 if pid: os.killpg(pid1,signal.SIGTERM) pid =False #if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*http/http/"').read() == radio_stations[9]+'\n': #cmd = f'sudo killall -v mpv ; mpv {radio_stations[9]} &' #subprocess.Popen(cmd, shell = True) #print(os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*\///"').read()) if not os.popen('ps aux | grep mpv | grep -v grep | head -n1 | sed "s/.*\///"').read() == 'Jazz.m4a'+'\n': random.seed() rand = random.randint(0, 4000) cmd = f'sudo killall -v mpv ; mpv -ss {rand} /home/pi/radio/Jazz.m4a &' subprocess.Popen(cmd, shell = True) time.sleep(0.3) |
398