raspberry pi zero W である。小生はスイッチサイエンスの単品抽選に落選してヤフオクで3,000円で落札したが、賢明な諸氏にはスイッチサイエンスで「Raspberry Pi Zero W、Raspberry Pi Zero ケース、miniHDMI変換アダプタ、USB-microB OTGケーブルがセットになった最小構成のキット」が2,808円と送料150円なのでそちらをオススメする。スピードは遅いが、ラジオを聞くには十分な性能である。届いてから気がついて驚いたのだが、ラインアウトが無いのでUSBダックは必須である。 ラズパイスタンドの作り直しで余った3.5インチに取り付けて、お気に入りのアルニコマグネット フルレンジ 10センチを搭載した自作ラジオを改造した。 本題であるが、NHKのらじる☆らじるが仕様変更してスクリプトで聞けなくなっていた。9月かららしい。困ったものだとグルグルしていると、あるハグレエンジニア様がらじる☆らじるの音声データをループ再生してくれるスクリプトを公開されていた。やっていることはらじる☆らじると同様だと思うのだが、データの継ぎ目で音が途切れる。まあ、気にしなければ気にならない。あるハグレエンジニア様を参考にアドレスを探せば必要な局がわかる。あるハグレエンジニア様のスクリプトを借用して利用させていただいた。少し変更して nhk1.pl nhkfm.pl と保存してpi.plを書きなおして使わせていただく。 変更点は以下である。 nhk1.plで保存 #/bin/bash audio=alsa #URL="http://nhkradioikr1-i.akamaihd.net/hls/live/512098/1-r1/1-r1-01.m3u8" #札幌局第1 #を付ける URL="http://nhkradioakr1-i.akamaihd.net/hls/live/511633/1-r1/1-r1-01.m3u8" #首都圏第1 #を取る mode="-really-quiet -cache 700 " while true do date +'%T' mplayer -playlist ${URL} ${mode} -vo null -ao ${audio} 2>/dev/null done nhkfm.plで保存 #/bin/bash audio=alsa #URL="http://nhkradioikr1-i.akamaihd.net/hls/live/512098/1-r1/1-r1-01.m3u8" #札幌局第1#を付ける #URL="http://nhkradioakr1-i.akamaihd.net/hls/live/511633/1-r1/1-r1-01.m3u8" #首都圏第1 URL="https://nhkradioakfm-i.akamaihd.net/hls/live/512290/1-fm/1-fm-01.m3u8" #一行追加する(エリアに応じたURLがいいかも) mode="-really-quiet -cache 700 " while true do date +'%T' mplayer -playlist ${URL} ${mode} -vo null -ao ${audio} 2>/dev/null done 書き直したpi.pl #!/usr/bin/perl use Tk; use Encode; ## pi.pl# 改訂版 初期設定 ################################################### my $msg = "yes"; #シャットダウン時にメセージを表示する yes/no my $geometry = "+10+40"; #表示位置 my $minsize1 = 460; #サイズW my $minsize2 = 140; #サイズH my $tmGeometry = "42x3+10+210"; #gnorm-terminal サイズ/表示位置 my $pVol = "20"; #初期ボリューム my $font = "MS ゴシック 8 bold"; #フォント my $bt0Img = "./raspA.gif"; #aplayボタン 画像 my $bt0Bac = "#fffacd"; #aplayボタン 背景色 my $bt0ABac = "#ffff00"; #aplayボタン アクティブ背景色 my $nextTxt = "▶"; #ネクストボタン テキスト(Aplay 専用) my $nextFont = "MS ゴシック 18 bold"; #フォント my $nextFore = "#333333"; #ネクストボタン 文字色 my $nextAFore = "#ffffff"; #ネクストボタン アクティブ文字色 my $stopTxt = "×"; #ストップボタン テキスト(gnorm-terminal を閉じる) my $stopFore = "#333333"; #ストップボタン 文字色 my $stopAFore = "#ffffff"; #ストップボタン アクティブ文字色 my $stopABase = "#113355"; #ストップボタン アクティブ背景色 my $swTxt = "◯"; #シャットダウン テキスト my $swFont = "MS ゴシック 18 bold"; #シャットダウン フォント my $swBac = "#555555"; #シャットダウン 背景色 my $swABac = "#b50008"; #シャットダウン アクティブ背景色 my $swFore = "#dddddd"; #シャットダウン 文字色 my $swAFore = "#ffffff"; #シャットダウン アクティブ文字色 my $volFore = "#333333"; #ボリューム 文字色 my $volBac = "#fff0f5"; #ボリューム 背景色 my $volABac = "#da70d6"; #ボリューム アクティブ色 my $bt1Id = "TBS"; #Radico1 ID (http://www.norikistudio.com/station-id-list) my $bt1Txt = "TBS"; #Radico1 テキスト my $bt1Fore = "#333333"; #Radico1 文字色 my $bt1Bac = "#40e0d0"; #Radico1 背景色 my $bt1AFore = "#dedede"; #Radico1 アクティブ文字色 my $bt1ABac = "#333333"; #Radico1 アクティブ背景色 my $bt2Id = "FMJ"; #Radico2 ID (http://www.norikistudio.com/station-id-list) my $bt2Txt = "FMJ"; #Radico2 テキスト my $bt2Fore = "#333333"; #Radico2 文字色 my $bt2Bac = "#87cefa"; #Radico2 背景色 my $bt2AFore = "#dedede"; #Radico2 アクティブ文字色 my $bt2ABac = "#333333"; #Radico2 アクティブ背景色 my $bt3Id = "./nhk1.sh"; #らじるらじる1 nhk1.pl使用 my $bt3Txt = "NHK1"; #らじるらじる1 テキスト my $bt3Fore = "#333333"; #らじるらじる1 文字色 my $bt3Bac = "#ffd700"; #らじるらじる1 背景色 my $bt3AFore = "#dedede"; #らじるらじる1 アクティブ文字色 my $bt3ABac = "#333333"; #らじるらじる1 アクティブ背景色 my $bt4Id = "./nhkfm.sh"; #らじるらじる2 nhkfm.pl使用 #my $bt4Id = "firefox http://www.nhk.or.jp/radio/player/?ch=fm"; #firefoxでページを直接開く場合 my $bt4Txt = "N-FM"; #らじるらじる2 テキスト my $bt4Fore = "#333333"; #らじるらじる2 文字色 my $bt4Bac = "#ffe4e1"; #らじるらじる2 背景色 my $bt4AFore = "#dedede"; #らじるらじる2 アクティブ文字色 my $bt4ABac = "#333333"; #らじるらじる2 アクティブ背景色 #SHOUTcastボタン #ID アクティブ背景色 文字色 背景色 アクティブ文字色 テキスト my $s1Id = "1734059"; my $s1Ab = "#333333"; my $s1Fo = "#333333"; my $s1Ba = "#98fb98"; my $s1Af = "#dedede"; my $s1Tx = "WNCS";#WNCS The Point! my $s2Id = "1331549"; my $s2Ab = "#333333"; my $s2Fo = "#333333"; my $s2Ba = "#da70d6"; my $s2Af = "#dedede"; my $s2Tx = "Jamm";#Jamm FM my $s3Id = "297368"; my $s3Ab = "#333333"; my $s3Fo = "#333333"; my $s3Ba = "#db7093"; my $s3Af = "#dedede"; my $s3Tx = "smooth";#Smooth Jazz Florida Plus my $s4Id = "15953"; my $s4Ab = "#333333"; my $s4Fo = "#333333"; my $s4Ba = "#ffa500"; my $s4Af = "#dedede"; my $s4Tx = "EI";#El Tocadiscos my $s5Id = "1108330"; my $s5Ab = "#333333"; my $s5Fo = "#333333"; my $s5Ba = "#c0c0c0"; my $s5Af = "#dedede"; my $s5Tx = "NST";#Nonstop Casiopea my $s6Id = "1477271"; my $s6Ab = "#333333"; my $s6Fo = "#333333"; my $s6Ba = "#dda0dd"; my $s6Af = "#dedede"; my $s6Tx = "BEST";#BEST SMOOTH JAZZ - UK (LONDON) HOST ROD LUCAS my $s7Id = "1323717"; my $s7Ab = "#333333"; my $s7Fo = "#f8f8ff"; my $s7Ba = "#dc143c"; my $s7Af = "#dedede"; my $s7Tx = "LOUNGE";#PulsRadio LOUNGE my $s8Id = "1292701"; my $s8Ab = "#333333"; my $s8Fo = "#333333"; my $s8Ba = "#f0e68c"; my $s8Af = "#dedede"; my $s8Tx = "Lounge";#Nonstop Casiopea my $s9Id = "1563396"; my $s9Ab = "#333333"; my $s9Fo = "#333333"; my $s9Ba = "#fff5ee"; my $s9Af = "#dedede"; my $s9Tx = "Gloval";#SmoothJazz.com Global my $s10Id = "419932"; my $s10Ab = "#333333"; my $s10Fo = "#333333"; my $s10Ba = "#da70d6"; my $s10Af = "#dedede"; my $s10Tx = "WSJE";#WSJE-DB - Smooth Jazz Expressions my $s11Id = "1077152"; my $s11Ab = "#333333"; my $s11Fo = "#333333"; my $s11Ba = "#9acd32"; my $s11Af = "#dedede"; my $s11Tx = "World";#The world my $s12Id = "1586446"; my $s12Ab = "#333333"; my $s12Fo = "#333333"; my $s12Ba = "#da70d6"; my $s12Af = "#dedede"; my $s12Tx = "Jpop";#J-Pop Sakura 17 my @Id = ($s1Id,$s2Id,$s3Id,$s4Id,$s5Id,$s6Id,$s7Id,$s8Id,$s9Id,$s10Id,$s11Id,$s12Id); my @Tx = ($s1Tx,$s2Tx,$s3Tx,$s4Tx,$s5Tx,$s6Tx,$s7Tx,$s8Tx,$s9Tx,$s10Tx,$s11Tx,$s12Tx); my @Ab = ($s1Ab,$s2Ab,$s3Ab,$s4Ab,$s5Ab,$s6Ab,$s7Ab,$s8Ab,$s9Ab,$s10Ab,$s11Ab,$s12Ab); my @Af = ($s1Af,$s2Af,$s3Af,$s4Af,$s5Af,$s6Af,$s7Af,$s8Af,$s9Af,$s10Af,$s11Af,$s12Af); my @Ba = ($s1Ba,$s2Ba,$s3Ba,$s4Ba,$s5Ba,$s6Ba,$s7Ba,$s8Ba,$s9Ba,$s10Ba,$s11Ba,$s12Ba); my @Fo = ($s1Fo,$s2Fo,$s3Fo,$s4Fo,$s5Fo,$s6Fo,$s7Fo,$s8Fo,$s9Fo,$s10Fo,$s11Fo,$s12Fo); my $padxi = 0; my $padyi = 0; ##################################################################### my $bTi = 0; $mw = new MainWindow(); $mw->minsize($minsize1,$minsize2); $mw->geometry("$geometry"); $main = $mw->Frame(); $main->pack( -side => "top", -fill => "both", -expand => "yes", ); $mainL = $main->Frame(); $mainL->pack( -side => "left", ); $image = $mainL->Photo( -file => "$bt0Img" ); $bt0 = $mainL->Button( -image => $image, -relief => "flat", -background => "$bt0Bac", -activebackground => "$bt0ABac", -padx => 0, -pady => 0, -command => \&Ap, ); $bt0->pack( -side => "left", -fill => "both", -expand => "yes", ); $mainL2 = $mainL->Frame(); $mainL2->pack( -side => "left", -fill => "both", -expand => "yes", ); $next = $mainL2->Button( -relief => "flat", -text => decode("utf8", "$nextTxt"), -font => "$nextFont", -activeforeground => "$nextAFore", -foreground => "$nextFore", -background => "$bt0Bac", -activebackground => "$bt0ABac", -padx => 0, -pady => 0, -command => \&Next, ); $next->pack( -side => "top", -fill => "both", -expand => "yes", ); $stop = $mainL2->Button( -relief => "flat", -text => decode("utf8", "$stopTxt"), -font => "$font", -activeforeground => "$stopAFore", -foreground => "$stopFore", -background => "$bt0Bac", -activebackground => "$stopABase", -padx => 0, -pady => 0, -command => \&Chk, ); $stop->pack( -side => "top", -fill => "both", -expand => "yes", ); $mainR = $main->Frame(); $mainR->pack( -side => "left", -fill => "both", -expand => "yes", ); $mainR1 = $mainR->Frame( -padx => $padxi, -pady => $padyi, ); $mainR1->pack( -side => "top", -fill => "both", -expand => "yes", ); $bt1 = $mainR1->Button( -relief => "flat", -text => decode("utf8", "$bt1Txt"), -font => "$font", -activebackground => "$bt1ABac", -activeforeground => "$bt1AFore", -background => "$bt1Bac", -foreground => "$bt1Fore", -padx => $padxi, -pady => $padyi, -command => \&Nr1, ); $bt1->pack( -side => "left", -fill => "both", -expand => "yes", ); $bt2 = $mainR1->Button( -relief => "flat", -text => decode("utf8", "$bt2Txt"), -font => "$font", -activebackground => "$bt2ABac", -activeforeground => "$bt2AFore", -background => "$bt2Bac", -foreground => "$bt2Fore", -padx => $padxi, -pady => $padyi, -command => \&Nr2, ); $bt2->pack( -side => "left", -fill => "both", -expand => "yes", ); $bt3 = $mainR1->Button( -relief => "flat", -text => decode("utf8", "$bt3Txt"), -font => "$font", -activebackground => "$bt3ABac", -activeforeground => "$bt3AFore", -background => "$bt3Bac", -foreground => "$bt3Fore", -padx => $padxi, -pady => $padyi, -command => \&Nr3, ); $bt3->pack( -side => "left", -fill => "both", -expand => "yes", ); $bt4 = $mainR1->Button( -relief => "flat", -text => decode("utf8", "$bt4Txt"), -font => "$font", -activebackground => "$bt4ABac", -activeforeground => "$bt4AFore", -background => "$bt4Bac", -foreground => "$bt4Fore", -padx => $padxi, -pady => $padyi, -command => \&Nr4, ); $bt4->pack( -side => "left", -fill => "both", -expand => "yes", ); for($i = 0; $i < 12; $i++){ if($i == 0||$i == 4||$i == 8){ if($i == 0){$fii = 1;}elsif($i == 4){$fii = 2;}elsif($i == 8){$fii = 3;} $mainRs[$fii] = $mainR->Frame( -padx => $padxi, -pady => $padyi, ); $mainRs[$fii]->pack( -side => "top", -fill => "both", -expand => "yes", ); } $sh[$i] = $mainRs[$fii]->Button( -relief => "flat", -text => decode("utf8", "$Tx[$i]"), -font => "$font", -activebackground => "$Ab[$i]", -activeforeground => "$Af[$i]", -background => "$Ba[$i]", -foreground => "$Fo[$i]", -padx => $padxi, -pady => $padyi, -command => [ \&Scast,$Id[$i] ], ); $sh[$i]->pack( -side => "left", -fill => "both", -expand => "yes", ); } $mvol = $mw->Frame(); $mvol->pack( -side => "top", -fill => "both", -expand => "yes", ); $sc = $mvol->Scale( -orient => "horizontal", -from => 0, -to => 100, -variable => \$vol, -command => \&Cv, -activebackground => "$volABac", -background => "$volBac", -foreground => "$volFore", ); $sc->set($pVol); $sc->pack( -side => "left", -fill => "both", -expand => "yes", ); $sw = $mvol->Button( -text => decode("utf8", "$swTxt"), -font => "$swFont", -relief => "flat", -text => decode("utf8", "$swTxt"), -font => "$font", -activeforeground => "$swAFore", -activebackground => "$swABac", -background => "$swBac", -foreground => "$swFore", -padx => 0, -pady => 0, -command => \&Sdown, ); $sw->pack( -side => "left",, ); MainLoop; ##################################################################### sub Ap{ &Chk; $bTi = 8; system("gnome-terminal --geometry=$tmGeometry --command=\"perl splay.pl -def -list\""); } sub Chk{ if($bTi){system("killall -s HUP gnome-terminal-server firefox"); $bTi = 0;}; #Terminal Window Close } sub Next{ system("killall -s HUP aplay mpg321 vlc"); } sub Nr1{ &Chk; $bTi = 8; system("gnome-terminal --geometry=$tmGeometry --command=\"./play_radiko.sh $bt1Id\""); #ID } sub Nr2{ &Chk; $bTi = 8; system("gnome-terminal --geometry=$tmGeometry --command=\"./play_radiko.sh $bt2Id\""); #ID } sub Nr3{ &Chk; $bTi = 8; system("gnome-terminal --geometry=$tmGeometry --command=\"$bt3Id\""); #ID } sub Nr4{ &Chk; $bTi = 8; if($bt4Id eq "./nhkfm.pl"){system("gnome-terminal --geometry=$tmGeometry --command=\"$bt4Id\"");} else {system("$bt4Id");} } sub Scast{ &Chk; $bTi = 8; system("gnome-terminal --geometry=$tmGeometry --command=\"mplayer -playlist http://yp.shoutcast.com/sbin/tunein-station.pls?id=$_[0]\""); #ID } sub Cv{ system("amixer -c 0 sset PCM $vol\%"); #ヴォリューム USB (ライン出力の場合は 1 を 0 に) } sub Sdown{ if($msg eq "yes"){ my $msgbox = $mw->messageBox( -title => "really", -icon => "question", -type => "OkCancel", -default => "Cancel", -message => decode("utf8", "シャットダウン!?"), ); if($msgbox eq 'Ok'){system("sudo shutdown -h now");}else{return; } } else{system("sudo shutdown -h now");} #Stop } ###########./pi.pl 改訂版 ##################ここまで 上記の他に splay.pl play_radiko.sh play_nhk-radio.sh raspA.gif(右のおしゃれな画像をraspA.gifで保存)radio がいる、全て/home/piに置き $ sudo chmod 755 play_radiko.sh $ sudo chmod 755 nhk1.sh $ sudo chmod 755 nhkfm.sh $ sudo chmod 755 splay.pl $ sudo chmod 777 radio $ sudo chmod 755 pi.pl さらに必要なアプリのインストールが必要である。 sudo apt-get install perl-tk sudo apt-get install gnome-terminal sudo apt-get install mplayer sudo apt-get install vlc sudo apt-get install mpg321 sudo apt-get install rtmpdump sudo apt-get install swftools sudo apt-get install libxml2-utils ラズベリーパイを起動して、ログインした画面にデーモン小暮として Perl/TK による操作画面を表示するには、 /home/pi/.profile の下の方に Perl/TK のスクリプトファイル( pi.pl )を起動するように記述する。 sudo -u pi perl /home/pi/pi.pl & ターミナルで perl pi.pl でもよい ブラウザが煩わしいが、直接ページを開くことも考えた。ubuntuではうまくいくが、raspbianではうまくいかない。研究してみる。 国が四流国家への道を突き進んでいる時に、こんなことをしていていいのだろうか?
by digressive
| 2017-10-23 23:13
| Ubuntu
|
Comments(0)
|
カテゴリ
全体熟年マカー失業録 DTPに花束を すみません、取り乱しました。 マカーはケチだから Ubuntu プアオーディオ ペンタブしよう non6 nuseum リンク
ホームページ作成 WEBデザイン(Perl PHP MySQL) グラフィックデザイン CI 各種印刷物 広告 SP はじめました。 ■□■□■□ RandomReading《読書記録》 通勤電車が私の書斎さ。 ■□■□■□ WEBカラーネーム WEBカラーチャート 植草一秀の『知られざる真実』 頑張れミラーマン 世に倦む日々 無料版です 天木直人.com 多少偏向していそうだが、 文春よりは参考になる きっこのブログ 謎のブログ、リンクしていいのかな? とりまきメモ ブログというより、日記帳ですね。 LINK MEMO 小生の勝手なリンク集 pixiv お気に入りブログ
世に倦む日日絵と音楽のコラボレーショ... ライフログ
検索
タグ
フルレンジ
raspberry pi
ヘッドホン
真空管アンプ
KOBE
bluetooth
iPhone-color
iPhone
ハードオフ
raspbian
アルニコ
ヘッドホンアンプ
パワーアンプ
フォノイコライザー
ヘッドホン自作
HOLGA-color
i2s
Raspberry Pi
ランダム再生
オペアンプ
学研
インターネットラジオ
木製ヘッドホン
ハイレゾ
HyCAA
Bluetooth
USB DAC
volumio2
YDA138
volumio
小金井市
aplay
新年
infinite painter
6j1
ラジオ
自作
ダイソー
raspberry pi 3
usb dac
Raspbian
yda138
ポートアイランド
改造
アンプ
cdプレーヤー
se-u33g
カーオーディオ
ES9018K2M
dac
山水
mac mini
Hex3653
ta2020
マイナンバー
マイナンバーカード
ubuntu mate
TVTest
サブウーファー
TvRock
真空管
神戸
モノラルアンプ
ES9023
windows10
fostex
google home mini
スピーカー
大人の科学
きのこ帝国
NFJ
SQ5
電解コンデンサー
ht82v739
レコードプレーヤー
applepencil
USBダック
SSD
HOLGA
4B-1B
イヤホン
バランス出力
radiko
Volumio2
javascript
TDA2822M
PCスピーカー
PC自作
PD2506Q
Perl/TK
Photoshop
REIYIN DA-DD
RIAA
Radiko
Raspberry
Raspberry Pi 4
RockBox
Rspbian
SD カード
SDGs
ブログパーツ
| |||||||||||||||||||||||||||||||||||||||||||||||||
ファン申請 |
||